tags:

views:

1135

answers:

10

I'm looking for a new language to learn after C++, Java, obj C, HTML, css, and js. I originally was going to try C# but a bunch of people say its really slow because its a high level language. So why would anybody use C#? Isn't C++ much faster? Does it make development easier, but just have a slower final product? Also, what can C# be used for? You use it with a lot of .NET stuff on windows, and with ASP.NET, but what are other situations where one would use C#? Will there be a lot of job opportunities for it?

EDIT: I'm sorry for this noobish extremely broad question; I was unfortunate enough have barely been familiar with C# or stackoverflow before asking this. Of course, now I'm a guru at everything,,,

(for those who like happy endings: I really love C# now, it's beautiful, has an awesome future, and I'm considering making it my primary language. </happy-ending></upvote-whore-move>) :D

+26  A: 

Code written in assembly can be blazingly fast. Why not just write in assembly?

Don't believe everything you hear. C# has been plenty fast for all my projects. Typically, performance is more a factor of design than raw platform performance.

spoulson
No way, that's too slow! Build everything in hardware! ;)
JP Alioto
@JP lol .
Greg B
no man, punch cards is the way of the future :-)
SQLMenace
On the side, I do all my computing in Rube Goldberg machines.
spoulson
I write everything in F# and it gets compiled down suitable for Parallel FPGAs, so it's essentially built in hardware :) (meant as a joke. I don't do that)
Mehrdad Afshari
+41  A: 

Who exactly is this "bunch of people"? What are they comparing it against?

For the vast majority of things, C++ is not "much faster" than C#. It certainly has benefits in various situations, particularly where you want more deterministic memory handling, but in my experience the bottleneck in most applications isn't in places where C++ would help. As spoulson says, a lot of performance is in the design instead of the exact implementation - and there, it helps to be able to try different designs easily.

Why would we use C# when it's a bit slower than C++? Because it's generally reckoned (i.e. some disagree :) to be a lot easier to develop in without shooting yourself in the foot.

As for what C# can be used for... what do you want to use it for? Unless you want to develop drivers and kernels, it may well be fine for you. (Even OS development has some folks using C#...)

Job opportunities? Loads.

Downsides? Well, .NET itself is only available on Microsoft platforms. There's Mono, but it doesn't have quite the same degree of portability as Java (no doubt another "slow" language according to the same bunch of people).

Jon Skeet
I've also read some cases where C# can out-perform C++ in computation speed due to runtime optimizations done by .NET.
Will Eddins
Well, Java *is* slow. Eclipse is the biggest (fattest?) testament/witness to that!!
hasen j
You should add security to this list, buffer overflows are the biggest risk, that is how Mac/Linux and Windows boxes get compromised..immutable strings are a great thing
SQLMenace
Case in point by Guard: .NET's JIT compilation of MSIL is optimized for the installed platform. When compiling C++, it's optimized only for minimum requirements.
spoulson
@hasen j serverside Java is not slow, the GUI part (Swing etc) is what could be improved
SQLMenace
I'm not sure Jon Skeet should be allowed to post anymore, he's hogging all the Rep (good answer BTW)
Greg B
@SQLMenace: Immutable vs. non-immutable strings have nothing to do with buffer overflows. Managed access to memory, on the other hand...
Derrick Turk
A: 

C# is not always slower - in many cases, it can perform just as well as any language you listed. Usually the algorithm has more to do with the speed than the choice of language.

However, C# is very expressive, and has a great base class library to work with, and super-fast compilation. This means that it's very easy to work with, and can allow you to be much more productive than many other languages, especially C++. For example, I just had a small project that I would have budgeted 1 man-week for in C++, and we finished it up in less than a day in C#, mainly because the base class libraries simplified so many of the tasks.

Reed Copsey
+14  A: 

I'd have to say the people you were talking to simply don't know what they're talking about. Plain and simple.

Many enterprise level applications are built on top of C# and other .Net languages. There is nothing inherently slow about them. Yes the tend to have slower startup times but that's pretty much where it ends.

I noticed you mentioned Java in the list of languages. If you're comfortable with the speed of Java, C# will not present any issues. Generally speaking C# performs at least as well as Java on many different types of bench marks.

JaredPar
+3  A: 

Why should it be slow ? Indeed, C# is compiled to 'Intermediate Language', which is JIT'ed at runtime, but this can give you a performance advantage, since the runtime can generate the most optimized for the platform the code is running on ...

Depending on the application that you want to write, the 'speed' of the language will have a minor impact. The performance of your application will mostly be determined by the way you design your application, if you make good uses of the tools / technologies you use , etc ... Sure, C# is not a silver bullet, and there are projects where you shouldn't use it, simply because it is not the right tool for the job, but it will do just fine for most of the business / enterprise app's.

Frederik Gheysels
+11  A: 

My last company was founded by 5 C++ veterans with 15+ years experience each. They spent over a month building a certain Windows service. One of them found and dabbled in C#. Within a week he'd gotten further than the collective had in their month. Shortly after, they all switched to C#.

Why C# if it may perform slower: what price do you put on that degree of rapid development?

Dinah
A: 

one big reason to use C# over C++.........look at all those buffer overflow problems that C++ has where people take over your machine because they inject executable code in your strings or memory leaks....garbage collector is quite handy IMHO

SQLMenace
A: 

Even if C++ is faster to run, the difference isn't big on today's computers. That's why on mobile devices where cpu and memory are rather limited, C/C++ is still widely used.

But think about development times instead. If it takes 2 months using C++ and 1 month using C#, which would you go for? And when big modifications/refactoring need to be done, a higher level language makes it significantly faster and easier!

Lauri Larjo
Java, which is no faster than C#, is often used on mobile phones.
Dinah
+4  A: 

I haven't found many instances where C# isn't a good choice of languages, and .Net (or Mono) isn't a decent platform. Notable exceptions being kernel level development, or drivers. There are plenty of areas where low level, and raw performance is needed. For most, if no all business, or Enterprise applications C# is one of the better choices for development. It's well supported, works with many other systems, libraries, communications channels and components already available not to mention being a fairly nice language (esp. 3.5) to work with.

ASP.Net wasn't a bad platform, I generally find the object/control stack to be one of the short comings for complex interactions. I think ASP.Net MVC fits better for more scalable web based applications. Just the same, it's better than many other systems I've worked with in the past.

In terms of service layers, and even GUI development it's pretty nice. I've got a lot more experience in web based applications, and service/communications/business layers than with desktop GUI applications, so can't comment much there. I feel a lot of GUI development is more about the IDE/Toolkit, than the particular language.

As to slow, you specifically list Java, in most instances, C#/.Net is as fast or faster than Java. IMHO development specifically goes smoother with C# (Visual Studio) over Java (Eclipse). For web-based apps, I like ASP.Net MVC (and even ASP.Net) over Swing. That's just me though.

Tracker1
+2  A: 

The people you talked to don't know what they are talking about. C# is a very similar language to Java, all told; it has most of the same benefits and drawbacks. The way it all works is pretty similar (Java/C# is compiled into an intermediate language/bytecode that is interpreted or JIT compiled to native code, with various similar optimizations that you don't need to worry about as a programmer). It's used in a lot of the same situations as Java, and is really aimed for the same market. It's moving a lot faster and bringing in a lot of innovation as a language, but it's (in practice) pretty much Windows-only, if that's a concern of yours. The job market is similar. Both are very popular languages.

As for a language to learn, I would suggest something DIFFERENT. You say you know C++ and Java; C# shouldn't be hard to pick up. Potential employers will know this. Try Scala or Python. Both will give you some new perspectives on things (C# not so much), and make you a better programmer by teaching you new ways to think, rather than just adding another tool to your box.

Adam Jaskiewicz