Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Is learning C# as a first language a mistake? (programmers.stackexchange.com)
29 points by yitchelle on Nov 28, 2013 | hide | past | favorite | 48 comments


I only recently started using C# (Mono) about a year ago due to Unity, and I have to say that I've been pleasantly surprised. I think it is a much better functional programming language than JavaScript (thanks to the combination of types, a saner lambda syntax, and generators) and ObjC (obviously, and the GC makes ARC seem absurd), the two languages I would say I'm an "expert" in and would have previously considered my "favorites". I couldn't believe that I was actually looking into how I could host a C# server for our backend (I ended up settling on node just because heroku is so easy to get up and running).

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.


A lot of people recommend C because it presents an abstraction very close to the hardware. This is useful but in today's world, it isn't really a substitute for actually learning how hardware works.

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...


I think learning assembler, even (or maybe best) on an emulator of something simple like a Motorola 6809 will make working in C much more intuitive. You don't have to become an expert or build anything too comples. Just learn and understand the fundamentals. If you do, you'll have a lot less trouble with the things that confound many beginning C programmers, like the difference between foo, *foo, and &foo.


Well said, C is not a good model of modern hardware! Memory models, vectorization, and all those fun things aren't easily exposed/understood via C (at least not without lots of compiler intrinsics ).


You can do OpenCL in C, that's pretty bare metal in some areas.


As someone on SO pointed out, the most important thing is to not be dogmatic about "your language". You can start out on C#, Pascal or Erlang, but don't be closed off to looking at or building toy projects in other languages. Especially if they feel weird or difficult, it probably means you need to look at the problem a different way. Learning new ways to solve the same problem is useful for a programmer, and it keeps your brain engaged.


C# was my first language. I call it "home" because it's an awesome language that ships with an awesome framework.

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


I learned C# using csc.exe and wrote my code in Emacs.

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.


> mainstream .NET and C# community didn't really "get" Open Source

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.


There is a lot of depth to C# that most of the .net developers I've met have never seen (and even when they've seen it, they do not fully understand).

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.


Why is no one mentioning the job market for C# developers? I love lots of languages, but what pays my bills is a day to day C# 9-5 Senior Dev job. It leaves me with the financial stability to play around with ideas in other languages at home, without having to fight for a relatively small job market comparatively.

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?


This is a pretty important note. Especially on the east coast, C# is by far the easiest language to jumpstart a career in for young devs, and is a very safe bet for veterans as well. Java jobs are practically non-existent in many mid size east coast cities. I am now 100% node.js and python, but I probably would not have made it in the door if it was not for C# when I was starting out. The job market heavily favors devs, and the tooling makes it possible for self taught people to gloss over the fundamentals until they have enough time to go back and learn them. Also, if you think Stackoverflow is useful as a dynamic language dev, you would not believe how much more useful it is as a C# dev. I have no idea why, but SO seems to heavily favor C# over everything else. This is not to say that other languages get no love over there, but John Skeet alone has probably answered more obscure C# questions than all the other languages combined. I am only being half hyperbolic here.


C# is in high demand in many cities around the country.


C# is great. But it really doesn't matter what you learn as your first language. Programming is a craft. You're expected to keep yourself up to date. You're expected to read-up on new techniques, and all the goings-on outside of your day job programming language. You're expected to perfect your craft.


I wouldn't do it, for the simple reason that it is, for all practical purposes, a vendor-specific language. There is plenty to be said for the idea that the concepts of programming translate into all languages. But that's an academic perspective. From the perspective of having employment flexibility, I'd be looking for a language that didn't lock you in to one specific platform, as big as that platform may be.


I'm going to be a bit nit-picky, but C# isn't a vendor-specific language. There is also the mono implementation which is very very good, and doesn't lag too far behind the .NET implementation. Xamarin is a decent example of writing C# and targeting multiple platforms.

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.


Is learning french as a first language a mistake?


No... unless you happen to pick Spanish as your second, Italian as your third, and then go around trying to shoehorn Japanese, Swahili or Finish into your (unknowingly) narrow definition of what a language should look like.


pretty accurate...


For me, C# / .NET / Visual Studio / Resharper is the most productive general purpose development environment I've encountered. I've made a number of very serious efforts to move away from it (to diversify knowledge / due to it's image problems), but always come back because my productivity is just so high.

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 have been thinking about a similar question. What is the best way to learn a language? Or how does one equip oneself to pick up any language to start coding up the basic tasks[ignoring the intricacies the language provides]. Does learning one kind of a language help with learning other languages?

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've been thinking about this too. It appeals to me to start off with something like Scheme, then learn asm and C to understand how machines work (at least conceptually). That way the basis of proper functions and computing is in your mind, and you're not overcome with the hardware details first. OTOH, I look at my own path, starting on BASIC, C, ASP and then onto assembly and functional - and I wonder if it would have been easy for me to start off where I currently am. As an "expert" now, is my viewpoint so warped that I mistakenly think that old-me would have immediately picked up ML and functional concepts?


Going from Scheme to asm and then on to C would take a lot of personal dedication into learning how computers work. Much of the interest to learn programming is to make something cool. I made a small game in Delphi when I was younger. I toyed with Basic to ensure that my gorilla's bananas would always destroy the computer's gorilla. It was basic, simple and I learned a lot of new concepts. I'm sure you did the same thing.

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."


I'm going to go against the grain here and argue that yes, it's a mistake.

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.


  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.


Will novice programmers be using pseudo-functional bits and running parallel tasks? IIRC we're talking about someone's first language, i.e. they're at the hello world stage.

I don't see that person running parallelization schemes in their first 3 years.


They will be exposed to higher-order functions very early on, as LINQ is one of the most popular features. You get early exposure to lambdas, functions as parameters, generators, and probably closures.

These are valuable concepts to be exposed to, and IMO provide an advantage over learning Java.


> 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

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.


Really?

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.


Well, there is RoboVM, and Java (or derivatives) run on just about everything wether it be you sim card or credit card to high end clusters.


Same with C# http://www.adafruit.com/products/336

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)


In practical sense .NET does not exist outside of Microsoft world. Most of those who mention Mon have never used it (or non-MS environments for that matter). Don't waste time on "Microsoft-Java". Either learn Java, or better yet start with Python.


Calling C# "Microsoft-Java" is about as accurate as calling Go "Google-C".


The differences aren't so minor. I could write a list, but someone has already done that: http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java


That is a huge list that makes C# look amazingly better than java. Was this sarcastic?


I have had my share of Linux, windows, and OS X. Currently I use OS X for the majority of my daily tasks but I am not dogmatic about it. I like all of them and think they are all good in their own ways. Right now the scale tips a bit to OS X but it could go any way.

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

That's absolutely not true, and everybody that has programmed in both languages know that's not true.


To me, any language with a well defined semantics, consistent syntax, understandable error messages, strong (preferably static) typing is a good choice to learn programming. Also, it's important that you don't need to introduce many concepts to do simple things, which is typically the case with C# or Java.

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.


A friend told me recently that they liked Python because it was an easy language to start a project with, but they loved OCaml because it was an easy language to finish a project with.

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!


I started with C++ 6 years ago. 3 years ago, my religious view on C++ ended and i finally realized, that C++ is not enough. I saw Java, Lisp, Prolog, C# and others but got stuck in Haskell, because Haskell is the way, i want to write programs.

Independent to a language, i recommend to start without a IDE. C# and Visual Studio is in this case a bad combination.


I started with Python, then Lisp, then I had my first job working with C#. I honestly don't think C# would make one iota of sense to me if I did not have any background in programming.

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?


Yes, unless there's a paid development position at the end of the course. ;-) But seriously, your first programming language should be one where there are numerous entry-level programming jobs in companies where you live. Network, network, network!


Some of the better CS schools (used to?) start freshmen with Scheme. Not sure if they assume its a "first" language but for at least some of them it is.


Berkeley's CS department starts with Scheme.


As does WPI. Good move, imo, starting with functional programming Just Makes Sense


I don't think there is such thing as a bad choice for a first language, barring obscene languages like Brainfuck.


No, unless you want to shut yourself out of non-Miscrosoft ecosystem. Considering that learning a language is a long term investment and MS's star is waning, it's probably not a good idea.


If only C# programming skills (and programming skills in general) were transferable to other languages. Oh wait.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: