Many universities noticed this trend and decided that pointers were too hard a concept to teach in a CS program and so they switched from C as the core CS language to Java.
In VB/Java/Python, you can glue three strings together by going:
str = "Foo" + " " + "Bar"
print str
But in C, you have to go:
char * foo = "Foo";
char * space = " ";
char * bar = "Bar";
int nLenFoo = strnlen(foo, 20);
int nLenSpace = strnlen(space, 20);
int nLenBar = strnlen(bar, 20);
int nBuffSize = nLenFoo + nLenSpace + nLenBar + 1;
char * buff = (char *) malloc (nBuffSize * sizeof (char))
if (0 == buff) exit(1);
char * tmp_buff = buff;
if (tmp_buff != memcpy(tmp_buff, foo, nLenFoo))
exit(1);
tmp_buff += nLenFoo;
if (tmp_buff != memcpy(tmp_buff, space, nLenSpace))
exit(1);
tmp_buff += nLenSpace;
if (tmp_buff != memcpy(tmp_buff, bar, nLenBar))
exit(1);
fprintf(stdout, buff);
Why is this so much more difficult to do in C then it is in VB? Because string concatenation is NOT a simple problem!
Slashdot has an article up today about the downsides to teaching a generation of programmers to use Java instead of C. It's main thrust is that Java programmers can't build new computer systems.
Freakin' D'uh!
I remember having heated conversations as a student advocate at Dalhousie University with a number of professors regarding the issue of teaching Java as a first language. Their argument was that we had an 80% drop out rate from first year to second year and we needed to figure out how to carry more students forward. I felt at the time (as I do now) that you achieve this goal by teaching the basics BETTER not by dumbing it down and carying the hopeless ones forward anyways (who then struggle in the OS class, or in the AI class or in the DB class or in the Algorithms class, etc...). I even made the argument that all code should be taught in assembly and that even C was too high a level to teach CS at.
C has always been, and will always be, the basic language of computer scientists. It is the closest thing we have to easily understandable machine language. It's biggest deficiency is also its biggest asset: it so terribly easy to shoot yourself in the foot with C and so terribly difficult to do many trivial things (like string manipulation).
But that's because C shows you the real nuts and bolts of what's going on.
There are many things that can go wrong in the process of assigning three seperate blocks of memory to be held in a third block. And the way that Java/VB get around this is the same way that President's Choice gets around not being able to cook: someone else does it for them and they simply have to "re-heat" the code. Under the covers, the VB/Java syntax is doing exactly the same thing that the C code is. It's just hidden from the end programmer (much like how much of a computer program is hidden from the end user).
VB/JAVA programmers look at the system from an end-user point of view, rather then from the computer's point of view. When it comes to taking someone else's ideas and putting them into the computer, that's what VB/JAVA types are good at (and there's a lot of work around for doing exactly that). But they rely upon the C programmers who implemented the lower-level libraries that actually DO the operation that the VB/JAVA programmer wants to do.
Students who aspire to be real computer science professionals, be they termed software engineers or systems analysts or software developers or simple programmers, MUST understand the intricacies of the memory heap, I/O interupts and CPU instructions if they want to be able to craft and improve the underlying computer systems in the future.
And frankly computers don't run on Java: programmers do.
Now we just have to invent an ultra-productive do-everything lanuage called BEER.

No comments:
Post a Comment