[geeks] Java as a first language
Jonathan C. Patschke
jp at celestrion.net
Fri Nov 10 14:33:49 CST 2006
On Fri, 10 Nov 2006, kevin marshall wrote:
> Please excuse me if this has been covered before, but would any of you
> recommend Java as a first language, and if not, any recommendations?
I suppose it depends on what your goal is. If you want to play around
with the computer and build neat stuff, find a language with a high
enough degree of instant-reward that you don't get bored with it. Find
a copy of Visual BASIC 6, or start learning Perl or PHP. If you decide
you want a challenge afterwards, move on to C or Java.
If you want to learn how to write code well and how to implement
algorithms well (ie: you want to make a career out of programming
someday), I'll warn you right now that it's just like bodybuilding. It
takes a lot of time, a lot of dedication, a lot of practice, and getting
to the point where you can do useful things elegantly and well requires
a lot of tedium.
I would not recommend an object-oriented first language for anyone who
intends to get even remotely serious about writing software for the
simple reason that most computers are not object-oriented.
Object-oriented thinking is convenient for modeling problems, but it
doesn't give a lot of insight into what's going on inside.
My first programming language was TI BASIC, back in 1983, followed by
Applesoft BASIC and GW-BASIC later. In terms of bad habits, this was a
less-than-ideal start. By the time I moved on to Turbo Pascal and C, I
had a log of BASICisms to unlearn.
Ideally, if I'd been a little older and had a PC or Z80 back then, I'd
have started with Turbo Pascal. Pascal verges on being a toy language,
but Turbo Pascal is complete enough for implementing any algorithm that
doesn't depend on videly variant amounts of dynamic storage.
If you want to get serious about programming, you're going to need to
learn C. Whether you learn it first or whether you learn something like
Perl first to get you into thinking algorithmically, there are very few
"high-level" languages tha bring you as close to the machine as C.
Being able to program in C very well implies an understanding of how
computers work. Regardless of what the "agile programming" neens and
functional programming academics would have you believe, it is still
Very Important that your programs run well on actual hardware.
As a language, C is easy to learn. The K&R book is tiny, and the
language is equally tiny. Conceptually, though, it's very heavy. You
have to learn how to manage resources by hand. This involves
simultaneously thinking about data structures in abstract terms
(records, arrays, linked lists) and in mechcanical terms of memory
layout.
Once you're good at C. You're halfway towards learning Java, anyhow.
You just need to stir in the OOP methodology.
Universities like to start people off in functional languages such as
Scheme because a wide variety of algorithms can be implemented in them
fairly elegantly, and, once you get to thinking recursively, Scheme has
a very high degree of instant-reward. It's possible to take many of the
concepts of a functional programming language and use them in C or Java,
but you'll tend to end up not managing memory well.
I'd also recommend learning at least one assembly language. x86 is not
optimal because it is so complicated and has so many opcodes. MIPS or
SPARC assembly is very regular, very small, and very rewarding. Of the
two, I prefer MIPS.
If you pick a tiny machine (6502, Z80) or an elegant machine (MIPS,
SPARC), assembly language is a pretty good place to start. it really
drives home the point that programming is really nothing more
complicated than explaining -exactly- what you want done in excruciating
detail with zero ambiguity.
All that said, the language you choose isn't nearly as important as how
you program in it. Don't just learn enough to hack things together;
learn to program well. Learn to comment well, so that you'll know what
was in your head six months ago. Your code should be as unambiguous to
the reader as it is to the compiler.
--
Jonathan Patschke ) "Some people grow out of the petty theft of
Elgin, TX ( childhood. Others grow up to be CEOs and
USA ) politicians." --Forrest Black
More information about the geeks
mailing list