Functional Programming in C# with Language-ext [closed] - c#

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I have recently started working on a new DotNet Core project. I had noticed that someone (developer) used the Language-Ext library in this project. It was a new thing for me so I got to know that it is for Functional programming. It was quite confusing for me to understand it. I googled it and found benefits of it (Functional programming) :
Less Code (main point)
Easier Debugging
Easier testing
For a OO programmer, functional programming is quite different. So, my question is do we really need to use Language-Ext (functional programming) in C#? Are there any other benefits which I am missing?

So, my question is do we really need to use Language-Ext (functional programming) in C#?
If you want to do functional programming in C# you don't need LanguageExt, but IMO this is the best library for this use case.
Are there any other benefits which I am missing?
I'm biased because I use LanguageExt for some years now and it's my favourite library. If I create/edit C# projects without this library it feels a bit like working with an ancient C# version.
What more benefits are there?
Getting rid of (many1) bugs
Getting rid of much boiler plate code
Immutable data types
Avoiding side effects (easier parallel processing)
Easier refactoring
More type safety
Can be combined with non-FP C# code (use where useful)
Better refactoring skills (get another perspective)
LanguageExt creator Paul Louth created a great introduction showing some benefits:
https://github.com/louthy/language-ext
The library now has a lot more features and if you get into this (and functional programming at all) you will find many gems.
(On the premise that you want to stay with C# -- and not use F# or Haskell or ...)

"do we really need to use Language-Ext (functional programming) in C#?"
of course not; it looks like some people choose to do that; this is IMO a tiny minority of C# users. If you wanted to embrace functional style, you'd probably look at F# (while C# does offer some minor nods to functional programming, it isn't the speciality of the language). If language-ext adds just that bit more that you want... great? But this is entirely subjective and contextual.

Related

What is the most efficient method in converting AutoLISP legacy code to C#? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am engaged in a project that works mainly in AutoCAD to design and manufacture prefabricated building components such as roofing trusses. One of our goals is to redesign a program that was written in LISP that functions in designing roofing trusses. We are to rewrite the LISP code in C# and incrementally implement it into the current libraries that they have set up.
My problem is that I have been tasked with building a rudimentary LISP to C# converter. After some research (as Google results quickly show that such a thing does not readily exist on hand), I have come to the question of which way of converting this legacy code would be more efficient. Would it be better to take chunks of the LISP code to analyze and rewrite in C#, or should I continue on with developing a rudimentary converter for the AutoLISP code?
You should take chunks of the LISP code and rewrite in C#.
Even if it was less effort to write a general purpose LISP interpreter in C# than to rewrite the LISP in c# (which is highly improbable), the LISP is probably running AutoCAD commands like you would type in the AutoCAD command line instead doing things the ObjectARX way. So you would also need to convert the commands to use the ObjectARX API.
C# is a compiled object-oriented programming language whereas AutoLISP is an interpreted expression-oriented language. Therefore there is never going to be a really straightforward way of converting one to the other without a monumental effort.
Its worth noting that AutoLISP has flexibility to be modified quickly without needing to be recompiled. The benefit to using native in-process C# is that it's extremely fast versus a similar LISP approach. I've found there's a nice middle ground for maintaining the flexibility of LISP with the speed and power of C# which leverages the LispFunction command flag and ResultBuffer type in the .NET native API.

Clarification on Static and Primitives [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Static and primitives are not part of OOPs. I have read that static and primitives are not allowed in scala class definitions. If this is true, then why static and primitives were allowed in java and in c# and few other languages?
They are not part of "pure" Object Oriented, but sometimes "pure" gets in the way of "getting the job done".
Using primitives can make mathematical operations (in particular) much faster, and statics enable a lot of useful design patterns.
C#, C++ and Java are a general purpose programming languages. You can find for example elements of duck-typing in C# 4.0, elements of functional programming, and many more useful constructs.
Not every program and not every part of a program has to be object oriented. Use OOP when needed and when it serves purpose, in C#, C++ and Java you can use other or simpler constructs every time you feel OOP is a 'firing mosquito with a cannon'.
Its an engineering decision. Like most engineering decisions it involves carefully balancing lots of different forces on the design. In this case its the design of the language. Different languages are intended to solve different problems and have different objectives. So its not surprising that different languages come to different conclusions.
It this case there are costs and benefits to having primitives.
Primitives can be faster.
Primitives can make it easer to do certain low level things (eg writing individual bits to a register on a micro condoler in an embedded system.)
On the other hand primitives can make your programming language more complicated as your primitive types have different syntax etc to operate on them. Some newer languages are trying to have there cake and eat it by using primitive types under the covers but making them look like objects in terms of syntax.

Linux Bioinformatics Tool [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I am looking to make a data visualization tool that will visualize biological data. I am used to being a C# and .net coder. However, as I understand it, you can run into trouble if you are running a C# app in ubuntu. Any suggestions for a language to use with these specifications in mind? I was thinking Java but am happy to take suggestions.
C# is a solid choice, especially if you already know the language. C# and the .NET framework have a solid cross-platform port with the Mono project and you can create Gnome UIs using the Gtk# bindings.
As an alternative, Java is used for a lot of bioinformatics applications. Though personally I have to say that most of those have horrible user interfaces and Java’s memory management seems ill-suited to deal with the data sizes that are common in bioinformatics – tools routinely run out of memory or become extremely slow. This isn’t necessarily an inherent problem of Java as much as sloppy programming, but Java certainly doesn’t help.
An alternative to Java would also be Python with a suitable GUI library (there are some good ones), especially since Python offers a much nicer, more polished syntax.
Yet another alternative that’s worthwhile especially if you’re really dealing with big data or if performance is important, would be C++ with Qt to build the GUI. Note that this will make development vastly more complicated if you’re not already proficient in C++.

Best/quickest way to learn Java for a seasoned .NET/C# and C++ developer [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What is the quickest/easiest way to learn Java for a seasoned .NET/C# (more than 7 years) and C++ (5years) developer.
When I say to learn Java - I mean being able to write applications in a "Java way" using base classes library + where needed using a popular Java libraries (it is great that so many of them are open source).
I know that Java development comes in a lot of flavors - enterprise applicatons (Java EE), mobile devices (Java ME), objects hosted in application servers (to my knowledge Java has a buch of these) - however at the moment I am interested in a general Java development - may be with a some emphasis on a integration projects/enterprise development.
So basically - I am a strong, passionate about technology, proud to be a senior C#/C++ developer with a dozen years of experience who wants to dedicate a month-worth (may be more) of evenings to learn to effectively program in Java environment.
Having said that I don't mean I am switching from .NET/C++ to Java - but I would probably have to spend 30%-50% of my development time developing/supporting/whateverstageintheSDLC in Java.
Thank you.
I suggest starting with The Java Language Specification. I don't think there is any quicker or more comprehensive way of gaining an understanding of the language for a seasoned programmer.
Followed by Java Collections Tutorial.
Followed by java.lang.* and java.util.* classes, interfaces and packages.
This will give a good basis for learning and understanding any other branch of Java as it becomes necessary.
I would take a completely different approach to reading books upfront. Simply download an IDE and get coding. The netbeans tutorials tend to get you up and running with a variety to technologies very quickly.
If you can code C# then you should have no problem getting something up and running.
Once you have some code up and running that is when you would then dig out the likes of effective Java.
Karl
Effective Java should be in every Java developer's bookshelf. It focuses not so much on performance as one might think from the title, but rather on how to program Java idiomatically, which becomes subtly different from following the idioms of C#.
Perhaps one of the best ways would be to get a copy of Bruce Eckel's Thinking in Java.
Much more than simply covering the syntax of the language, this book goes into the background - as the title says, "How to think in Java" so you can write pure Java code, not C# (or C++) code using Java Syntax.
I m only speaking for java web app development: i think its going to be quite similar to how you might've done it in C# using ASP.NET, except you don't get the visual drag and drop GUI creation using visual studio. The basic concepts are pretty much the same.
As for libraries, there are a million and one in java, and only time will help with those. But it'll help knowing the common ones, such as apache commons, google collections, spring, hibernate. It might help you get started if you start with something like Appfuse, which is a full java RAD web app framework that munges together all the above common frameworks.
On the build tools side, there are ant and maven as the major players. I prefer ant over maven personally.
Ordered list:
Thinking in Java;
Core Java, Volume II;
Spring reference;

Interview question on C# and VB.net similarities/differences [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have been a VB.net developer for a few years now but I am currently applying to a few companies that use C#. I have even been told that at least one of the companies doesn't want VB.net developers.
I have been looking online trying to find real differences between the two and have asked on crackoverflow. The only major differences are a few syntax difference which are trivial to me because I am also a Java developer.
What would be a good response to an interviewer when they tell me they are looking for a C# developer - or similar questions?
I've had to interview people for a few C# positions and this is my general advice for VB.Net developers interviewing for a C# position:
Make sure you are clear that you have been working VB.Net. This seems obvious but is something that apparently isn't (in my experience).
Try to give a code sample, if possible. I've seen some horrible VB.Net (and C#) written by VB programmers who didn't seem to learn much in the transition to .Net.
Be able to write in C# during the interview, if asked. I know there aren't many real differences between the two, but I don't want to pay you to learn the new syntax.
For your specific question: I've asked that type of question before and what I wanted to hear about was how the underlying system and framework were the same. If possible, talk about garbage collection, IDisposable, finalizers, the dangers of unsafe code blocks, stack vs heap, etc. All the kind of stuff to show that you really understand the intricacies of the .Net framework. Right or wrong, the heritage of VB brings with it an expectation of a lack of understand of lower level programming and windows in general (which, ironically enough, a c++ developer would have of a c# developer... and so on).
Lastly, how you frame your experience can make a world of difference. If you position yourself as a .Net developer, rather than VB.Net or C#, the stupid, pseudo-religious, banter may not enter the conversation. This of course requires that you actually know both VB.Net and C# at the time of the interview, but that's a good policy regardless.
The truth of the matter is that if you find that the person interviewing you writes you off simply because you've previously been developing in VB.Net, it's likely not going to be a place you want to work at anyway.
Some differences (that are more substantial than syntactical) that suitably catch me out sometimes:
VB.NET does not have anonymous delegates
Unsafe code blocks aren't in VB.NET
I love C# to death, but I envy VB.NET's optional parameters. Office automation in C# is so very, very painful.
I think the truth will-out on this:
I'm a software developer, the syntax of the language is the final part of the puzzle. By employing me, you're getting someone with demonstrable experience of problem solving and logic. I'm experienced with the .NET environment, the CLR and the associated Windows stack, including SQL and Windows server. I don't know the C# syntax, but, I am used to object-oriented approach, I will have no problem getting totally up to speed on the finer points of the syntax within a couple of weeks. You can see from these examples of my code that I'm an experienced developer, I assure you the transition will be seamless. I have already made a start learning the language, I haven't had any problems so far.
#DAC - VB now (in .net3.5) has support for lambdas:
Function(x) x.ToString()
In an interview I'd say that understanding the CLR and what the code's really doing is what's important, and that you're happy to code in either (assuming that you are).
I'm also a C# feller to the death but the differences are not just syntax. There are places where VB wins HANDS down
Optional parameters
Late binding
Working with COM from C# can be a very frustrating affair. (Which is not to say impossible!)
Truthfully? If you're a Java developer too, I'd lead with that. A Java developer with some experience in .NET will generally make a better impression than a VB developer with experience with Java. If you can answer questions on the difference between .NET and Java you should be in good shape.
I'd also recommend you learn the C# syntax ASAP. If you're experienced with VB and Java it won't take long.
A lot of developers have issues with VB and the people that use it. Valid or not you'll have to deal with that reality.
VB or C# both are syntax only diffrent but if you are applying way of logic is same.

Categories