Categories
java tutorials programming

Java considered harmful as first programming language…

Today, I was pointed at an article suggesting that java is responsible for the decline in the quality of Computer Science graduates.

Specifically if you want to be a Computer Scientist, I’d say that the initial claim that “java is bad as a first language” is true, just as “C++ is bad as a first language” is true. What disappoints me is that they go on to suggest that C++ is good as a first language (disclaimer: my uni course taught ML as first language, ARM assembler as second).

Do you want to be a Computer Scientist? Why would you want that? Well, the article makes some good points in that regard – essentially, if you want to be an OK-to-good programmer, then it will help to be a CS, but not required, but if you want to be a *great* programmer, you absolutely need to be a CS. So, if you’re not interested, stop here :). But if you hope to be a really good programmer one day – or to understand those who are – read on.

“Better” first programming languages

(by “category”, rather than naming individual langs – within these categories, anything popular / common is equally good)

Assembler

Teaches you to be REALLY good at the meat of programming: the individual lines of code that follow one after another within any chunk of a program, such as the body of a function or method.

Functional

The closest form of programming to the theoretical mathematics of programming, and hence the easiest in which to achieve a lot of solutions (for instance, parallel programming such as needed to take advantage of multiple CPU’s or multiple servers in a cluster is orders of magnitude easier to do in a functional language).

Data-driven

Much of the programming problems in the world come down to manipulating, generating, or managing data. Data languages don’t get much attention because they aren’t general-purpose languages, but they’re the best choice for a big chunk of the systems that most programmers will spend most of their lives working with. Amongst the non-general languages, they’re probably the most useful to a modern programmer (sheer speculation on my part there – feel free to smack me down for my foolishness :)).

C? C++? …etc

Anything C-derived (and that includes java!) seems to be an excuse for avoiding teaching the fundamentals of computer science: you should either be teaching the theory (as the article laments we are not currently doing), or you should be teaching the hardware (as it also laments, but less forcefully, and seems to mention only as an excuse for why C is good). Or…you should be accepting that you’re not [even attempting to] teaching either. C/C++/Java force you to learn neither of those things, so make for poor first languages IMHO.

Is java “bad”?

Let me be clear:

Java is one of the best day-to-day practical languages available in the world today (C# is pretty much the same – but the Microsoft / Windows obsession often counts against it); Java is the WRONG approach for many problems – but it’s the RIGHT approach significantly more often than C++, LISP, C, Assembler (any), etc.

If you already know how to program, then Java is an excellent language. One of the core features is that it lets you work in large teams, alongside other programmers who aren’t as good as you, and not have your code screwed-up by their incompetence or inexperience.

By contrast, C++ makes it easy for other people to destroy your code, and C positively encourages it.

LISP? Well … with LISP, the chances are most of your colleagues will give up entirely, and leave you to write all the code for the entire company. Sadly … relatively few people are willing to code with LISP.

Flamebait articles

In passing, I wanted to comment on the article itself. Mainly because on the whole it’s a GOOD article, making some good points and bringing attention to some problems that have been allowed to get out of hand – but I can’t recommend it without reservations, because in some respects it’s deeply flawed. To people under-experienced in this stuff (e.g. undergraduate programmers, and high-schoolers choosing CS degrees) I think it would be easy to be misled by some stuff in the article that really isn’t fair.

The way the article has been written makes it easy to speed-read it and recycle it as food for a “java is bad” argument :(. As noted at the start, I think the arguments for this aspect ALL hold equally true for declaring that “C++ is bad”, but the author not only glosses over this but instead even has a half-hearted attempt to argue the opposite. To see this as justification for either argument would be foolish, of course, but it’s easy to see how pre-prejudiced (i.e. flamers and trolls ;)) people will do that. I’m sure it will happen, although I don’t think the authors meant it that way (if anything, I think it’s an extended attempt to elevate Ada in people’s estimation). In the modern internet world, on certain topics (such as anything that compares and contrasts programming language) you have a duty to be extra careful about how you present your arguments.

Given the way the article starts (by poking java), I’m particularly disappointed that the “Why Java matters” section misses out any of the stronger benefits of java in particular, mainly I think because they wanted to mention them in the Ada section (where several of them appear), and didn’t want the fact that they’d mentioned them in the java section to weaken the argument (I note that C#/.NET/CLR isn’t mentioned at all either – if you’re even going to try to defend java as a choice, I think you should mention other managed languages).

I also think it’s odd that they would choose LISP as the only functional language represented. Not just because I’m an ML fanboy :), but because IME, functional languages fit much more closely to standard human approaches to problem solving than imperative languages.. If you’re going to pick the ideal language to teach students first, it would be a functional language, so there ought if anything to be MORE fn langs than imperative ones in the list – but it’s the other way around. I think if they fairly compared both fn and imperative, the fn langs would probably win the majority of reader mindshare. I think the main reason they didn’t include them is probably their desire to make Ada seem good, as mentioned above.

That’s purely my personal opinion, of course; take it or leave it…

3 replies on “Java considered harmful as first programming language…”

My first *formal* education in programming (not including messing around in BASIC on my TRS-80) was in C, but it was a year-long high school course in C where we pretty much learned the higher concepts of what you might learn in a course on Assembly language. We spent five months on “bit flipping,” which was just pointing to memory locations and running ROTs and masks and stuff on them, writing your own putpixel with double buffering, that sort of thing.

Then I took a C++ class, in which I learned almost nothing.

Then I took electrical engineering courses and learned to program entirely in Assembly on the X86, 680x, 68000k, ARM, PIC, and a few others that escape me right now. At which point I realized I didn’t care about programming that much and wanted to be a hardware engineer.

And then somehow I ended up working on video games. But I’m still not a programmer!

…was I going somewhere with this? I forget.

Oh yeah. The point is, I agree with the bottom-up approach to programming. Learn the basics, start with an incredibly simple (by modern standards) processor, learn ASM or something just-barely-above-ASM for that processor.

Although this could just be my bias. One of the things that always held me back as a programmer was my complete inability to understand classes, virtual functions, templates, and all that other stuff that I know just enough about to know I don’t understand. Granted, I never really put my mind to it because I resigned myself to hardware by the time I was being taught that stuff.

But still. I was always good at the low-level machine code and the high-level state machine / turing machine / graph theory / complete grammar / CS-type-stuff. Yet I never managed to fill in the middle.

C# has anonymous functions and higher-order functions – so you can write functional programs in C# (shame Java doesnt). Also if you want a good ide with a functional language try F# (written in Microsoft’s Cambridge labs and being turned into an official MS language), which is a .Net functional language and therefore works within Visual Studio. (Which ignoring any anti-MS bile is a pretty good IDE – I haven’t used Eclipse in years so I couldn’t compare!!!).

Sure, C# may support fn programming, but it doesn’t enforce it. Since you’re trying to teach students to think functionally, I feel you need something that does enforce it. I think both Java and C# are good languages to teach *at some point* on a CS course, but just not necessarily the first language.

Comments are closed.