Friday 14 March 2014

In defense of the command line and the humble text editor

I recently embarked on a new university subject - an introduction to Java programming - as part of my CS/IT degree, and cringed slightly when I heard we were advised (though not forced, thankfully) to use Eclipse. I've had some experience with Eclipse already, using it for Android development, and my overall impression was that it has almost as many features as it does bugs/'features'.

I wasn't looking forward to battling with that again, but it occurred to me that a lot of the things I find annoying about Eclipse could probably be customised/turned off in the preferences, so I decided to give it a go. After all, it does have some useful features, and I thought manually compiling code from the command line would be impractically tedious for assignments later on in the course.

In spite of some ridiculous issues which I can't be bothered relating (long story short: the only version of Eclipse I can use crashes if I try to modify the preferences), for the first week of my new subject I did, in fact, use Eclipse. If I'd been able to do so without it crashing, I might have turned off a lot of its autocompletion features and other things that save typing and make for lazy coding. However, it's hard to resist being lazy, and the way Eclipse is designed also means it's almost difficult to write classes and main methods yourself. Eclipse wants to do everything for you. That's very nice - and very bad for a newbie like me. I'll explain why in a minute.

Today I finally decided I wasn't going to put up with Eclipse anymore, so I moved all my source code out of the Eclipse workspace into appropriate folders for each week of my uni subject, opened up a terminal and Sublime Text, and tried to write a main() method.

I realised I had no idea how to.

It's not like I haven't seen hundreds of them by now; it's just that I've never had to remember how to write them because I've never needed to write them. Eclipse auto-generates these things.

I spent all day manually compiling and running Java code, and I've learnt more than I did in a week of writing similar programs in Eclipse. I consider it a privilege to be able to learn by trial and error, see exceptions and syntax errors pop up and try to figure out what's going on all by myself without the little lightbulbs and red 'X's that Eclipse gives you. I relish the fact that I can leave a variable unused for as long as I like without being given a wiggly yellow line and a warning that says 'you haven't used this variable yet!' I enjoy being able to make mistakes without being admonished. But most of all, I love having to remember how to do things.*

It turns out that Sublime Text - an excellent programmer's text editor - has many of Eclipse's better features, including autocompletion, so perhaps it's not so humble after all. However, the fancier features are unobtrusive enough that I barely noticed they were there.
The only autocompletion I use is for variables and methods I've already typed out at least once; Sublime Text doesn't seem to offer autocompletion for things you haven't already typed. I discovered an exception to that rule (and there are probably others) - it does offer autocompletion for the main() method, which I only allowed myself to use once I was confident I knew how to write it by myself. There's also an option for auto-closure of brackets and strings, but that was one of the features I hated in Eclipse so I'm leaving it off. For now, closing brackets and quotes are too firmly embedded in my muscle memory.

It's slightly scary to realise that if I'd gone on letting Eclipse practically write code for me, if someone had sat me down in front of Vim and asked me to write a Java program I probably wouldn't have been able to.** Until I know enough about Java to be able to work on the kind of big projects that Eclipse is essential for, I refuse to succumb to laziness.

*the whole 'not crashing' thing is pretty great, too.
**without googling anything!