Live data from Hacker News

A Very Quick Comparison of Popular Languages for Teaching Computer Programming

ariel.com.au

21–30 of 35 posts

Re: A Very Quick Comparison of Popular Languages for Teaching Computer Programming

#21

Earlier quoted context omitted.

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

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 :)

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.

Re: A Very Quick Comparison of Popular Languages for Teaching Computer Programming

#22
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]).

Re: A Very Quick Comparison of Popular Languages for Teaching Computer Programming

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

Re: A Very Quick Comparison of Popular Languages for Teaching Computer Programming

#24

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 underst…

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

C is not CLOSE TO THE METAL. It lacks concept of SIMD instructions and barriers/fences. If you want to be CTM learn OpenCL / CUDA (unless you want to learn assembler for actual ISAs or SIMD extensions).

Re: A Very Quick Comparison of Popular Languages for Teaching Computer Programming

#25

Earlier quoted context omitted.

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 :)

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.

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.

Re: A Very Quick Comparison of Popular Languages for Teaching Computer Programming

#26

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 underst…

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

I never said it was mind bending. I said it was a good mental exercise for young engineers to go through to fully understand pointers.

It's one thing to read about pointers, it's another to actually implement a linked list in C.

Again, I want to stress I don't think you should get awarded a PhD for it, but for first year CS majors: it is good practice to actually implement and debug pointer-based data structures.

Re: A Very Quick Comparison of Popular Languages for Teaching Computer Programming

#28
post #12

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 underst…

But do we really need to submit beginners to things like segmentation faults, arrays without bound checks and the lack of a reasonable string datatype? There is no reason to use C as a first language when you can just as well teach all the basic ideas in a more friendly environment and then go through all of K&R in 2 weeks or so.

The problem with OOP is that its really not something that should be taught to people who are first learning to program. It is extra complexity and doesn't add any value for beginners. That is my problem with Python.

C has its disadvantages, but you get: 1-a simple syntax 2-good mental exercises in learning, implementing and debugging pointer based data structures 3-a good idea of what is happening at the processor level when a computer program is being run.

You simply don't get that combination in any other language.

There are caveats of course: theres the functional vs procedural argument (which is a higher level argument than this). There could also be a good point that OOP should be the very first thing a student should learn, but only if you teach them a smalltalk based language, not python, java, C++ etc.

For the context of my argument, I chose: 'for teaching first year CS majors their first procedural programming language, what is the best choice?'

Re: A Very Quick Comparison of Popular Languages for Teaching Computer Programming

#29
post #13

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.

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.

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

Re: A Very Quick Comparison of Popular Languages for Teaching Computer Programming

#30
post #12

Earlier quoted context omitted.

But do we really need to submit beginners to things like segmentation faults, arrays without bound checks and the lack of a reasonable string datatype? There is no reason to use C as a first language when you can just as well teach all the basic ideas in a more friendly environment and then go through all of K&R in 2 weeks or so.

The problem with OOP is that its really not something that should be taught to people who are first learning to program. It is extra complexity and doesn't add any value for beginners. That is my problem with Python. C has its disadvantages, but you get: 1-a simple syntax 2-good mental exercises in learning, implementing and debugging pointer based data structures 3-a good idea of what is happening at the processor l…

I started learning programming in January using K & R. C is great. Doing so many things manually really teaches you what is going on. It's definitely challenging, but I think I'm learning faster this way.
Post reply on HN