I have wondered whether I should learn ruby or python hence they are
both pretty common languages and both look pretty much alike except for
some differences like blocks and how the structure of ruby is.
I was faced with the same decision a few years ago. The reason I chose
Ruby over Python was that I found it just a bit more mature and elegant.
For example, object orientation in Ruby is very consistent and clear:
Every value is an object, almost everything is done using methods. In
Python, it seems rather bolted on (no implicit âselfâ, heavy use of
global functions). I also donât like the concept of significant
whitespace at all, since it makes the syntax rather âfragileâ in my
opinion. I do appreciate well formatted code, but I donât want to
struggle with spaces and tabs just because the interpreter forces me to.
On Tue, Jun 12, 2012 at 02:17:49AM +0900, Kasper S. wrote:
I have wondered whether I should learn ruby or python hence they are
both pretty common languages and both look pretty much alike except for
some differences like blocks and how the structure of ruby is.
So what arguments are there for learning ruby?
Itâs largely a matter of taste, though I know some Pythonistas who would
disagree and start saying bad things about Ruby. This leads to the
first
of a few matters of taste that apply in my case:
I like the Ruby community more.
I find that Python is unnecessarily confining in terms of what it
allows the programmer to do. I feel like Ruby sets me free to achieve
what I want, the way I want to achieve it.
As of version 1.9.3, I like Rubyâs license terms more (dual-licensed
under the Ruby License and a BSD License, the latter of which is quite a
nice little license).
The books on the market for Ruby are, in my opinion, generally more
enjoyable and useful for advancing my skills as a Rubyist.
Pythonâs syntax kinda annoys the crap out of me, but maybe thatâs
just
me. One case in particular is the way Python defaults to a style that
leaves blocks of code looking unfinished to me, in large part because
multi-expression or multi-statement blocks have no ending delimiter.
I have wondered whether I should learn ruby or python hence they are
both pretty common languages and both look pretty much alike except for
some differences like blocks and how the structure of ruby is.
The books on the market for Ruby are, in my opinion, generally more
enjoyable and useful for advancing my skills as a Rubyist.
Although on the flip side, Pythonâs official web documentation is 100
times better than Rubyâs. All the semantics are documented, every single
change to the language is documented.
My other pet peeve with ruby is the ludicrous way that Strings are
handled in 1.9. Python 3âs approach is clear, precisely defined, and
symmetrical.
Pythonâs syntax kinda annoys the crap out of me, but maybe thatâs
just
me. One case in particular is the way Python defaults to a style that
leaves blocks of code looking unfinished to me, in large part because
multi-expression or multi-statement blocks have no ending delimiter.
I can live with that, especially after having used HAML.
What I find annoying about Python is that methods are function values,
and you have to remember to use () to call them. But this means you have
to know whether an attribute is a direct value, or is an accessor method
which returns the value you want.
e.g. is it str.len or str.len() ?
Answer: neither, itâs len(str). But thatâs actually a shortcut for
str.len()
That would be simple enough, except that some objects can have
âpropertiesâ which you access as if they were values, but are actually
calling methods under the surface:
import random
class Foo(object):
def __random(self):
return random.random()
x = property(__random)
a = Foo()
print a.x
print a.x
So thereâs no consistency. With Ruby everything on an object is a
method, and itâs called automatically whether you use () or not.
Instance variables are hidden.
I have wondered whether I should learn ruby or python hence they are
both pretty common languages and both look pretty much alike except for
some differences like blocks and how the structure of ruby is.
So what arguments are there for learning ruby?
Thanks
Hi,
I think if you just want to learn a scripting language, Ruby is nice.
However, if you are more toward âscientific computingâ, I think Python
has better libraries. Also, if you are more toward web, I think you
should also consider JavaScript.
For someone with no programming experience, I would recommend learning
JavaScript. It doesnât have much to offer, except it is ubiquitous and
will
allow you to quickly start playing with things that you can see tangible
results. For Ruby or Python, it will take quite a bit longer before you
have anything beyond mind castles.
Of course, if youâre satisfied with mind castles, then Iâd choose Ruby.
Mostly because I canât think of anything that Python has to offer except
simplicity for beginners. But Ruby is so much more expressive and
powerful
because of its syntax and support for many different paradigms, each
with
their own strengths(disclaimer: my python experience is quite limited).
Python might make a better language for a total beginner, though,
because
it is considerably simpler than Ruby since it tries to have only one
obviously correct way to solve a problem, whereas Ruby gives you lots of
tools to choose the best solution for the problem.
Also, donât neglect that there are many viable languages to choose from,
depending on your criteria. And, of course, youâre asking this on a Ruby
forum, so obviously these answers will have a certain bias that you
should
consider mitigating by querying enthusiasts of alternative languages.
On Wed, Jun 13, 2012 at 12:18:32PM +0900, Josh C. wrote:
For someone with no programming experience, I would recommend learning
JavaScript. It doesnât have much to offer, except it is ubiquitous and will
allow you to quickly start playing with things that you can see tangible
results. For Ruby or Python, it will take quite a bit longer before you
have anything beyond mind castles.
I disagree. The languages I have had the best luck picking up quickly
were those that were best suited to creating command line utilities that
automate common tasks. With some basic understanding of array handling,
regular expressions, command line argument parsing, and file reading and
writing, whole worlds of such automation possibilities open up.
Isnât that array handling, regular expressions, command line argument
parsing, and file reading and writing also covered in JavaScript and in
scripting languages in general?
Well, standard JavaScript only runs in the browser and doesnât have
access to the file system or the command line. Youâd have to use
something like Node.js (server side JavaScript).
This is also the reason why I donât find JavaScript a good choice for
learning: It doesnât run on its own, itâs limited to editing HTML, and
it requires some previous knowledge.
I disagree. The languages I have had the best luck picking up quickly
were those that were best suited to creating command line utilities that
automate common tasks. With some basic understanding of array handling,
regular expressions, command line argument parsing, and file reading and
writing, whole worlds of such automation possibilities open up.
Hi,
Isnât that array handling, regular expressions, command line argument
parsing, and file reading and writing also covered in JavaScript and in
scripting languages in general?
learning: It doesnât run on its own, itâs limited to editing HTML, and
it requires some previous knowledge.
I agree. JavaScript is not a great learning language because the runtime
enviroment (i.e. the browser, usually) makes error handling, debugging
and experimentation difficult. When you are starting you are going to
make a bunch of errors in the code and syntax, and will want to play
with how things work. In the browser you donât see errors (normally),
and it is painful to do things like inspect what is happening (alert
boxes everywhere?).
Hi,
With Ruby, you have to install it in the system. With JavaScript, it is
available automatically on most browsers. If you need access to the
file system or the command line, you can install JSDB (or Node.js as has
been pointed out), but it is the same effort as installing Ruby, isnât
it?
Regarding the runtime environment, have you tried Google Apps Scripts?
It is server-side JavaScript and it has some (maybe not the greatest)
debugger. At least one great thing about it is you can run it anywhere
where there is an Internet connection and a (appropriate) browser; no
installation is needed.
learning: It doesnât run on its own, itâs limited to editing HTML, and
it requires some previous knowledge.
I agree. JavaScript is not a great learning language because the runtime
enviroment (i.e. the browser, usually) makes error handling, debugging
and experimentation difficult. When you are starting you are going to
make a bunch of errors in the code and syntax, and will want to play
with how things work. In the browser you donât see errors (normally),
and it is painful to do things like inspect what is happening (alert
boxes everywhere?).
With Ruby (and other command-line languages) youâll get meaningful
errors, you can debug and single step your code easily, you can throw in
some pp or puts statements as needed, and you get the super-useful irb
to be able to play with statements and inspect the state of the
environment.
If you do learn using JavaScript, get a good browser debugger such as
Firebug.
I taught myself the basics with Ruby before I started college. For me
one of the best things about Ruby is the way in which concepts that
might be considered more advanced in other languages are run of the
mill in Ruby. More specifically Rubyâs collection handling mechanisms
and the way that blocks work make the concepts very easy to grasp.
Ruby makes working with collections in a non-imperative fashion very
easy without having to go into some Lisp dialect which while
fascinating is very weird, especially when coming from most other C
derivative languages. I have been very pleased with âProgramming Rubyâ
the explanations are generally very clear and easy to understand even
if you are just starting out programming.
Iâve also found that the concepts presented right up front in Ruby
have applications with languages like C# as C# takes on more and more
functionality that Ruby has already built in to it.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.