PDA

View Full Version : Ruby or Python for beginners?



ThinkBuntu
October 26th, 2007, 09:04 PM
Just curious which one you guys think is the best for new programmers. I've dabbled in both, and I actually think that because Ruby has been heavily influenced by a variety of popular languages, the lessons one learns from it can be easily transferred. This especially has to do with the "rhythms" one learns (which I learned in JavaScript, for better or worse).

What do you think? I have the ox-stunner Python book by O'Reilly and a great Ruby book from a smaller publisher, and I'm thinking about selling/donating one. That being said, if there is any language I should be aggressively studying right now, it's PHP.

pmasiar
October 26th, 2007, 09:34 PM
Why PHP?

I prefer Python, IMHO Ruby is too close to Perl, not concerned about readability. Problem for beginners is, difference in readability is palpable only when you have couple thousands lines of code - and then, it is too late to switch.

That said, Python and Ruby are very close, and I would recommend the one which your local guru knows and prefers. If no gurus around, Python community is quite bigger than Ruby, and also more and better online books are available. Also, Python is preferred language for Ubuntu and OLPC.

ThinkBuntu
October 26th, 2007, 10:22 PM
This is purely for web programming, which is why PHP is a top priority. There's a ton of free PHP software available and it's probably the only widely-used language that will run on pretty much any host.

LaRoza
October 27th, 2007, 12:36 AM
This is purely for web programming, which is why PHP is a top priority. There's a ton of free PHP software available and it's probably the only widely-used language that will run on pretty much any host.

Don't worry, you'll hear a lot of arguments for Python over PHP, actually, I started a thread on it a while ago, and it popped up recently. The Ruby camp is also aggressive, leaving us (me, you et al) working with PHP and wondering why everyone can't get along.

You actually have the same opinion (that I quoted), but it is actually not as true as we thought. There are Python hosts, free too. Many that offer PHP offer Python.

That being stated, I prefer PHP for web programming. I can write readable, usable, and maintainable code AND not mix content (XHTML) with code (PHP).

I would look in Ruby and have done so, but I find Python to be the better choice for me. Ruby seems limited to Rails in general use, although it is a fine language.

Smygis
October 27th, 2007, 12:39 AM
This is purely for web programming, which is why PHP is a top priority. There's a ton of free PHP software available and it's probably the only widely-used language that will run on pretty much any host.

And that dosnt make a good language.

Many hosts are starting to pick up Python now when Python have some great frameworks for webb development. I say python.
And there you have my totaly subjective opinion. And thats the only thing everyone will ever give you on matters like this.

loell
October 27th, 2007, 12:39 AM
go with the snake not with the gem ;)

ThinkBuntu
October 27th, 2007, 12:59 AM
What's funny is that for the true "Horatio Alger" the best option will be PHP for some time. Although there are free Python providers, etc. the majority of the better low-cost or free hosts offer only PHP. If a site does well, it could run on a Lisp CGI if the developers so desired, but to get to that point, PHP is necessary. Do you see where I'm going with this?

LaRoza
October 27th, 2007, 01:01 AM
Do you see where I'm going with this?

Yes.

samjh
October 27th, 2007, 01:02 AM
Python is more readable. It actually uses normal English words instead of arcane brackets, squiggles, and other weird symbols. :p

LaRoza
October 27th, 2007, 01:07 AM
Python is more readable. It actually uses normal English words instead of arcane brackets, squiggles, and other weird symbols. :p

Duck! (slavik is coming)

Python is very readable, by its nature, but I am sure if we worked at it, we could make that disappear.

Smygis
October 27th, 2007, 01:20 AM
What's funny is that for the true "Horatio Alger" the best option will be PHP for some time. Although there are free Python providers, etc. the majority of the better low-cost or free hosts offer only PHP. If a site does well, it could run on a Lisp CGI if the developers so desired, but to get to that point, PHP is necessary. Do you see where I'm going with this?

Then why in all hevens and hells did you even bother starting this thread? You want a discussion about Python and Ruby. And then like go.
Meh, ill use PHP bi***es!

I cant see the point in that.

LaRoza
October 27th, 2007, 01:33 AM
I cant see the point in that.

The thread was not on web programming:



Just curious which one you guys think is the best for new programmers. I've dabbled in both, and I actually think that because Ruby has been heavily influenced by a variety of popular languages, the lessons one learns from it can be easily transferred. This especially has to do with the "rhythms" one learns (which I learned in JavaScript, for better or worse).


The OP said PHP would be used for web programming, that was the point. The thread was straying OT, don't push it over (like I am doing now...)

To get back OT, what do you think answers the OP's question? Python or Ruby?

Smygis
October 27th, 2007, 02:29 PM
The thread was not on web programming:



The OP said PHP would be used for web programming, that was the point. The thread was straying OT, don't push it over (like I am doing now...)

To get back OT, what do you think answers the OP's question? Python or Ruby?

The OP asked on the basis of being a newbe programmer. But if he learn PHP, he wont be a nebie anymore and the thread is entierly pointless. If he knows how to program PHP sorta ok he shuld be able to judge varius languages by himself and find the language who appeals most to his way of thinking.

ThinkBuntu
October 27th, 2007, 04:25 PM
I started this thread to see how people value the two, even against each other, as a tool for teaching computer programming. I think that Python teaches good habits, but that because Ruby has been influenced strongly by other languages, Ruby may teach skills and habits that are more portable.

I brought up PHP only because it's the Lingua Franca (language-wise) of the internet and web development these days, especially outside corporate.

Also, this discussion has nothing to do with which one I learn. I know the basics of both, and I will probably teach myself both over time.

LaRoza
October 27th, 2007, 05:18 PM
The OP asked on the basis of being a newbe programmer. But if he learn PHP, he wont be a nebie anymore and the thread is entierly pointless. If he knows how to program PHP sorta ok he shuld be able to judge varius languages by himself and find the language who appeals most to his way of thinking.

What do you think is better for a beginner, Ruby or Python? (Please stay OT)

Railsbuntu
October 27th, 2007, 05:19 PM
This is how I chose Ruby over Python: I tossed a coin :lolflag:

Honestly, the two languages are great. They have some differences, you won't be wrong by choosing one over the other.

I chose Ruby and I am pleased with it, no regrets, and because of the Ruby on Rails framework which I love. If one day I have time, I might "dive into python" and give a try at Django, but not for now.

First I started with PHP, and when I learned OOP in PHP,I figured out something was wrong! So I quickly switched to Ruby before unrecoverable damage would be done to my brain. PHP is so ugly... :mad:

LaRoza
October 27th, 2007, 05:24 PM
This is how I chose Ruby over Python: I tossed a coin

Honestly, the two languages are great. They have some differences, you won't be wrong by choosing one over the other.

First I started with PHP, and when I learned OOP in PHP,I figured out something was wrong! So I quickly switched to Ruby before unrecoverable damage would be done to my brain. PHP is so ugly... :mad:

Very true.

I started with PHP (for web programming), and did learn the OO in PHP5, but after I learned PHP4 and Java. PHP's OO looks like a nice version of Java's, so I didn't feel repelled by it. Of course, Ruby and Python have OO much better, because they were designed that way. PHP can be clean, if you write it that way. It is very easy to write Perl (no offense) in PHP, but you can do Python too.

pmasiar
October 28th, 2007, 01:54 AM
If a site does well, it could run on a Lisp CGI if the developers so desired, but to get to that point, PHP is necessary. Do you see where I'm going with this?

No I do not see it. PHP is used often by amateurs. Ie Google uses only C++, Java and Python ("Python is we can, C++ if we have to") YouTube was in Python. So PHP is not the only language to start with, as you misleadingly mentioned.

LaRoza
October 28th, 2007, 02:02 AM
PHP is used often by amateurs.

Python is often used by Beginners.

We are not google, and I know of successful companies that use C# exclusively, so standards of other companies are not standard for everyone.

pmasiar
October 29th, 2007, 02:52 PM
Python is often used by Beginners.

Yes, I know: but difference is, Python beginners first learn to program in Python, and **then** start writing web application, while PHP beginners do it in opposite order. :-)

It is **too easy** to create web pages in PHP without actually having a clue what you are doing, and many people do just right that.

ankursethi
October 29th, 2007, 03:09 PM
I've *seen* complete idiots program in PHP. They can wreak havok. I myself have written PHP code some time back that was utter crap, and blew up right in my face at the end. PHP, by design, encourages hacks. It was built not for the "beginner" (a person who is new to the field of programming and wants to learn good practices) but for "n00bs" (a person who is new to the field of programming yet thinks he is the greatest programmer of all time and can safely choose to ignore all suggestions that anybody has to offer).

This comment is not meant for the OP, though. I can see you are proficient with programming. That was a generalization. There are very good PHP programmers out there, but they mostly got there by writing C/C++/Perl/Python/Ruby code.

Python bring higher level data types from Perl, Tcl, Lisp etc. to the table, but with a strict, cleaned up syntax. It incorporates the best from all fields of programming. Ruby does the same, but seems to build up on a Perl-like syntax rather than defining something new. So both of them are very similar.

For a beginner, Python will probably be a tiny bit better than Ruby. Well, that's my POV.

Railsbuntu
October 29th, 2007, 04:40 PM
The danger of PHP is that any idiot can **** code that apparently works. Badly coded php websites can dangerously backfire.

I laugh when I see php based website being hacked. I don't consider that the pirate is an *******, I consider that the self-proclaimed webmaster is an idiot and doesn't know anything about coding, and that the pirate was kind enough to show us the incompetency of the webmaster.

Regards,
:guitar:

dataw0lf
October 29th, 2007, 04:55 PM
I laugh when I see php based website being hacked. I don't consider that the pirate is an *******, I consider that the self-proclaimed webmaster is an idiot and doesn't know anything about coding, and that the pirate was kind enough to show us the incompetency of the webmaster.


I agree, to an extent. PHP encourages bad programming paradigms, and since it's extremely attractive to newbie programmers, they tend to pick these up and reflect them in their code. Not to say PHP can't produce well engineered applications, experienced engineers can do this; but, in all reality, as a senior application security engineer for a top security firm, I must admit that the easiest applications my pentesting teams attack are PHP web apps, mostly due to naiviety on the PHP developers' part.

I would never suggest PHP as a beginning programming language. Go Python. Lisp. Smalltalk. Ruby (even though I'm not that much of a fan). Even JavaScript. But please don't learn PHP as a first programming language.

Of course, you'll keep me in a job, so, the hell with it, learn PHP first.

:)

dataw0lf
October 29th, 2007, 04:58 PM
And of course I didn't read the OP's original message.

I'd suggest doing the Python / Django thing just because, well, it's Python. RoR is ok, but I'm personally not much of a fan of Ruby, just it's framework. Ruby's semantics derive quite a bit from Perl, and Smalltalk too. Python has the advantage of looking like you didn't bang your head against your keyboard ten times to produce code (ok, Ruby isn't nearly as bad as Perl - but it still holds true to the WTMWTDOT principle (way too many ways to do one thing)) ;-)

ThinkBuntu
October 29th, 2007, 05:47 PM
No I do not see it. PHP is used often by amateurs. Ie Google uses only C++, Java and Python ("Python is we can, C++ if we have to") YouTube was in Python. So PHP is not the only language to start with, as you misleadingly mentioned.
Nope, you don't. What I'm saying is that new and under-funded projects are just about stuck with PHP (largest pool of hosts and developers, rapid development, forgiving language). When they're successful, they may wish they'd written in another language to begin, but they're stuck. It's an interesting conundrum when you think about it.

Wybiral
October 29th, 2007, 05:56 PM
Nope, you don't. What I'm saying is that new and under-funded projects are just about stuck with PHP (largest pool of hosts and developers, rapid development, forgiving language). When they're successful, they may wish they'd written in another language to begin, but they're stuck. It's an interesting conundrum when you think about it.

Why can't they use Python again? There are Python hosts, btw, and plenty of Python developers. PHP isn't forgiving, it's just better at hiding your mistakes :)

dataw0lf
October 29th, 2007, 05:58 PM
Nope, you don't. What I'm saying is that new and under-funded projects are just about stuck with PHP (largest pool of hosts and developers, rapid development, forgiving language). When they're successful, they may wish they'd written in another language to begin, but they're stuck. It's an interesting conundrum when you think about it.

PHP is _NOT_ a forgiving language, whether security-wise, paradigm-wise, or structure-wise.

Still, you make a point. PHP is readily available to the less technically inclined (shared hosts that are easy to use, where the only interface is a web control panel and an ftp service). And writing web applications usually has a higher payoff earlier in the game for beginners. So I suppose that's a large reason why PHP programmers write bad code, besides the fact that PHP encourages it to a large extent.

ThinkBuntu
October 29th, 2007, 06:00 PM
Why can't they use Python again? There are Python hosts, btw, and plenty of Python developers. PHP isn't forgiving, it's just better at hiding your mistakes :)
Stricter enforcement of best practices makes a language less forgiving, especially for new programmers (to the language and to the trade) in my opinion. Python is more forgiving than Java too.

juozasg
June 6th, 2009, 04:30 AM
I would recommend ruby for beginners just because of this sweet little book: http://pine.fm/LearnToProgram/

I have been playing with ruby for many years and recently got a paid job to do Ruby on Rails programming, but Ruby definitely is not just about about Rails, I've done game scripting, system scripting and even GUI apps with GTK+ for Linux and Windows.

IMO the best advantage Ruby has over Python is cleaner and more consistent Object Oriented organization. Ruby makes building OO programs less burdensome than any other language I know - this is a very good thing for a beginner.

After becoming proficient with Ruby, you should be able to write cleaner and better PHP than someone who has learned PHP first (unless they have been doing PHP for many years)

Python is somewhat better performing (faster, less memory) and has a larger developer base (more libraries, probably more people able to help out). Some people think it's more readable, but I don't agree. It's true that Python uses fewer noisy characters like |?!}{, but it only takes few weeks before you stop noticing them in Ruby.

Ruby has its Perl heritage, but it's strictly optional - most ruby code I've seen stays pretty clean.

You will have to use few special symbols: @, @@ and $ when defining your variables, but it won't make your programs hard to read.

):P