

A Very Quick Comparison of Popular Languages for Teaching Computer Programming - djangonian
http://www.ariel.com.au/a/teaching-programming.html

======
Androsynth
I used to think: _C is a horrible language for beginners, they should learn
python due to its simplicity. This will allow them to learn about control
structures and program flow in a simple and easy to read environment_. But the
more I think about it, the more I like C. It gives you the best understanding
of what computations are actually being done by your processor; the mental
exercises involved with fulling understanding pointers is valuable at the
collegiate level (much less so if your learning to program on your own, I
believe college is a time to increase your analytical abilities rather than
just learn raw facts); It also has the simplest syntax to learn (for a
procedural language).

You dont have to explain argv, argc or the details of scanf to beginners.
Thats like saying python is complex because you need to explain iterators and
generators. You don't need to dig that deep into the language as a beginner,
you just need to be able to understand the structure, control flow and be able
to get your programs working.

~~~
cheatercheater
> But the more I think about it, the more I like C. It gives you the best
> understanding of what computations are actually being done by your processor

Yes, because C is exactly how computers work inside! SO CLOSE TO THE METAL

> the mental exercises involved with fulling understanding pointers is
> valuable at the collegiate level

I have learnt about mappings in mathematics in kindergarten. Literally. Then
in university we have had exactly one sentence to flesh out the idea in ZFC.
You really think C is so mind bending?

~~~
AdamTheCamper
I believe it is quite close to the metal. When I had my Systems Programming
course in first year of college we started with C, and then continued with x86
assembly. One of interesting parts was, when we compiled our C code to
assembly and then compared with our hand-written assembly code. Was fun :)

~~~
cheatercheater
Do you realize that with pipelining, preemptive computation, multiple levels
of caching, opcode optimization, NUMA, massive parallelism, and all that other
stuff x86 is to hardware what Java is to hardware interrupts?

Answer: you don't because otherwise you would not have posted the above.

~~~
Androsynth
You're over exaggerating. You can teach students about processor theory,
assembly language and C without getting into all the extra stuff.

All the extra stuff is built on that foundation, and learning C helps you
understand that foundation better than any other language.

~~~
cheatercheater
This is not "extra stuff". It is _how it works_. x86 was made to be simple to
hand-code, not to in any way reflect the hardware. And then, decades later,
new developments to it are so that it's _easy to compile to_. The language
went through two major paradigms without either having the point of x86
reflecting the hardware it abstracts. SIMD, NUMA, pipelining and caching is
exactly how processors work right now. And they're radically different to what
happened before the Intel Core family of processors. This is in turn radically
different to what happened before the Pentium Pro family of processors. Yet
all support the same x86 instruction set. The corollary is that x86 is an
abstraction. You're being ignorant if you think x86 is like the opcodes being
executed after the whole caching stage has happened.

------
nivertech
Erlang version (abc.erl):

    
    
        -module(abc).
        -export([main/0]).
        main() ->
            {ok,[A]} = io:fread("A=?","~f"),
            {ok,[B]} = io:fread("B=?","~f"),
            C = A + B,
            io:format("C=~f~n",[C]).
    

or

    
    
        -module(abc).
        -export([main/0]).
        main() ->
            {ok,[A,B]} = io:fread("A,B? ","~f ~f"),
            C = A + B,
            io:format("C=~f~n",[C]).
    

Compile and run from REPL:

    
    
        c(abc).
        abc:main().
    

Or just execute in REPL:

    
    
        {ok,[A]} = io:fread("A=?","~f").
        {ok,[B]} = io:fread("B=?","~f").
        C = A + B.
        io:format("C=~f~n",[C]).

------
noblethrasher
Was anyone else initially confused by the 'Postscript' heading at the bottom?
At first I thought it referred to the programming language (PostScript) but in
fact it's just referring to the "writing after the writing" (P.S.).

------
tomku
His postscript is a debatable improvement, as input() in Python 2.x (which was
what the article was written using) actually evaluates the input as a Python
expression before storing it. It's equivalent to wrapping the input functions
that the other languages use in eval(), which is (imo) a very, very bad
practice to teach unless you're asking your students to write a REPL.

~~~
aroberge
Yes, he should have been using raw_input().

------
LeafStorm
This was a very interesting read, but the Python code sample was painfully out
of date. It might be worth it to create a modernized version of this post,
with updated code samples for all the languages included, and additionally
adding newer languages like Ruby and JavaScript.

------
samirahmed
> I spent about 15 minutes, failed, then searched Google for an example.

It is understandable that Java can be verbose, but 15 minutes followed by
failure, make the author seem almost clueless about Java.

~~~
nierman
yeah, the use of java.util.Scanner would make it _much_ more succinct:

    
    
        import java.util.Scanner;
        
        public class Addup {
            public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int i1 = sc.nextInt();
                int i2 = sc.nextInt();
                System.out.println(i1 + i2);
            }
        }

~~~
techtalsky
Very interesting, although he does indeed say:

> The extensive class library is however quite daunting. It appears there's a
> class for almost everything, and much of "programming in Java" seems to
> consist of "searching for the right class". Even after two years I find I
> cannot do much in Java without constant reference to the documentation.

------
JVIDEL
This is old, and there are no mentions of Erlang, Haskell or Scheme.

Not even PHP which while it isn't perfect it's still pretty easy to learn.

------
wizzard
In the Java example there is a ton of error checking that is not being done in
the other examples. Not really a fair comparison. The author said the programs
should complete the task of "reading two numbers from the user, adding them
together and printing out the result." The Java program does more than that,
so of course it looks more verbose.

~~~
hythloday
I think it _is_ a fair example: both NumberFormatException and IOException are
checked exceptions, so the code will fail to compile if they're not caught.

~~~
anonova
Despite being checked, they do not necessarily have to be caught if you add a
`throws` clause in the method declaration.

------
sunsoong
Surprised to see Scheme was not included.

------
cheatercheater
To everyone who was interested by pg's idea of a simple language for
parallelism, check out pi calculus:
[http://mainisusuallyafunction.blogspot.com/2011/09/lambda-
to...](http://mainisusuallyafunction.blogspot.com/2011/09/lambda-to-pi.html)

