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.
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.
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?'
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?
And anyway, the real problem is not C being complicated. Its that the other alternatives are also perfectly reasonable while also being simpler.
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.
It is understandable that Java can be verbose, but 15 minutes followed by failure, make the author seem almost clueless about Java.
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);
}
}> 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.
It's not hard in itself, but it is overly long, with a lot of things to remember.
I'm actually kind of embarassed I had so much trouble with this - I've been working on a commercial Java package for two years, but because it's GUI based I rarely have to deal with reading from the console. Real Java programmers will probably look down on me with a mixture of pity and disgust. Such is life.
-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]).Not even PHP which while it isn't perfect it's still pretty easy to learn.