As usual, no poll because there’s too many programming languages to make one worthwhile. Obviously one of the best answers is usually “whatever is popular because it’ll make getting a job easier”, but for a university program, for instance that may not be true since a lot of schools will introduce you with one language, and then you’ll learn more languages as you advance in the program. I’m asking about the best introductory language.
I’m not sure I have a great answer. On one hand, I love C as a learning language – not because “it makes you do things the hard way” or whatever, but because it doesn’t hide things from you. When you use == you’re comparing two numbers no matter what; there’s no weird overloaded stuff where you can compare the string “123” to the number 123 and have it be true (I’m looking at you, PHP). It can be convenient, but it can also hinder learning because I think it’s important to realize at some level that everything you’re working with is arbitrary and just numbers under the hood – that prevents confusion in a lot of cases about why things do/don’t work (because no matter how good the language design is, you’re inevitably going to hit a problem that stems from two numbers not matching eventually).
On the other hand, I’d be remiss to not mention that C also has some weirdness – “bool” is just a handy alias for an integer (it’s literally just a typedef). If is especially wonky, because things like if (a = 4) can and will come back to bite you, and while you can explain it away with “everything is just numbers and if just does the test <value> != 0”, I can’t deny that it’s unintuitive. It also has the problem that “hello world” is too big of a program.
#include <stdio.h>
int main( void ) {
printf("Hello, world!
");
return 0;
}
I’ve had a lot more trouble than you might expect teaching the “simplest program”. At some point you have to introduce the technical term “magic” before you have to start explaining what a preprocessor is, what “void” means*, and why main has to return a value (which also would entail explaining functions on the first day) to a complete beginner. Compare this to Python’s simple
print "Hello, world!"
Straightforward, simple, easy to understand. It’s great, Python is nice to work with. I just feel like people who start with non-systems languages get themselves into holes when they inevitably run into what could be called a “language implementation detail”.
Perhaps the best approach would be to start off with Python because of how minimal the programs look, and then use something like C as an “intermediate” language that aims to ultimately explain why some of these weird bugs happen under the hood.
Opinions?
- I (and most CS education people I know) actually tend to just omit the “void” in lessons because the compiler won’t complain without ANSI warnings explicitly requested; just to cut down on questions.