For example, in Java there is Functional Java and Higher-Order Java. Both essentially give a small API for manipulating higher-order, curried functions, and perhaps a few new data types (tuples, immutable lists).
LanguageExt looks very promising for making functional style programming in C# easier.
https://github.com/louthy/language-ext
have you looked into F#?
Also a neat blog post would be here that talks about how to use the new generic / lambda expressions built into c# 3.0.
If you just add using System.Linq to the top of your source file there are a LOT of nice new functions added to working with collections such as folding / filtering / etc.
Assuming you can't use F# for whatever reason, and just want to use functional paradigms and idioms in your C# code to improve quality & reliability:
Functional style pattern matching for C#
Monad library for C#/.Net
There is also 'elevate' which has some functional things like option types (maybes) etc.
I think you want F#
Also, the more recent versions of C# have a lot of functional concepts included in the base langauge.
There may be such a library for C#, but you should probably consider just using F# http://research.microsoft.com/fsharp/fsharp.aspx and http://msdn.microsoft.com/en-us/fsharp/default.aspx.
Microsoft plans to make F# a first-class language in Visual Studio so there should be little risk in using one of the CTPs to build your initial stuff.
If you're looking for something that extends C# then no, but there is F# which is a .NET based functional language. From the "About F#" page:
F# is a typed functional programming language for the .NET Framework. It combines the succinctness, expressivity, and compositionality of typed functional programming with the runtime support, libraries, interoperability, tools and object model of .NET. F# stems from the ML family of languages and has a core language compatible with that of OCaml, though also draws from C# and Haskell. F# was designed from the ground up to be a first-class citizen on .NET, giving smooth interoperability with other .NET languages. For example, C# and F# can call each other directly. This means that F# has immediate access to all the .NET Framework APIs, including, for example, Windows Presentation Foundation and DirectX. Similarly, libraries developed in F# may be used from other .NET languages.
Since F# and OCaml share a similar core language, some OCaml libraries and applications can cross-compile either directly or with minor conditionally-compiled changes. This provides a path to cross-compile and/or port existing OCaml code to .NET, and also allows programmers to transfer skills between these languages. A major focus of the project has been to extend the reach of OCaml-like languages into arenas where they have not traditionally been used. Throughout the project the designers of F# are grateful for the support and encouragement of Xavier Leroy and others in the OCaml community.
Not a shrink-wrapped library per se, but Luca Bolognese of Microsoft has a series of blog posts where he builds a C# library for functional programming with types like tuples, records, type unions and so on:
Also Linq is basically a library for functional programming with syntactial support in C#.
Check out http://code.msdn.microsoft.com/FunctionalCSharp for some samples.
F#, there's a CTP release available from microsoft.
One more option to consider is FuncSharp. It's not so heavy as LanguageExt and it does cover the most important patterns/aspects.
Related
Most comparisons I can read on the internet are about the syntax whereas it doesn't matter much. I care more about advanced features. For example, I read on .NET about these features:
Partial Class .Net support not java java partial classes
Adaptive Control Behavior http://msdn.microsoft.com/en-us/library/67276kc5.aspx
Parallel Class http://msdn.microsoft.com/fr-fr/library/system.threading.tasks.parallel.aspx
Solver Foundation http://www.solverfoundation.com/
Reverse Enginiering with UML Sequence Diagram http://blogs.msdn.com/b/habibh/archive/2009/07/29/use-uml-sequence-diagrams-in-team-system-2010-to-reverse-engineer-your-code.aspx
MS-CAPI (Microsoft Crypto API) certified FIPS 140-1 compliant http://groovy.codehaus.org/Bridging+the+Gap+Between+Java+and+.NET+with+Groovy+and+Scriptom
These are features I would need for future projects maintenance. Currently we use Java and I can't really find any equivalence of them on java platform or can you point me towards them that are free and well integrated (not having to hack to make things work smoothly - like using another 3rd language to wrap calls - or pay 10000$ more to get the feature) ?
In terms of language "advanced" features and "power", I generally find: Java << C#3 (.NET) << Scala. (Although C#/CLR does have things not present in Scala.)
I'm not even sure why ASP.NET is in the title though. You also throw VS into the confusion. It's just a (popular ^^) C# IDE.
As far as "need"? Well, there are a million Java projects and libraries. They just don't always act the same way as the C#/CLR (or Scala) counterparts. It doesn't mean you can't do it in Java.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
I know it is a kind of broad question but any answer are appreciated.
All:
Require some form of runtime on your system (JVM/.net/Python runtime)
All can probably be compiled to executables without the runtime (this is iffy and situational, none of them are designed to work this way)
Are good languages
All have specific areas where they are much more appropriate than the other two
Java:
Tries very hard to be Cross Platform--generally succeeds
Little access to platform features that are not in the SDK
Slowest of the three to change and does not contain features common to the other two such as closures
Very backwards compatible (partly because of the previous point)
FAST (about 2x slower than C, quite a few x faster than python)
Probably has the most library support of the three
Strong multi-platform server systems already deployed using J2EE
Scales down to embedded (I've worked on 2 different embedded java projects--coming soon to a cable box near you)
Static
C#
Quicker to add new features
Windows only--Mono is cross platform but does not have the library support.
Started very similar to Java but has many more language features now.
Much better access to windows APIs
Not sure about speed--I think it's similar to Java.
Very good library support
The only one of the three that you have to pay for (it's free for "entry level")
Static
Python
Language is cross platform. Not sure about non-language platform access (such as drag-and-drop)--anyone know?
Probably an easier language to learn
The only one of the three that does not use c-like syntax
Slowest of the three, but still pretty darn fast compared to other dynamic languages.
Dynamic
This link is also interesting
Python is a dynamic language where Java and C# are really not. It is totally different than the other two. There are ways to accomplishing things in Python that do not translate well to the others and vice versa.
Java and C# look the same, but they have differences between the two under the sheets. Being an expert in one, does not make you an expert in the other by any stretch of the imagination. The syntax is similar and libraries are too, so it would be easier to get up to speed in one or the other, but there are subtleties that can trip you up.
C# and Java have almost identical syntax and very similar libraries. There are differences that you have to be aware of (Type Erasure in Java, for example).
Python is a completely different animal. It is a dynamic language (where the other two aren't). Python winds up being closer in style to something like Ruby.
Java and C# are statically typed languages, while Python is a dynamically typed language. That's a huge difference.
The syntax of Java and C# is similar (but I would not call it "almost identical" as Justin Niessner says).
Java and c# are pretty similar in terms of syntax and are mostly strongly typed (C# is getting more dynamic with every version), Python is a dynamic language
Java and C# are very similar and are syntactically similar to C/C++. They also use braces to mark code blocks.
Python is completely different. Although imperative like Java and C#, Python uses indentation to define blocks of code.
Java and C# are also compiled languages, whereas Python is interpreted and dynamic.
Python, Ruby, and Groovy are somewhat similar languages.
C# and Java are easy to move between, although I don't know many people who are experts in both. C#'s syntax is based off of Java, so they read very, very similarly. They both run cross-platform; Java on the JVM, C# on .NET or Mono. They're both OOP, and widely used for web development. I'd use whichever the team was more familiar with.
Python's off to the side there. It's also used frequently as a scripting language. It can use classes and object orientation, but isn't forced to. It's not as well supported for web work. I'd use this for a different set of tasks than C#/Java.
C# and Java are the two languages you listed that are most similar. Python has a very different syntax, and uses a slightly different programming model. Both C# and Java are Object Oriented languages at their core, with increasing nods to Dynamic Typing. Python began as a Dynamically Typed scripting language and has been picking up more and more Object Oriented features over the years.
The C# class library (.NET Framework) is theoretically multi-platform, though it's heavily weighted towards the Windows platform, and any other OS compatibility is largely an afterthought. The .NET framework currently has two "official" frameworks for building windowed applications (Windows Forms, and WPF) and two "official" frameworks for building web applications (ASP.NET, and ASP.NET MVC). Windows Forms is similar to Java Swing, but the other four frameworks are very different from much of what is found in the Java or Python worlds. There are many language features in C# that are different or lacking in Java, such as Delegates.
The Java class library is pretty solidly multi-platform. It's officially supported desktop and web frameworks (Swing and J2EE) are generally regarded as slow, and difficult to use. However, there is a very lively open source community which has built several competing frameworks that are very powerful and versatile. Java as a language is very slow to introduce new language features, though it is runtime-compatible with several other languages that run on the Java platform (Groovy, Jython, Scala, etc..). Java is the language which has has the most run-time optimizations put into it, so an application written in Java is almost certainly going to be faster than an application written in C# or Python.
Python is an interpreted language (in general), and is pretty solidly multi-platform. Python has no "official" desktop or web frameworks, though desktop applications can be written using GTK or Qt support, both of which are multi-platform. Django has become a de-facto standard for Python web development, and is regarded as a very powerful and expressive framework. Python is at this point fully Object Oriented, and is notable for it's powerful tools for working with collections/arrays/lists. As an interpreted language, Python will be significantly slower than either C# or Java.
Python was made to be simpler, more readable, flexible and object oriented than what existed before - i.e. Java, Perl etc. It's actually closer to Java than it is to Ruby. Ruby is more like Smalltalk. Think of Python as Java without the stuff that mostly gets in your way, makes things awkward to do, slows you down or clutters the essence of your logic. So no semi-colons, curly braces for scoping. No static variable declaration or variables at all really they're identifiers that point to objects instead.
There's also a standard style guide for Python unlike other languages. Indentation is used to indicate scope and inconsistent indentation is a syntax error.
It also includes some often used things built into the language: lists, dictionaries, sets, generators etc.
Java is nice for those familiar with C / C++ syntax and are set in their ways, like that syntax and find it readable. Ruby and Python are for those that preferred Pascal or Smalltalk to C, like Lisp etc.
They are not similar at ALL. They all take widely different approaches to OOP, syntax, and static/dynamic typing.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
C# has a good momentum at the moment. What are the features that you would need to have in order to switch (or return) to Java?
It would also be quite useful if people posted workarounds for these for the current Java versions, e.g. Nullables being wrapped around custom classes, to make this a much more interesting wiki.
As a .NET/C# developer here are the missing features that annoy me. This list in no particular order - just as thoughts come to mind:
The Java library is too small. For common things I have to choose between 5 competing open source products because the base library is lacking in so many ways.
This is an Object Oriented programming language right? Why in the heck do primitive types not inherit from "object"?
Pointers
Lambdas
Closures
Partial Classes and to a lesser extent partial Methods
Real support for Generics
Using statements and Dispose - this was a real WTF for me. You really have to explicitly close connections in try/catch blocks. Poor Java guys!
Yield return would be nice
Unsigned integers - again WTF? I have to use number types larger than I need for what purpose again?
In Java you can return from final blocks of try/catch. A co-worker confused the hell out of me for hours by introducing a bug this way. This behavior should be prohibited as in C#.
I rarely have to use Java and when I do, I have all sorts of WTF moments.
Edit: I Removed for-each comment based on the fact it is no longer a missing Java feature since 1.5.
In my experience, Java vs. .Net is more of a business decision than a technical one. Shops with MS experience trend towards .Net and shops with Java experience trend towards Java & OSS. I've seen little evidence of people switching based upon language features. On the other hand, I've seen shops heavily tilt towards one platform b/c of one or two key employees they wanted to hire being knowledgeable in that area.
in no particular order:
function pointers (delegates); the whole passing interfaces around thing is stupid
real generics; what's the point of having type safe generics if the compiler can't even hold the meta data through a unit's compilation?
ui speed; all the self-drawing ui libraries are very slow compared to native controls wrapped in "managed" libraries, not to mention that microsoft's self-drawn ui is hardware accelerated through direct3d
an yield return construct; c# is so user friendly in this it's crazy
operator overloading
linq; just cuz its so addicting
properties; more synctatic sugar you get addicted to
better interop with native code; c#'s p/invoke and native com support makes interop so easy compared to jni -.-
first class value types; this goes hand in hand with real generics, having generic lists that never box/unbox in c# is part of why c# is faster than java.
and i'd say this is the most important one:
a responsive, informative debugger; nothing can even come close to visual studio right now
Just going off the cuff, I think the biggest thing Java 7 needs that everyone is lamenting the lack of is closures.
I'm a C# programmer and about one year ago I had to participate in the development of an application in Java. What I missed the most was:
Visual Studio (Eclipse is nice, but
VS is VS, especially Team Edition)
Comparing strings with ==
Properties
Basic types as first-class objects
(e.g. not "int" type vs "Integer"
class)
Anonymous methods (a workaround can
be made by using anonymous classes
but it is not the same)
LINQ
And there was one single Java feature that I missed when I went back to C#: explicit exception declaration in method signatures.
DISCLAIMER: I am speaking about a somewhat old project, I don't know if some of these features are present in current versions of Java.
Less heinous XML parsing and manipulation tools. Doing anything with XML in Java sucks.
I'll also give one answer the other way around. C# needs an enumeration implementation like Java has. Java's enumerations rock!
Let me add anonymous overrides to this list also. Sorry to go off topic, but C# needs the ability to anonymously override methods. I have been switching back and forth between Java and C#, and I have to say for unit testing legacy code, there is nothing better than anonymous class overriding.
I would need function pointers of some sort. The ability to use delegates in C# is so useful. There are so many times in Java where I want to create a map of delegates or function pointers as the solution, but I can't. I know you can simulate a similar thing in Java, but having the abstraction as part of the language is a huge plus!
Momentum. I have done a lot of development on both platforms. I'm enjoying the .NET side more because of the way the C# language is evolving. Java's evolution seems to be more a reaction to C# than an actual vision. So I think the best thing for Java to do is ignore .NET and create something new of its own.
Another one I would like is some equivalent to LINQ. I noticed how much I actually depend on the ability to use LINQ when I tried to do a top coder competition and realized they only support .NET 2.0. Once you get used to using LINQ to solve problem and make it part of your regular programming vocabulary it is very difficult to not see problems in that light. It is akin to using generics and then not being able to use generic.
I think, choice between Java and C# is not a question of language features, but a question of platform and ecosystem choice.
So, I doubt that any new syntactic sugar in Java or C# can lead to a significant amount of switchers between the platforms.
After all, JVM world has Scala and many language-sensitive developers are using it in some way.
I think, you should consider swithcing this holywar from "Java vs C#" to "JVM vs CLR", because JVM is (in the last years — mostly) not only Java, but also Scala, Groovy, Clojure, JRuby, Jython, and dozen of JVM-languages.
Properties!
Anonymous objects are nice too
Continuations, like Scala (on top of the rest) would be good too, for agents development.
Support to run over CLR (and vice versa perhaps for JVM) without IKVM and other such layers.
Let's be clear that we need to distinguish between Java and the JVM. I actually switched from C# to Java, but I admit it was not because of Java's amazing language features! In my very humble opinion, C# is the better language, and CLR is the perhaps a more elegant VM. However, even with Mono, you're not writing applications that run everywhere!
I think the greatest argument for Java is the amazing community it has. This is where the cutting edge technology is being developed, not at Sun (now Oracle). The Java community has consistently been the leader in developing Enterprise technologies. For instance, how long did it take Microsoft to provide a DI Framework? Where's AOP in .NET? When I start a .NET project, my foundation is Spring.NET, a Java port. When I need ORM, it's NHibernate. Need a testing framework? NUnit. I realize there are other OSS projects for the .NET platform, but their numbers and support from Microsoft are laughable compared to the Java community.
on the other side, has .net got enterprise open projects like Terracotta (semi commerical), Infinispan, Compass ? no. ncache (commerical), lucene.net are far behind them. Especially Terracotta is unique, it can improve some of your app x100, it's simply perfect and free (partitioning is commerical). If we implement a high load app in both .net with anything and java with terracotta + hibernate + terracotta-hibernate-integration, java app will probably far more performant than .net one. Ther're some ports to .net like nhibernate, log4net, lucene.net, but all of them are trying to catch java versions. And entity framework is a disaster, they have to start with nhibernate as the base or get some lessons from them.
.net is only working on windows (mono is far from enterprise, there isn't any enterprises using it), how much money does myspace.com spent for their 4000 windows web server licences ? 1 million ?
You can't install a simple plugin to VS (and can't do some other things) if don't buy professional edition,
Some windows instance types in amazon web services are nearly x2 price of the linux ones.
if you look at ohloh.net open source java project counts (with language comparison tools), you'll see that java has x5 more volume than c#.
also Java has %20 share on worldwide while c# has %4.x (source:tiobe.com)
Look at the top web sites; only microsoft and myspace are using .net. google, amazon, ebay, linkedin, alibaba, twitter (switched to scala from rails)... many of them are using java and many others are using php, ruby (facebook, yahoo,..)
As a language Java is far behind c#, but Scala (runs on jvm) is as good as c# and it's performance is nearly same as java and also it can use all jdk and other java code as his library.
I'm not saying java is better, but I'm saying java is as valuable as .net, too.
A native 'decimal' type for Java replacing the BigDecimal class would be nice. But Java thread-safe collections are nice.
Perhaps the question is not so much what Java 7 needs to persuade developers to use it, but more a case of what makes developers want to move from Enterprise/server-side java language to a different C# desktop Windows-only oriented world?
For most developers, the language isn't difficult to pick up be it Java or C#. I develop in Java, but Linq didn't take long to understand and use.
I think the choice of Java or C# depends on what motivates you personally -perhaps money? in which case either language will do whether they have certain features or not.
Ste
They should start by fixing the Calendar/Date related classes, even that seems too much to ask.
A simple way to map values in your model to the UI (like bind in Java/FX)
I think it depends on bussiness decisions, not the languages themselves.
But I really really really love C# lambdas and curry :D :D
http://mikeomatic.net/?p=82
a map({codeblock}) which runs over anything iterable would be nice. And filter too. And being able to return multiple values easily from a method.
(a,b,c) = getThreeValues();
(would assign the individual variables a, b and c).
Actually I just think they should have Haskell as a supported scripting language on the JVM :D
linq, lambda, anonymous types
I don't see any point in "luring" anyone anywhere. They solve different problems and you should use whichever one suits you.
Java has less "Language" and less structures to trip up new people, it's platform independent and it doesn't change too fast allowing old code to stick around for a LONG time (Good for some large companies).
C# has tight desktop integration and a slew of nice features that make it more fun to program. It has .net integration. It has pointers, closures, etc which make it harder for n00bs (a valid language target, hence Basic) but more fun for experienced programmers--I haven't convinced myself that these features make you more productive, but in some situations they can make your code a lot nicer! Also if you need pointers, you need pointers.
I don't see a whole lot of overlap in target audiences. Why change a language to attract programmers when it's healthier for the entire industry to have two healthy languages each targeted at solving different problems attracting different developers?
Boo seems like a very cool language. Is it 100% C# compatible? I mean: can I use any C# DLL/class? Could I make use of the XNA framework?
As far as I know, Boo has an implementation on top of the .NET CLR - which implies that it should be able to both consume, and be consumed by C# code. The syntax may not always be pretty when consuming Boo from C# - but the opposite should be quite elegant, given Boo's syntax.
Also, all of the classes in the .NET BCL should be available to you in Boo.
Yes Boo is easily consumed by C# and vice versa. Most of the best features of Boo don't carry over to C#, such as syntactic macros, for obvious reasons, but you can create Macros in C# and consume them in Boo. Additionally Boo has the nice feature of being able to create Modules, which is something you can't do in C#.
They both can create extension methods. Boo has 'duck' typing while C# now has the "dynamic" keyword. While they're both functionally equivalent you might end up seeing the two merge eventually.
Boo currently has known issues with generics, but the feature will be completely supported once they are all ironed out. I suspect there will have to be some extra work done to support the new Co/Contra-variance features in .NET 4 as well.
It would be no different than using VB.NET with C#. Currently the only big different between the two (functionally) is Boo does not have pointers... but there are ways to handle that.
PS: Boo IS a wonderful language.
IIRC, any language which compiles into IL (Intermediate Language, .NET's version of Java's bytecode) can work with any other language which does the same. So you can mix C#, F#, ASP.NET, VB.NET, and if Boo does the same, you should be able to use with with C# as well.
I have a small experience in VB.net and I would like to learn C#.net
What are the differences between VB.net and C#.net?
Is there any difference in performance between these two?
Apart from the syntactical differences, are there any major changes that I have to keep in mind?
The Language Features section of the Wikipedia article offers a good overview. Performance is essentially equivalent in almost every aspect, from what I understand.
Performance is equivalent if you write equivalent code, but VB.NET has constructs that are in there for "backward compatibility" which should NEVER be used. C# doesn't have some of these things. I'm thinking specifically of:
Functions which are in the Microsoft.VisualBasic namespace which are members of other standard .NET classes like Trim(). The .NET classes are often faster.
Redim and Redim Preserve. Never to be used in .NET, but there they are in VB.
On Error ... instead of exceptions. Yuck!
Late binding (sometimes derisively called "Option Slow"). Not a good idea in a non-dynamic .NET language from a performance perspective.
VB is also missing things like automatic properties which makes it pretty undesirable for me. Not a performance issue, but worth keeping in mind.
I think you will find the answers to your question in this articles:
http://en.wikipedia.org/wiki/Comparison_of_C_sharp_and_Visual_Basic_.NET
and
Link
edit: Noldorin was faster :x
The first thing to know about learning C# is that it is not pronounced "C#.net", it is just C#. Microsoft tacked on ".NET" to VB, because there was a previous version of VB that didn't work on the .NET Framework. C# was created specifically with the .NET Framework in mind, so the ".net" is implied and unnecessary. Also as a side note putting "C#.NET" on your resume really tips off a knowledgeable manager to your skill level, or lack there of, regarding C#.
Also this Wikipedia article is really good for showing the pros and cons as well as the differences between C# and VB.NET at a high level.
Follow following links which give detailed differences
http://www.harding.edu/fmccown/vbnet_csharp_comparison.html
http://www.codeproject.com/KB/dotnet/vbnet_c__difference.aspx
http://support.microsoft.com/kb/308470
In spite of differences as mentioned at http://support.microsoft.com/kb/308470 both C# and VB.Net are first class citizens of .Net world
Although there are differences between
Visual Basic .NET and Visual C# .NET,
both are first-class programming
languages that are based on the
Microsoft .NET Framework, and they are
equally powerful. Visual Basic .NET is
a true object-oriented programming
language that includes new and
improved features such as inheritance,
polymorphism, interfaces, and
overloading. Both Visual Basic .NET
and Visual C# .NET use the common
language runtime. There are almost no
performance issues between Visual
Basic .NET and Visual C# .NET. Visual
C# .NET may have a few more "power"
features such as handling unmanaged
code, and Visual Basic .NET may be
skewed a little toward ease of use by
providing features such as late
binding. However, the differences
between Visual Basic .NET and Visual
C# .NET are very small compared to
what they were in earlier versions.
No matter which language you select based on your personal preference
and past experience, both languages are powerful developer tools and
first-class programming languages that share the common language
runtime in the .NET Framework.
Says by Microsoft
https://web.archive.org/web/20061027230435/http://support.microsoft.com/kb/308470