Title photo
frugal technology, simple living and guerrilla large-appliance repair

Regular blog here, 'microblog' there

Many of my traditional blog post live on this site, but a great majority of my social-style posts can be found on my much-busier microbloging site at updates.passthejoe.net. It's busier because my BlogPoster "microblogging" script generates short, Twitter-style posts from the Linux or Windows (or anywhere you can run Ruby with too many Gems) command line, uploads them to the web server and send them out on my Twitter and Mastodon feeds.

I used to post to this blog via scripts and Unix/Linux utilities (curl and Unison) that helped me mirror the files locally and on the server. Since this site recently moved hosts, none of that is set up. I'm just using SFTP and SSH to write posts and manage the site.

Disqus comments are not live just yet because I'm not sure about what I'm going to do for the domain on this site. I'll probably restore the old domain at first just to have some continuity, but for now I like using the "free" domain from this site's new host, NearlyFreeSpeech.net.

Sat, 22 Aug 2015

Learning Java - why and how

Time has been a little tight over the past couple of weeks, but I had an "opening" today that I used to work on Java. Beginning Java. Very beginning Java.

I'm using the Oracle Java tutorials. You can download the whole thing as HTML in a .zip, or as epub and mobi files.

I have both the full HTML and the mobi version, which is made up of 20 separate .mobi files that I emailed to my Amazon Kindle reader because a) I'm too lazy to plug it in to the computer and b) they offer e-mail-to-Kindle, so why not use it.

I'm going through the material slowly, typing in the programs when that seems appropriate and using javac to compile and java to run them.

I learned how to create a Java source file (ending the filename with .java) and then compile it with javac (after which you end up with a "bytecode" file with the .class suffix that you can run with the java program, leaving off the .class at that point:

$ ls
$ javac test.java
$ ls
test.java Test.class
$ java Test
(program runs)

The java compiler is good at finding errors (lower case when there should be upper, missing semicolons, etc).

While looking at /r/learnjava on Reddit, I stumbled across an entry, What is easiest way to read and write a text file? that lead me to a very helpful tutorial on how to do it and the extremely helpful site that published it, BeginwithJava.

I did type out these examples, got some practice in the conventions and syntax of writing Java programs and was happy to find that they worked as advertised.

So why Java?

Coming from a free-software background, Java isn't exactly at the top of the list of programming languages to learn, even though it is free software, albeit corporately-controlled and litigated. The only thing "worse" is a Microsoft-created language like .NET/Mono.

Yet both have a foothold in the Linux-running world. Both are huge.

My main motivator in learning Java is Android. I'm very much interested in learning to create Android applications. Our world is a mobile one, and Android is the biggest piece of that enormous pie. I have an Android phone, and I'd love to create my own applications for it.

I should probably be focusing on Javascript, the web's lingua franca, and maybe Python or Ruby, but the pull toward coding for Android is so strong, I'm letting it pull me in the direction of Java.

I have learned a little bit of Go, but it's early days for this very promising Google-created language, and while it very well might become a first-class (no pun intended, really) language in the Android world (and is getting closer by the day), Android development is still all about Java and Android Studio.

I have Android Studio installed. First of all, my laptop starts to heat up like crazy when I run it. Second, I have no idea what to do with it.

So I'm starting with Java.

What little I have learned up to this point is that programming is programming. The language you use is just a means to an end, which is making a computer do what you want.

The art/skill of writing a computer program is something that you can "port" from one language to another.

So while I am very interested in creating web apps with Javascript and Node, and am continually interested in doing system-administration tasks with Perl or Python instead of Bash, right now figuring out Android is at the top of my list. And if Java can help me do that while grounding me in a language that can also be used on the web and a local computer, so much the better.

More Java resources

There are plenty of regular books to help you learn Java. One that I like (seeing the preview) is "Java: A Beginner's Guide" by Herbert Schildt. I haven't bought it yet because the free resources have been so good.

Among those free ones, which I have downloaded and have at my disposal are:

Having the Oracle "book" on my Kindle will be pretty helpful, I hope. So far it's pretty good.

Parting note: Though I do have Android Studio, for my "regular" Java practice, I didn't install and IDE and am instead using the terminal and the Gedit text editor with javac and java command-line programs on my Fedora Linux system. (I'm not using an IDE.) This way I'm working with the tools I know and getting a feel for the Java tools I'm adding to my repertoire, if you will.