Is learning C# as a first language a mistake?
programmers.stackexchange.com
programmers.stackexchange.com
For some context, I use SubEthaEdit, and thus have no auto-complete or fancy IDE features, so my opinion is purely language based. With all three of these languages, my "style" more or less ends up turning them into the language I want to program in anyways (no subclassing, shying away from mutability, etc.). All in all this fits my long held belief that the worst programming language is whichever one you are currently using.
On modern machines, C doesn't even expose some of the more important issues related to hardware. I am referring to things like the memory consistency model, cache coherence, different abstractions for multiprogramming and how they are implemented in hardware - GPUs vs. shared memory MIMD vs. MPI vs. clusters running MapReduce and so on. I'm not saying these programming models can't be implemented in C. I'm pointing out that learning C won't automatically teach you about the tradeoffs between message passing and shared memory systems. You still have to go out and learn that stuff. I'd argue that in today's world this is about as important as learning what malloc and free are doing under the hood.
Fred Brook's notion of classifying the complexity of programmable systems into essential and accidental complexity is useful here [1]. No matter what language you start with, you'll need to learn to deal with the essential complexity of software systems. In that regard C# is as good as language as any other. In fact, it might even be better than C because you get to focus a little more on the essential complexity because it is a higher-level language than C.
I think the advice of learning C first came in an era when hardware abstractions were simpler and so simply learning C would go a long way towards helping you understand how your computer really worked and thus in one sense helping you cope with the accidental complexity of software. But I think that advice might need to re-thought now because both the hardware and the software systems we build and use today are so much more complex. Just learning C alone might not get you very far in terms of understanding what really happens on your machine when, say, your webbrowser is making a HTTPS request to google.com.
[1] http://faculty.salisbury.edu/~xswang/Research/Papers/SERelat...
13 years later I only have a few regrets.
1. Microsoft tools are very very clever and very very good. You could become dependent on them. You could think you need them to be good at your craft. You could also be tricked into thinking that intellisense & autocompletion are key to your programming productivity.
I agree with what some folks here and on Stack Exchange say... Broaden your horizons and try a couple of languages/development environments. Perhaps learn Objective-C, Ruby, Node.js or Python at the same time. You could discover that programming is little to do with the IDE.
2. Reusing other peoples code is a good thing. The Open Source community means you can reuse 1,000,000's of man-hours of work for free. And also contribute your own stuff back to others. Last time I looked, the mainstream .NET and C# community didn't really "get" Open Source. And in turn they didn't really get "reuse", so we missed the benefits of open source.
T
The book Microsoft .NET for Programmers is a great (if somewhat dated, today) intro to C# and .NET for people who already have some programming background. It doesn't assume you are using Visual Studio so you get to skip all the smoke and mirrors that adds and just focus on C# and the .NET framework.
I don't think it's that they don't "get" it....for those who are aware of its existence, I'd suspect it's moreso that they just don't "do" it (for whatever reason), and for others it's simply that they don't care. You can not care about it and you can go on to have a successful career and be an accomplished programmer. The same programmer would be even better if they did embrace the open source community, but not everyone aspires to be in the top x% of programmers.
The .net framework comes with tons of classes built-in that can be arranged to do most anything that you've seen elsewhere with very little work; so it's understandable that with so much done for you beginning and intermediate programmers might skip learning how to build components from scratch, how to optimize, and how to create complex algorithms that solve novel business needs; however understanding of these topics is expected of senior developers everywhere I have worked.
I can see the point in suggesting one doesn't start with c#. I can also see the need for books that give you a proper ground-up understanding of what's going on. C# 5 Unleashed is an excellent example.
I don't think learning C# immediately is a mistake, but I do think it gives you an easy excuse not to learn the fundamentals that should be very important to you. It's up to you as to whether or not you skip important bits and risk your career; but it will catch up to you someday.
REALLY learning C#, understanding what happens when you drag and drop the aforementioned gridviews and sqldatasource objects onto pages, is also super important, but I do wonder what percentage of other platform developers really know what's going on in framework calls they use?
That said, there are better languages for cross-platform development, but that might not be a concern for a large number of companies and people.
Locking yourself into a single language is the wrong thing to do regardless, and is what most of the answers in the link suggest.
For operations, I don't like Windows - Linux is far superior for scripting, how-to information more widely available, it's open source, cheaper etc. So I tend to always deploy using mono. There are incompatibilities, but I have found them to be relatively minor based on my experience working on some very large systems.
I started learning programming with C and little bit of C++, before I started working on real life projects in Java and C#. Since then, I have dabbled in Python, ML, Racket and more recently Clojure. So what did I learn from all this? It is best to learn any language by learning the concepts or the \ how the language implements/solves that concept.
For example, teaching the general concept of "environment" some declaration resides in helps understand any languages "scoping" behavior more easily.
So, the bottom line is teaching any language by way of 'programming language concepts' and just using the language to realize those concepts would go a long way.
I wish I learned asm and C when I was younger but honestly, I don't think I would have stuck it out. So while my first thought right now would to say "learn C as it will help you understand many other programming languages," my honest advice would be to "make something in any language you want, just have fun."
An awful lot of novice programmers take years to progress from their "mother tongue" to their 2nd and 3rd languages, if they even progress at all.
I think marrying yourself to a proprietary language like C# is a mistake, not because of any particular C# language feature, but because it's yet another product of Microsoft's extreme case of Not-Invented-Here Syndrome (see for example netbios, active directory, etc etc etc). They have a compulsion to create proprietary, non-compatible versions of things that already exist, and you'll be handicapped if you only know C# and ever need to work on Not-Windows.
C# is basically Java with some minor differences (differences that will be immaterial to the novice) and Java has a far better degree of platform-agnosticism and would be a far better choice for a first language than C#, IMHO.
Linux, Windows, Mac, Android, iOS.
Considering that Java won't run on iOS (nor can you deploy java apps to the app store), I'd say C# is far more platform agnostic.
To be honest though anything non-x86/ARM is pretty esoteric these days, and realistically if you're going embedded C is a far better bet than anything else. (except maybe forth)
I have programmed in all three environments professionally and I know many different programming languages at least well enough to build a basic GUI.
I say that to preface what I am about to say... Java is not the worst language I have used but it's up there. I was a professional c# programmer back when it was in its 1.1 days and now I have revisited it for another professional project and it has improved to the point where I wish it was native on the Mac and on Linux without mono. It's what c++ should have been.
Edit... I have used java quite a bit and it's a terrible language.
C# is basically Java with some minor differences
Just about everyone I see saying this stopped seriously following or working with C# back at 2.0 or earlier. The changes since then have produced a very different beast than Java. Whether it has origins in NIH syndrome is entirely besides the point - MS was bolder with the language and the framework than Java's sluggish committees, and at the end of the day has built the better mousetrap.IMO any novice who isn't Windows phobic would be better off learning it than Java, in part because it will expose them to a wider range of language constructs and capabilities (pseudo-functional bits, task parallel stuff, etc).
That said, a total novice would probably be better off dabbling in a dynamic language like Python than taking on either Java or C#. Nothing like a REPL for getting your feet wet.
I don't see that person running parallelization schemes in their first 3 years.
These are valuable concepts to be exposed to, and IMO provide an advantage over learning Java.
That's really inaccurate. Mono aside, C# came up with quite a few innovations of its own, and I'm saying as a 15 year veteran Java developer who would love to see some of these be added to Java (at least we're getting closures next year).
Also, learning C# will teach you a lot of constructs and concepts that will be readily available in other languages such as Java, Kotlin, Ceylon or Scala (and to some extent, even Haskell).
The "proprietary, NIH, blah blah I hate Microsoft" nonsense belongs on slashdot, not here.
That's absolutely not true, and everybody that has programmed in both languages know that's not true.
For instance, consider Hello World in C#:
public class Hello { public static void Main() { System.Console.WriteLine("Hello, World!"); } }
you have either to explain several difficult concepts or tell the students that there are some magical things going there that they'll understand later. To me, it's not really satisfying. In the end, it will work, but with extra confusion and risk of losing some students along the way.
compare this with "hello world" in ocaml: print_string "hello world"
I'd much prefer to teach programming to a newbie in ocaml, python or pascal, rather than C#, Java, C++ or C.
My point? The best language to learn first is the one you are most likely to be able to finish a project with, and the best approach to figure out which is which is to start learning whichever one seems like the right one. If you're wrong, the good news is it's much easier to learn a second language, and a third, forth, etc.
I started with pascal, and it was the incorrect choice. I'm still not sure what the correct choice would have been, but from here it looks like lisp/small talk, neither of which I have bothered to learn yet. Go figure!
Independent to a language, i recommend to start without a IDE. C# and Visual Studio is in this case a bad combination.
I think that there is something be said about learning the value of all the libraries and working at a high-level view when your aim is production, but for learning, peeling away all the abstractions and forcing yourself to learn the fundamentals first is more important, with a much larger payoff once you are exposed to working with higher-level concepts. The dichotomy is that being productive is somewhat at odds with learning the fundamentals, but being productive in C# requires some intuition and knowledge about when to use a tool as much, if not more so, than how to use a tool.
I think that the entire .Net ecosystem is a terrible place to start. The first reason is Visual Studio. There is immense value in learning how to compile a program, using real REPL, learning how to design your file tree, and many other issues. I also think that a language that basically requires you to use code-completion is bad for your discipline as a programmer and doesn't enforce one of the major tenets of LCTHW, which is that typing and accuracy are highly valuable skills and depending on code-completion is akin to doing copy-pasting. Typing forces you to consider the "why" of your actions.
I also think that C# is generally much slower to develop on because far more verbose than other languages. It is better, IMO, to just focus on the problem at hand. Having a program that is 3x longer than Python can't be good for a beginner. Too much to focus on. Just get to the point and focus on it.
There aren't many learning resources about C# and using it for programming fundamentals. The advice can often be highly confusing and at odds with what you are ultimately attempting to accomplish. There is something to be said abound step-by-step and simple and straight-forward when you are just starting out.
I think C# is fine as a second or third language to learn. The reason is that there are many wonderful ideas and concepts in there, but they won't make a whole lotta sense without something to refer to in your own mind.
I hope the above isn't interpreted as a bash of the language or .Net as I believe that C# is a beautiful language with some amazing concepts. With that said, I'm sick and tired of seeing slow sites with the .aspx extension. If people with years of experience get bogged down in the complexity of the framework, what will happen to our beginner?