Examples where is Java more elegant than C#? [closed] - c#

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 14 years ago.
It's been a couple of years since I last worked with Java.
Can you tell me what problems can be solved more elegantly in Java?
I am aware of the following benefits of Java:
Java 'runs everywhere',
Java has support for units and
measures
(supposedly) better latency in Java
J2EE (I don't think there is an equivalent in .Net)
different approach to generics (with odd circular definitions such as "Enum>", see Ken Arnold)
What about generics - are there elegant Java examples that cannot be represented in C#? Or other APIs or libraries?
Thanks,
Jiří
P.S. some general links:
Wikipedia comparison article
Comparing Java and C# Generics -
Jonathan Pryor's web log

Java generics are very different to C# generics. And yes, there are places where that means it can be more elegant - usually in terms of wildcarding and variance. On the other hand, wildcarding is generally poorly understood (and I very definitely include myself in that camp) and the whole business of type erasure means that in general I far prefer .NET generics.
A rather different place where Java "wins" IMO is its enum support. C# enums are basically named numbers - Java is much more object oriented. A similar effect can be mostly achieved in C# using nested classes, but more framework support (an equivalent to EnumSet) and switch support would be welcome.
I also like the ability to restrict visibility to a package (namespace) in Java - although this is the only side of Java's access rules that I prefer to C#.
Having used both Java and C# pretty extensively for a number of years, my own feeling is that on the language level C# is far, far ahead of Java. Really, good cross-platform support and a large existing codebase are the only two significant advantages Java has over C# and .NET at this point.

What does "better latency" even mean in this context?
Other than that, I agree with Jon Skeet. On the whole, C# is lightyears ahead of Java. There are a few tricks in Java that are neat (enums for example), but they're very much the exception, not the rule.

Related

What is the difference between C#.Net and VB.Net (Except Syntax)? [closed]

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 10 years ago.
Please let me know the difference between C#.Net and VB.Net. I use C#.Net for my projects, but when ever I met with some other programmers they often called VB.Net more powerful and easy, than C#.Net. I always asked them "Why it is more powerful then C#, since it uses the same framework?" but still I didn't get any helpful answers.
Pointers (C#)
XML literals (VB.NET)
VB6 leftovers (VB.NET)
A few other syntax differences
In the end, not a whole lot. Although, some say C# programmers are better paid (never looked into it, but it's possible).
It also depends on your definition of 'powerful' and 'easy'. Both are powerful at their jobs. C# may have a slight advantage in terms of performance since it has pointers.. but they are rarely used in most cases.
Technically, there is no difference except the syntax. Both use the Common Language Runtime (wikipedia) (msdn). They are just two different languages that use the same libraries, and actually compile to the same thing. This is one of the reasons you can write a library in VB.net, compile it to a dll, and include that dll in a c# program.
There are some small differences, but for the most part, the choice of one over the other is almost entirely personal preference. Personally, I find the c# syntax to be less prone to errors, but some people like the "english-ness" of VB.
It's the same thing. I don't even know why Microsoft have C# and VB since it really does the same things.

Best place to learn C++ for a C# programmer [closed]

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.
I have been developing using c# now since the first release of .NET. I have never really spent time on C or C++ and thought it would be a good idea to get a little more awareness. Does anyone have any recommendations for sites that would provide a good learning/tutorial for someone that has c# experience to venture into C++ a little?
Thanks
Warning: C++ is not C and the following is related only with C++.
If you are already a c# developer I think you should work in three different directions:
1) copy semantic, memory management and const keyword, these are the main differences between c# and c++.
Make yourself familiar with copy constructor, destructor and assignment operator. Learn how to use RAII idiom.
Study the differences between passing a variable by: value, reference and pointer.
I will suggest Effective C++ http://www.amazon.com/Effective-Specific-Improve-Programs-Designs/dp/0321334876 also guru of the week it is a great source.
In More Effective C++ there is a nice chapter on the difference between pointer and reference.
2) you need to make yourself familiar with the standard library, in my opinion this is a really good book http://www.amazon.co.uk/Standard-Library-Tutorial-Reference/dp/0201379260/ref=sr_1_4?ie=UTF8&qid=1314957062&sr=8-4
3) the standard library is great but not enough, you will soon need boost.
I am reading this book at the moment http://www.amazon.co.uk/Beyond-Standard-Library-Introduction-Boost/dp/0321133544/ref=sr_1_1?ie=UTF8&qid=1314957541&sr=8-1
I haven't finished it yet, but it looks good so far.
Keep practise, you are going to love coding in c++.
You've already been given several good suggestions, but the wealth of information available on StackOverflow alone may be a bit overwhelming, so I'll give you a very specific bit of advice.
Rather than look for a tutorial on the web get a good book such as "C++ Primer" by Lippman, Lajoie & Moo. It is useful both as a tutorial and as a reference and is currently the most modern among the good, thorough books about C++.
This tutorial is good Teach Yourself C++ in 21 days.
21 Days is an overstatement by the way, you can breeze through that tutorial a lot faster, but it's comprehensive and easily understandable, and I recommend it.
Good luck!

Why were C# generics designed to behave so differently from C++ templates? [closed]

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.
I've already noticed that C# generics are quite different from C++ templates. I've read this question and answers to it and got a basic understanding of what the difference is.
However I don't get the reason for that design difference. I mean C++ was already quite developed when C# was being designed. What was suboptimal in C++ templates that C# developers did not clone C++ templates but instead rolled in generics that are so massively different?
What can generics do what C++ templates can't? In what are C# generics better than C++ templates? What's the reason for designing C# generics behaving differently from C++ templates?
The reason is that one ARE TEMPLATES the other are not. Sounds redundant? Partially because you ask a question oalong "why is a car different from a plane".
Templates are a very complex mechanism and most of the compelxity is rarely used. I think you don't really know what templates can do - only the 25% of C++ templates people use every day. This is the main problem - they are too comlpex. Hard for the compiler.
So Generics are supposed to capture a different approach for the most common use of templates, which is generic general types (no specialization, for example).
What can generics do what C++ templates can't?
Nothing.
What's the reason for designing C# generics behaving differently from C++ templates?
The fact that C++ generics are hardly mastered by anyone and a terrible thing to implement correctly for the compiler, while mostly going unused.
The main reason that it works completely different.
C++ templates are evaluated at compile time.
C# generics are evaluated at run time.
Besides, c++ templates are complicated. When developing C# they decided to reduce the complexity of the templates. Both for the users and for the run-time evaluation implementation.
What can generics do what C++ templates can't?
Generics have runtime information on instantiated types. This is useful for introspection (reflection) and appliances that use it;
Generics on C# 4.0 supports covariance and contravariance on interface and delegate types. So, as a little example, an IENumerable<Derived> can be used when an IEnumerable<Class> is requested, where Derived inherits from Class.

what is the difference in vb.net web apps and c# .net webapps [closed]

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.
can any one tell me the difference between vb.net web apps and c# .net webapps y most of the apps are done in c# rather than vb.net
There is no difference, they all compile down to the same CLR.
Nothing but preference. C# and VB.Net are extremely similar in nature as far as programming languages go.
Microsoft has said that both languages will co-evolve from now on. They will both get the same additional features with each new release, and MS is committed to both. There was a rumor that VB was going to be replaced by C#, but that is not true. They have dispelled that myth.
Because there are more coders that use c#, perhaps? Underlying philosophy of .net is that you can use language that you are most comfortable with, and stay in the same environment.
The only difference is the language that the code behind files are written in.
Both use the same objects and .NET framework, it's only a choice of programming language.
As for why most examples are in C#, more people prefer to use that.
From what I've heard, VB.NET was shoehorned into .NET as a late addition because too many programmers were familiar with it. Programmers tend to have their preferences with higher-level languages (which is by far the most distinct difference). In the end, they both provide virtually the same capability and functionality.

What's better, C# or java? [closed]

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.
Due to my future course in Computer Science, I'm now going to start learning Java.
I've been teaching myself C# and some C++ up until now, so I'm gonna switch to Java.
Just trying to think about what that'll involve, and any suggestions for sites that talk about the various comparisons between C# and Java for someone moving to Java?
Much of the fundamental logical operations and the class/object system work in the same way, and without the need for pointers or the need for more memory management, like in C++, which is great. The comparisons between the framework are the most important I think.
Also reckoning on switching to a Mac and running Java that way.
This from Wikipedia:
"Both C# and Java are designed from the ground up as object oriented languages using dynamic dispatch, with syntax similar to C++ (C++ in turn derives from C). Neither language is a superset of C or C++, however. Both mainly use garbage collection as a means of reclaiming memory resources, rather than explicit deallocation of memory (though C# requires explicit deallocation for graphical, GDI+ objects, in which case it uses the IDisposable interface). Both include thread synchronization mechanisms as part of their language syntax."
Here is a great article highlighting pros and cons of Java vs. C#:
http://www.veridicus.com/tummy/programming/java_vs_csharp.asp
And this one gives the syntactical differences for the same features:
http://www.harding.edu/fmccown/java_csharp_comparison.html
However, as a beginner, I think you will find that the languages are quite similar. C# may come in handy later, so rather than thinking of yourself as "moving" to Java, consider learning both.
I'm not sure this can be answered. There are plenty of arguments back and forth over which is better around the place.
They both have their advantages and disadvantages, but it really comes down to your situation and personal preferences.

Categories

Resources