When it comes to recommending a language for a complete beginner to start with, the field is usually narrowed to C# and Python. Forget the details of why other languages are rejected; that's not relevant to this post. This journal entry is about something that's been bothering me for a very long time. A beginner should start with C# or Python. But which one?
The fact of the matter is that I have deep seated reservations about both languages and I don't have a strong recommendation for either. I tend to side with C#, but I'm reluctant to do it and I won't actively disagree or object to Python as a suggestion. So I decided to voice some of my concerns with the whole matter. I'm fairly interested in how all of you feel about this, so please comment if you've got anything to say in favor of either language or just in general.
C#'s an absolutely beautiful language. It's not perfect, but it's as close as I've ever seen. It really takes a lot of lessons from Java and Delphi, and working in it is a pleasant experience. Massive support from Microsoft, combined with the fact that a lot of people know and love C#, means that any time you run into problems, you've got a lot of places to go for help. And the .NET Framework supports almost any type of development, from applications to web development to Windows services and everything in between. For the most part it's blazing fast, especially if you know what you're doing. The biggest advantage of all, though, is that anyone can get the Express Edition IDE for free, and work in what amounts to the foremost professional grade development environment in the world. Combined with XNA, it's a great way to make games.
Python's a great language in a lot of ways. It's developed a fairly active community that has produced a lot of good information and libraries. Since it's been used heavily in the commercial sector, it's a mature language that is known to be usable for real life work. Learning the basics is a rather simple task, though it includes plenty of advanced functionality. Many people have learned from Python, and many people use it to great effect. There's even a completely free book online called Dive Into Python that you can use to learn. And the presence of an REPL makes experimenting with Python coding very easy. When you're reading to do games, you can move smoothly into PyGame and hit the ground running.
Both languages seem great, because they are great. So the question is, why do I have such serious misgivings about letting beginners loose in either?
C# throws a lot of information at a beginner. Consider what a beginner will typically deal with in C#:
public static void Main(string args)
Console.WriteLine( "Woot!" );
That is a lot of things going on for someone who's never seen coding. That snip has 7 reserved keywords in it, and a number of them are somewhat difficult to explain. And asking a newbie to simply ignore bits of the code as magic really bothers me. They did it to me when I learned C++, and I used things like using namespace std; blindly for months. And once you start getting involved with WinForms, or really any part of the Framework, things get much more noisy and complex. Everything is great once you get over that hill and are basically familiar with the principles at play (classes mainly), but in the meantime, C# code is a confusing mix of simple statements and total nonsense.
So maybe you're thinking at this point, Python doesn't suffer that problem. The equivalent Python program is a single line:
Nothing more. The use of "print" is historic and maybe a little strange to someone new to coding, but it's a minor detail and other than that, this code is dead simple. There are a few different problems with Python though. First, although having an REPL is nice, you don't write regular code in that thing, and the actual Python IDEs suck very badly. The end result is that developing an application purely in Python can be kind of a pain, unless you're particularly fond of the Emacs or Vim environments. Second, the Python syntax is completely foreign from anything else. It won't help you understand Java, C#, or C++, which means that learning those languages eventually will involve a bit more work.
However, my deepest reservation with Python is the type system, which is dynamic typed and duck typed. I feel that the biggest pain in programming is learning that computers deal with very strict rules, and I tend to think it's better to start from more rules and then eventually relax some of them. That way, since you're more used to the restrictive rules, you tend not to outright abuse the relaxed rules. For example, arbitrarily changing the type of a variable and using it for some other purpose than when you started really bothers me. Python and most dynamic languages take the line that variable types are locked, and you're simply redirecting the name assigned to a variable. I don't buy that. While it's technically and theoretically accurate, it's a completely worthless perspective to take in terms of actually coding software. All it does in reality is confuse people about what a given variable is being used for. In general, Python is very, very lax about rules, and that tends to result in some rather grievous code being turned out by people who mainly learned to code in Python.
So at the end of it all, I don't know what to say to newbies about which one to select. I personally started in VB6, which involved a lot of behind the scenes magic, but turned out fairly simple code. And VB6 really had very relaxed rules indeed, and is a lot like Python in that regard. I had an intuition early on that this kind of behavior was "bad", and so my VB code never involved variants being thrown around or any of that stuff. (I did use duck typing, but inheritance was seriously broken so there weren't many options.) A lot of people learning VB6 turned out really horrendous code, and I expect the same exact thing to happen with people who learn with Python. That's why I usually side with C# at the end of it all, but I can't say I'm happy with it.