tags:

views:

193

answers:

10

I've been using PHP all the time.

Any advice to taking on these two languages?

+2  A: 

The same way you learned PHP - read the documentation, write some code, compile or execute it, debug it. Repeat until you are good. But don't expect to master a language quickly - anyone can learn to write code in a given language, but it takes time and effort to actually write good, high quality, and idiomatic code in that language.

Thomas Owens
while(true){readDocumentation();}
thephpdeveloper
@Mauris: This will prevent you from ever writing any code. :p
uckelman
Or, hopefully, *not* how you learned PHP if it was from php.net and random PHP code :-/ I would say, the best way to learn Ruby and/or Java is to *forget* the "PHP way" and to tackle each new language under their own idioms.
pst
pst: Yes, you need to put some things behind you, but a lot of things from PHP (or any language) can help you learn any other language.
Thomas Owens
+1  A: 

The way I learn new languages is to read the documentation and other people's source code. It really helps to see what is possible in the language, without having it all wrapped up in academic speak. Books are also helpful, if you have the time/patience to read through them. A really good idea is to look up programs written in those languages and see if you can write the pseudo code for the programs. Then compare those to the source code and see what the difference is.

chustar
A: 

Trying to learn two languages at once is probably not the best idea. Ruby is quite similar to PHP, so the transition may be fairly simple, depending on your prior experience with other dynamic languages. You may find this site useful: http://railsforphp.com/

troelskn
Ruby is similar to PHP? I'm not saying you are wrong, but if that's true why do I like Ruby so much and **..** don't entirely respect **..** PHP? And I'm not the only one.
DigitalRoss
Sure, both PHP and Ruby are both dynamically typed and imperative (granted ruby has some functional-syntax), otherwise ... "similar"? Might as well say Perl and Erlang are similar.
pst
Obviously there are differences, but they are both dynamically typed, interpreted languages. They are both primarily used in a LAMP context and they are both primarily used for building web applications. The syntax differs quite a bit, but underneath that they aren't that different really. Java on the other hand, is a completely different world, compared to PHP.
troelskn
I'd say Java is much more similar to PHP than Ruby is. Coming from PHP and with no Java training, I can pick up some Java source and figure out what's going on. I'm not so sure the same applies with Ruby. You need to be introduced to its idiosyncrasies, otherwise you might spend quite some time deciphering it.
mike
I guess we can conclude that it's rather subjective.
troelskn
A: 

I recommend you try and build basic applications. Have a target, use the documentation and search the blogs or ask somebody if you're stuck. That's how I learned Ruby.

Also, for Ruby and Rails documentation I like APIdock, too bad they don't have Ruby 1.9 (which I recommend you use).

Mihai A
A: 

Click this: code-golf

Then solve all the challenges that got at least 10 upvotes in both Java and Ruby. Don't worry about the golf-scoring part, just do the best you can. If you post your efforts you may get some feedback, and you can compare your results with others.

DigitalRoss
+5  A: 

I would say it really depends if you're used to the way OOP (object oriented programming) works. If you're not familiar with this way of thinking I would definately go with the book "Objects First With Java". It might look really, really basic at first, and you might be able to skip the first chapter or two. But if you read it from chapter 2 or 3 or so and finish it, you should have a good amount of knowledge to start building applications.

It's a little hard to help here because I don't know your level of skill when it comes to OOP. :) I've been writing PHP for a long time and didn't know a thing about OOP until I read the above-mentioned book.

All the best,

Bo

bomortensen
What *is* "OOP"?
pst
OOP is programming/developing which is oriented around objects - taking advantage of encapsulation, polymorphism and inheritance which (in best case) should lead to reusing code and a decrease of code maintenance. Hope that clearifies ;)
bomortensen
A more interesting question would be: what isn't "OOP"? Maybe you could answer that one, pst? :)
bomortensen
A: 

Keep it enjoyable and simple at first. Use the learning style that works for YOU. If you like reading docs - great, otherwise you'll just end up with a nasty aftertaste. I'll say keep it enjoyable again because your initial exposure/experience can be greatly influenced by how you hit it off with a new language. Try to approach it from an angle of familiarity, you will find that there's some overlap between what you know and the new material. It will help if you can introduce the new stuff with as much ease as possible.

Recall what speaks to you or demonstrates most effectively when you learn and plot your course based on that. If you like books, find one that suites your style. Most of the books will give you most of the same information so what will make the most difference in a case like this is style of the book. For me "Java Objects" by J. Baker did the trick, my friend swears by "Thinking in Java". ... or find some screencasts if you like screencasts.

Then of course fire up the debugger and step though some code, but what ever you do first make sure you're enjoying it.

vector
+1  A: 

The best way to learn Ruby and/or Java is to forget the "PHP way" and to tackle each new language under their own idioms.

Both Ruby and Java have a fair selection of books (dead tree, electronic, free and non-free) as well as numerous free online tutorials. Ruby even has a nifty online interactive tutorial by _why (you did search didn't you?).

Learning the basic operation and syntax of each language is essential to avoid wasting time with random guessing as to why X doesn't work like Y. (Hint: If X doesn't work like Y, it's because X isn't Y.)

pst
A: 

Start with Ruby. There is a wonderful online tutorial that lets you try Ruby right in your browsers. It covers the essentials of flow control and collections.

http://tryruby.sophrinix.com/

Java and PHP have more in common syntactically than Ruby and PHP. Sometimes that makes it harder instead of easier when learning a new language. That's why I think learning Ruby before Java will help. Ruby is also a lot easier to learn than Java, so the emotional return is greater and you'll be more equipped for Java.

As to learning Java, start with a Tutorial using Tapestry. Not so that you learn Tapestry, but so you gain the benefit of rapid development.

"Java developers love it because they can make Java code changes and see them immediately ... no redeploy, no restart!"

The down side to Tapestry is potential mess of setting up Tomcat.

Off Rhoden
A: 

I'd recommend getting yourself familiar an IDE (i.e. Eclipse) and working through some basic HelloWorld-esque problems. This will let you understand the lifecycle of a java program and some basic I/O. Maybe even take parts of a PHP project you've written and port it over to Java to get the basic syntax ideas down.

yankee2905