Kllrnohj wrote:
No, because that main isn't valid. You're missing the return type of int as well as the return. It may be valid in old, not-used-by-anyone C, but if you're teaching someone that you're already off to a terrible start.
So explain return types. You still don't have to get into all sorts of arcane inheritance rules and OOP-theoretical nonsense which won't make sense to someone who doesn't know how to program yet. You can concretely demonstrate the purpose of a return type in the main method in C, since you don't have to explain "void" to someone who doesn't know what return types are yet. Instead you can show how the int you return from main is the program's exit status code that it hands back to the execution environment.
Quote:
I just said C has quite a bit of boilerplate as well - which is true. HelloWorld has less, yes, but as soon as you get even slightly more complicated the boilerplate builds up quickly.
Once you get into programs where you need to compile multiple source files, sure, but I can't think of any instances where that is necessary (or even desirable) for the sorts of assignments that are given to intro students. Instead the boilerplate appears gradually, and, for the most part, in places where it has a real use that can be demonstrated and explained concretely.
Quote:
As Kerm kind of pointed out, there are better languages to start with - like Python. No boilerplate, no tricky memory management, no pointers, tons of growth potential, etc... C really is not a good starting language, and neither is Java.
I agree that Python is a fantastic starting language, and the reason I brought up C at all is because I think C does just fine as a beginners language and it seemed absurd that someone would be upset with Python by comparison.
Kllrnohj wrote:
Explaining Python's "Hello World" is a piece of cake and easily understood by just about anyone. Explaining Java's is ridiculous and requires a lot of Java-specific knowledge to have any hope of understanding.
QFT.
And for the record, a proper "Hello World" Python program should be
Code:
import sys
def main():
print "Hello World"
return 0
if __name__ == "__main__":
status = main()
sys.exit(status)
I probably wouldn't teach that either, but since we've decided that the purpose of a first program is to be as correct as possible, rather than as understandable as possible...