Tips for going from Ruby/Python to Java?
January 25, 2010 8:47 AM   Subscribe

I'm teaching myself to program. I learned the basics with Ruby on Rails, and I'm now coding in Python and Javascript, but I want to try an Android app, and that requires that I use Java. Going from Ruby to Python to Javascript was relatively painless, but I feel like I'm starting all over looking at Java code. Does anyone have any tips for going from scripted languages to Java? Or any really great tutorials for getting started in Java? Or any great tutorials for beginning programmers for Android?
posted by empath to Computers & Internet (13 answers total) 7 users marked this as a favorite
Response by poster: (if it matters, the android program I'm writing is not doing anything more complicated than what a basic simple web app does -- a form and some xml api calls on the back end via http, and displaying the results.)
posted by empath at 8:53 AM on January 25, 2010

Stack Overflow might help you: java+tutorial
posted by Blazecock Pileon at 9:02 AM on January 25, 2010

Are you having trouble with dealing with a strongly-typed language?

How's your OO basics? Java enforces OO pretty strictly, and if you're not used to thinking like that, it can be weird.

After you get the semantics down, it's just learning the API, which can be lots of clicking through docs, looking for something that's close to what you want.

It might be a good idea to pick up a book on design patterns, since a lot of Java is modeled after that.
posted by fnerg at 9:06 AM on January 25, 2010

Since you're coming from Python, an obvious first step could be to pick up Jython - it produces bytecode that runs on the Java Virtual Machine and lets you thus combine Python and Java code. That way you are not starting from scratch.
posted by Fruny at 9:30 AM on January 25, 2010

Man, I went from C++ to java and I couldn't believe how much easier it seemed :)

I think I got a book and read through that. This was all the back when I was in highschool.

If I were you I would get an android-specific book and go through it, rather then trying tutorials. Android "style" java is different from "Standard" Java both in the APIs you'll be using and the way you're supposed to code.

The APIs are designed for the phone, and there are differences in the way you're supposed to code because the VM doesn't do the kinds of pretty impressive optimizations that Sun's JVM can do these days.

this book and this one look like good bets for beginning programmers.
posted by delmoi at 9:31 AM on January 25, 2010

Since you're coming from Python, an obvious first step could be to pick up Jython

Jython dosn't work on Android. Android machines actually used a different JVM, and aren't bytecode comparable with java. And it doesn't have the entire JavaSE API, I don't think, there may be some dependencies that Android doesn't have.
posted by delmoi at 9:35 AM on January 25, 2010

Hmm, that "can't run Jython" was from '07. It seems like people have run Jython, at least according to that SO poster. But it's probably pretty hack-y.

If you want to do android programming, jump in head first, since there are so many differences between Android and JavaSE.
posted by delmoi at 9:38 AM on January 25, 2010

I haven't read Head First Java, but it's written by Kathy Sierra of the amazing but now frozen in time blog Creating Passionate Users and its definitely what I'd use if I didn't know Java.
posted by nomad at 9:44 AM on January 25, 2010

This is quite common for learners coming from a non-Object Oriented background. Previously you've been using languages where it can be acceptable to write software in a non-Object Oriented fashion. Java does not like this. Brilliant essays have been written on the subject, but for now your best option is to learn to like it if you want to learn Java. Basically you're given a bunch of predefined types that contain both data and algorithms that may use that data (member functions); these are called classes. Your goal is to create new types that inherit from existing classes and extend them and override existing functions just enough to do what you need.

The Jython suggestion has its heart in the right place, but Android is not strictly Java. You compile for a Dalvik JVM. I see an android-scripting project to allow Lua and Python scripts, but I don't own android devices and can't really tell you how mature it is.
posted by pwnguin at 9:45 AM on January 25, 2010

Response by poster: I think I am going to get ""Head First Java and "Beginning Android."

Thanks for all the input.
posted by empath at 9:47 AM on January 25, 2010

Apropos Jython: I would not advise it for someone trying to move to Java from Python.

The Java and Python models of object orientation are somewhat different, let alone the type system. If your aim is to learn Java, the blend of the two which you encounter in Jython is going to be more confusing than going for pure Java. Jython's neat for letting you run Python in the JVM but I don't see it as a useful stepping stone for the transitioning programmer, more a great solution for people who already know both languages and their strengths and weaknesses.
posted by i_am_joe's_spleen at 11:20 AM on January 25, 2010

If you just want to prototype and do simple stuff, you *can* use Python or Lua, with ASE. That's an official Google app, I think.

Might get you from here to there faster.
posted by Invoke at 2:25 PM on January 25, 2010

I'm a python guy and I've been learning Java (to *eventually* program Android too) by doing the official Java tutorial. I think it's pretty great, and should be easy to pick up if you already know OOP. I figure once I know Java pretty well, learning Android will just be API and style.
posted by i_am_a_Jedi at 4:46 PM on January 25, 2010

« Older This is so bad it's gone past good and back to bad...   |   What are these spiders doing? Newer »
This thread is closed to new comments.