tags:

views:

1126

answers:

20

I am a PHP dev looking to pickup a new language, I have tried and failed on C++ several times (possibly for my overall lack of interest). I've been hearing a lot about Python, and Ruby and my question is this: Which of these languages (Python, Ruby) should be easiest for someone with a background in PHP to learn?

Update (6 months later):

I decided at the time of this question to go the Python route, I spent some time learning Python but I didn't really enjoy the language, I eventually moved on to C# which I greatly enjoy, and infact have developed 2 application in C# already and have another 3-5 lined up. I do intend on looking into Ruby when I have some free time, but until then I'll advise anyone else in the position that I was in when this question was asked to skip both Ruby and Python and look into C#. I was a hard-core anti-.net anti-msft and although I still don't like the dependence on .net I do like the design of the language overall.

A: 

They are about the same. I think Ruby is more fun. Python is more canonically C-like, but not a whole lot.

Honestly, give them each a week and see what you like.

If you learn Ruby, start with Ruby. Don't start with Rails.

Kevin Conner
+5  A: 

Python. If you go through the fairly straight-forward 'Getting Started' section of the Google Application Engine, you can get experience deploying it to create web content, too.

Richard Franks
+1  A: 

And before the comments come, I don't think I can progress with PHP to much more (at least until PHP 6), I have done about everything that can be done with it including desktop apps with compiled PHP.

Unkwntech
If you're that competent in PHP, then you should have no problem keeping your day job while dabbling in some other languages. It sounds to me from your "lack of interest in PHP" that you'd probably prefer a newer language. If I had to bet between the two, I'd probably bet on Ruby.
kooshmoose
Sorry the lack of interest was in C. And I am fortunate to make a living as a freelance PHP developer, so I have all the time in the world.
Unkwntech
A: 

Ruby is really fun to program in, and feels more "common sense" to me as the code is very easy to read.

rkalajian
A: 

(possibly for my overall lack of interest)

That could be the problem with any language. I know learning C++ was very mind numbing since all you're really doing early on is console applications.

I would say ignore the language for now. Try some frameworks, try out RubyOnRails and try out Django.

ShaneB
+1  A: 

You may only know which is best when you try a few. It only takes an hour or three to go through a simple tutorial in a new language. Just Google for something simple and have a crack at it.

From memory, after I learnt PHP, I went on to Java. If you're coming from PHP5, then it may not be too much of a stretch. I can say that Ruby (not Rails) is a great starting point too. Have you seen Shoes? I'd give something like that a try.

Dan Harper - Leopard CRM
A: 

I found Python to be more similar to PHP than Ruby. But you would have to spend a 20-30 minutes with their 'getting started' tutorials to determine which one you are comfortable with..

Swati
+3  A: 

Well, Perl is the scripting language that's probably the most PHP-like. And there are a good number of Perl jobs out there and interesting projects like Mason and Catalyst.

But out of those two (which are both better general-purpose scripting langugages than PHP, IMHO), I think they're both different enough from PHP but similar enough to each other that "which one is most like PHP" shouldn't be your main criteria. (Instead, ask yourself what apps like Rails or Django you want to learn, or what you think would make you more marketable professionally, or use some other business criteria to decide.)

But, if you need a tiebreaker, then yeah, it's Python.

joelhardi
+10  A: 

Neither Python nor Ruby are anything like PHP as a language; syntax and concepts are completely different unfortunately. And if you are used to PHP for the web (which there is a pretty good chance this is the case), those languages, used for the web, become even more difficult to understand (WSGI is completely different than mod_php, and seeing how php is a self templating language, MVC or whatever pattern is much different).

The easiest to pick up straight from PHP is going to be something on the ASP.Net agenda. unfortunately, you would have VBScript Classic ASP mastered in no time. That being said, you don't want to do that, it's just old, outdated, and not any more fun than PHP. Not to mention you are going backwards from PHP to VBScript, and you will find yourself banging your head against the wall and asking 'Why?' more than you ever have.

Now that the disclaimer is out of the way, I say you should dig into Python, and learn what it's all about. In my experiences with virtually everything (Java (J2EE and JSP), ASP.Net, Ruby, PHP, ColdFusion, yadayada), Python has been by far the easiest to learn. Not because it's the easiest language, that is up to you to decide, but because the learning resources were much better at the time than anything else. That may have changed, it's been a few years, but my vote is still there.

And if I was correct in my web assumption, I would definitely go pick up django and start running with that, you won't be let down.

neouser99
I was starting to bang my head against the desk at the metion of VB, and almost down-voted you for it, then you saved yourself so +1.
Unkwntech
@Unkwntech: for someone with a PHP background, VB bashing is extremely unwise. Just saying.
Konrad Rudolph
Bashing any language is unwise, regardless of background. Long live php!
rick
+2  A: 

I'd have to say Ruby, also. Like PHP it's rather 'perlish' (Ruby steals a lot of syntax from perl, PHP was even originally implemented in perl, back in the day ;)), but with modern syntax and much of the cruft removed. That's not to say you'll be able to code Ruby immediately, but you shouldn't have much trouble with the concepts, and the syntax shouldn't have much in there that'll cause you confusion.

The one thing you may have trouble with is deployment (I'm no PHP fan, but the devs certainly got deployment right!). So if you're used to quickly putting a site together and uploading it, I'd advise you to pay attention to application servers and production deployment methods. Unfortunately Ruby lacks a little bit there, but there has been significant progress.

Dan
A: 

I think either Python or Ruby will blow your mind once you start getting into them. Both languages are elegantly designed and internally consistent.

I would suggest Ruby because it has more momentum at the moment and Rails is an incredibly good platform (not to discount Django, but Rails is now v2.0 with an insanely active community, and Django just went v1.0).

I moved from PHP to Ruby/Rails and I have never looked back. Things that will drive you nuts in PHP are simple and elegant in Ruby.

Rails deployment just became as simple as PHP with the advent of Passenger/mod_rails. Coupled with the incredible Capistrano tool for deployment, I think Rails is actually much easier to deploy then PHP projects (I simply execute "cap deploy" and Capistrano checks out the latest version and rolls it onto the server. Done and done).

In terms of raw language similarity, Java is probably actually the closest. The syntax is similar (both ultiamtely derive from C) and the object system is actually pretty much the same. The PHP 5 object model is largely based on Java's.

Toby Hede
+1  A: 

It seems you are actually asking two different questions and there is a third question that is implied.

Your first question, from your title is "which languages are most like PHP?". I don't have any particularly good answer to this, since I'm not all that familiar with PHP.

The next question is, "which language would be easiest for a PHP developer to learn?" For this I think the best answer is going to be python followed by ruby as a close second. I think this is probably true if you substitute just about any procedural/OO/algol-descendant language for PHP. Both python and ruby are very easy to pick up and a pleasure to use once you understand them. I think most people would have a slightly easier time picking up python because the language itself is a bit smaller and it tries to adhere to the maxim of "there is one (right) way to do it" whereas ruby is a bit bigger and often offers more than one way to do it (but IMHO, without all the warts of e.g. perl).

The implied question is, "what language will I benefit the most from learning?" and I would argue that it depends what your goal is, but that in a lot of cases it's going to be better if you learn a language that is as far from PHP as possible -- not because of anything inherently wrong with PHP (I won't open that can of worms) but because languages like LISP/Scheme, Erlang, Haskell or Forth are going to have a much bigger overall impact on how you think about developing software. I think you will be a much better developer for it (than if you learn a similar language like python or ruby).

On the other hand if your goal is just to have another tool at hand to get stuff done with, python or ruby are going to be more helpful than any of the others I've mentioned. If you want to strike a balance between expanding your horizons and having a tool to use in "real world" projects, my guess is that Erlang or Scala might be your best bets.

John
A: 

Why do you want to learn a language that's like PHP? If you're good at PHP, you're probably not going to learn much from a new language that does pretty much the same things with a different syntax. Similarly, if you go with a similar scripting language, you're probably not going to be able to use it to solve different problems than you use PHP for. I think you'd gain a lot more by learning something that's as different as possible from PHP, something like C, or F#, or Lisp. These languages are all quite different from PHP, and learning them will be more likely to teach you new concepts and enable you to tackle new problems that PHP (or a similar language) aren't well suited to handle.

Chris Upchurch
+1  A: 

strictly speaking, the language most like PHP is PHP.

if you've tried and failed with C++ several times, perhaps the problem is motivation, and not the choice of language

  • SmallTalk is fun
  • C is fast; you might try learning C first and then C++
  • Java is elegant, as is C#
  • Lisp is interesting
  • Prolog is also interesting, for a little while
Steven A. Lowe
+1  A: 

The language most like PHP is Perl. The reason for this is it was originally written in Perl, and as such it copied quite a lot of its design from Perl.

Brad Gilbert
A: 

May I suggest Javascript or Actionscript (Both share the same base of ECMA script)? They'll both server you well in Web apps, and who knows, my hunch is that we'll be writing most of our desktop apps in Javascript within 5 years. Probably before then we'll have full server side support for Javascript as well...

Robert Gould
A: 

If you're looking to upgrade your skills as a coder rather than for practical project work then it's defiantly C, primarily so you can get some experience with pointers and recursion. PHP is all very well and good, but in all honesty you've only half learned to code until you've groked pointers to some reasonable depth. Smalltalk wouldn't be a bad idea either as it will force you to fully understand OOPS (Java could be substituted, but it comes with a lot of baggage).

I'm not suggesting you spend a lot of time with either of these - nowadays they are of less practical use, but they are defiantly worth learning for the skills they will give you. Moreover if you've failed with C++ before then learning C as a first step might give you a good run at that again.

Cruachan
A: 

Honestly, if you're good at PHP, I don't see any strong reason to switch to Python or Ruby. As scripting languages, all 3 occupy a similar niche, and anything you can do in any one of them is easily accomplished in one of the others with similar memory requirements and similar speed.

You'd be much better served learning a non-scripting language next since extra speed provide can be crucial in some situations. If you really can't stomach C or C++, give Java a shot.

Randy
+1  A: 

My advice would be for c#. I also started more or less programming with PHP and tried to learn more in my spare time, but I really hit paydirt with C#.

The syntax will look mostly familiar, with curly braces and similar operators. Superficial, yes, but this familiar look really helped me a getting started.

Sylverdrag
Or java. I agree. I switch back and forth and the only difference that I occasionally stumble on is the concatenation operator and prefixing php variables with $
rick
Same here. If I work too much on C# I tend to forget the $ sign too.
Sylverdrag
@Sylverdrag, one of the projects I'm working on now, uses c# on the client and PHP on the server and I'm constantly using $ where they shouldn't be and forgetting them where they should be.
Unkwntech
A: 

i feel the syntaxes of Perl are somewhat similar to PHP

Biranchi