Perhaps I should entitle this ‘On trying to learn Java’, because although I have persevered through over sixty YouTube lessons, I still don’t feel confident in the language. I understand in a broad way the approach that it takes — the strategy, if you like — but the choices made in putting the language together don’t seem intuitive to me.
For those unfamiliar with Java, it’s an object-oriented language based on C++, designed specifically to be portable across a wide range of different platforms. The reason I am learning it, in fact, (or trying to) is in order to write Android applications. Not that I have any in mind at the moment, but if I ever do think one up it would be nice to be able to program it myself.
What makes Java portable is the fact that the source code can be interpreted into higher-level ‘byte code’, which is then capable of running on many different devices. Which is fine, but I thought the whole point of having smart, sophisticated devices was to allow us to interact with them on our terms, not theirs. To have to write monstrosities of code in order to get a five-hundred-dollar tablet to do what I want really goes against the grain.
Then there’s the object-oriented part. I vaguely understand the principles behind this, it’s the details of the implementation that irritate me. Why does the int variable declaration appear lower-case, while String has an initial capital? Why do I have to write:
HandlerClass handler = new HandlerClass();
when it’s obvious that if handler is based on a HandlerClass object, then it’s usually going to be a HandlerClass object itself, and since this is the first time it appears, it’s got to be a new one? What’s wrong with:
handler = HandlerClass();
Yes, I know there are exceptions, but why not keep the confusing syntax for those and assume some sensible defaults otherwise?
None of this is meant as a criticism of the lessons, which were put together in 2009 by a guy calling himself ‘Bucky’. They’re really excellent — much better than the Amazon book I was trying to read on the same subject. Bucky is deceptively laid-back and casual in his approach, but each little chunk of a lesson brings you closer to understanding what’s going on. You can find the first lesson at https://www.youtube.com/watch?v=Hl-zzrqQoSE. Like Bucky, I use and recommend the free Eclipse application for program development — this is essentially a text editor with the smarts to tell you when your syntax is wrong, and to interpret and run the program directly without having to exit to the Terminal prompt.