Skip to content | Skip to navigation
Hi there,
before I just start out and shift information together which I afterwards have to dump nearly entirely, I'd want to know how to best start into Ruby (and Ruby on Rails, too). I know there are at least two NAOis already working with this programming language: Jaz and Majic, so maybe you could give me some good advices what to read (online tutorials, FAQs, manuals, printed stuff, etc.) and what to avoid (awful written tuts, crappy printed introductions, etc.). :)
Reason for me to learn Ruby:
#1: I simply want to learn another programming language which is a bit more reaching out to different platforms and ways to use it than PHP or other mainly web-based stuff I'm used to code with.
#2: I want to code specific programs for myself which I possibly would want to share with others, which a) are not so platform-specific, so I could use them both on Windows and Linux and b) of course do fit my very specific needs.
#3: And of course it always looks good if you can show the world you're not only working with web-applications and scripts. :D
Thanks in advance,
cu, w0lf.
Multiple exclamation marks are a sure sign for a diseased mind!
Well I was reading and using as a reference the pickaxe book.
http://whytheluckystiff.net/ruby/pickaxe/
The Ruby language is amazingly easy to understand and learn. I was doing stuff with it almost immediately, stuff that I never dreamed of doing. Once I got a grasp of the language constructs I moved onto playing with it's C interface so I could extend it in order to allow me to write X Windows code in Ruby. It couldn't have been any easier and Ruby is well documented.
I've been messing with Ruby on Rails off and on for a few months. I would say that the rubyonrails.org website has all the most important information. You can find other stuff on google that people are blogging about.
Maybe we can get a nice Ruby / Ruby on Rails thread going.
There is the classic Why's (Poignant) Guide to Ruby. It's from the author who also wrote the tutorial that Frank suggested, but this one has cartoon foxes.
'Yeah, That's what Jesus would do. Jesus would bomb Afghanistan. Yeah.' - snowlion
The articles I've read say that Ruby was built with OO concepts in mind. (Hence the @@ var declarations etc)
However, in Python, Perl, PHP, etc. OO concepts were kind of an add on at the end.
My acquintence with all these languages is purely academic, so I might be wrong.
Please contiune to vote AND post.
To the best of my knowlegde, Python has always been OO. So much so that functions, classes, strings, methods are objects. To show you just how OO Python is have a look at some output from a Python interpreter.
goldenmyst:(~)$ python
Python 2.4.1 (#1, Sep 11 2005, 16:25:35)
[GCC 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> number = 7
>>> string = "boy"
>>> def print_name(str):
... print "str"
...
>>> class aClass(object):
... pass
...
>>> dir(number)
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__str__', '__sub__', '__truediv__', '__xor__']
>>> dir(string)
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> dir(print_name)
['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get__', '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name']
>>> dir(aClass)
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__']
Once again, every type in Python is an object, even functions! Please, if anyone tells you Ruby is more OO than Python is, tell them it is not true.
Having said that, Ruby and Python are great languages worth exploring.
And I guess it doesn't really matter how OO a language is.
...and thanks for being "the voice of reason" Majic.
It's ultimately your decision one way or the other. If full OO support is what your after there are solutions, if partial OO support is what you need there are options. I don't think there is any shortage of language options at the arsenal of programmers.
Having said that, Ruby and Python are great languages worth exploring.
Yes indeed and both are object oriented to whatever extent. I think it's silly to preach about how OO a language is, just use the darn thing for whatever you need it for and be happy.
Nobody is trying to sell one language over another and in todays programming society languages are mostly a personal preference. There are so many tools at the disposal of programmers that it matters not which you choose, it only matters that you choose something you like that can do the task you need. The realm of general purpose object oriented languages is pretty diverse these days. Whether they are fully OO or partially OO is an aspect that isn't worth wasting time over.
The most important question is: Does it matter? Being OO or being mostly OO is probably good enough for most people. How many people do you find that are really using multiple inheritance in C++ for example. How many people ever use 100% of a languages feature set.
Whether Ruby or Python, we all know they can get the job done in one form or another.