Slashdot Mirror


Programming in the Ruby Language

ShoeHorn writes: "Here is a good article (1st of a 4 part series), that introduces you to the Ruby language. If you are currently a programmer coming from the likes of C++, Perl, or Python, you will see some strong similarities (especially to Python)."

13 of 345 comments (clear)

  1. Re:word math by _Stryker · · Score: 2, Informative

    It could have some interesting uses. How about this (in pseudocode since I don't know Ruby):

    $indent = "....";
    ...
    print $indent * $current_indent_level;
    print $indented_text;

  2. Re:so many choices by Waffle+Iron · · Score: 2, Informative
    I'm just learning python now. There just aren't enough hours in the day for me to learn all of these languages.

    Then learn Ruby. Python looks clean to the untrained eye, but you have to remember lots and lots of special cases because of the arbitrary mixture of object-oriented and procedural features.

    Ruby is extremely consistent and well thought out. I've used well over a dozen languages, and Ruby is my favorite by far.

  3. Re:Performance, gentlmen (and ladies)? by sakti · · Score: 2, Informative

    The Great Computer Language Shootout is what you are looking for...

    --
    "It is better to die on one's feet than to live on one's knees." - Albert Camus
  4. As the guy who wrote the article. by poet · · Score: 5, Informative

    It is important not to judge Ruby on this article.
    The content in the article is specifically designed to look like either Perl or Python. This was to generate a similarity that programmers from other languages can understand.

    The second one, article in the series looks a lot less like Perl and more like Python. This is due to Ruby being a true OO, very similar to Python.

    The third article will (if they let me write it) cover advanced Ruby structures and illustrate them by interfacing with the PostgreSQL database.

    The fourth article will cover Ruby/Qt.

    If you guys want to see these articles you may want to give some decent feedback on the Developer Works site.

    --
    Get your PostgreSQL here: http://www.commandprompt.com/
  5. Re:missing the point by mj6798 · · Score: 2, Informative
    I nominate you for the "Sweeping Statements Award." I especially like the way you say "The object models of Python, Perl, and Ruby."

    Maybe you haven't noticed, but Python, Perl, and Ruby all represent objects as general purpose dictionary types, in contrast to the Lisp and Smalltalk approaches.

    Beyond that, I have no idea what you railing against. Did I say scripting languages were bad? Did I say people should switch to Lisp? What is your problem?

  6. You forgot by Tim+Ward · · Score: 2, Informative

    SQL

  7. Re:Java has won *nothing* by auntfloyd · · Score: 3, Informative

    Because it is not Open Source, it is highly unportable (just try running Java on OpenBSD sometime!)

    Ok. On a just-installed machine (complete with generic kernel, yes I know):

    (rob@denali:~)$ uname -a
    OpenBSD denali.CENSORED.com 2.9 GENERIC#653 i386
    (rob@denali:~)$ java -version
    java version "1.4.0-beta"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
    Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)


    That's OpenBSD 2.9 running the latest JDK 1.4 beta. What were you saying again?

    You also seem to be confusing Java (the platform) with Sun's version of Java. Open Source editions (eg Kaffe can run on just about anything. Not to mention that you can get the sources to Sun's JDK.

  8. The Pragmatic Programmers Ruby Book is Online by swagr · · Score: 4, Informative

    here.

    --

    -... --- .-. . -.. ..--..
  9. Re:Java has won *nothing* by RevAaron · · Score: 3, Informative
    Some stupidities though -- the whole notion of making variable types case-sensitive reeks of Fortran.

    That's because they're not types, they're classes. And why does that matter? Because all you reference a class by it's name- as a VARIABLE. If all Ruby variables were case-insensitive, then classes, or types as you refer to them, would also be case-insensitive.

    It's simple, beautifful elegance. This is unlike other languages, where types and/or classes are an exception, aren't normal variables. There lie's power in Ruby's approach.

    --

    Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
  10. Re:Lots o' languages by tEbIng · · Score: 2, Informative

    This thread on the python-dev mailing list talks about the unification project (code-named "Parrot" :)

    http://mail.python.org/pipermail/python-dev/2001 -J uly/016406.html

    There was also a thread on comp.lang.python about it:

    http://groups.google.com/groups?hl=en&safe=off &th= d5fb029bd99759bc,43&seekm=X2Jb7.24637%24C7.967 1673 %40e3500-chi1.usenetserver.com

  11. Re:Why worry about importing IT workers, by jeffy124 · · Score: 3, Informative
    and for the MS route
    [...]
    (Java/no other language is as useless to compete with Java)

    I think you're under the false impression that Java was written by Microsoft. You also probably don't use java for anything hence feel it's unnecessary. If you want a good, easy to maintain and robust app on multiple platforms then use java, but if you need that app ready to go into production quickly, then java is not your best choice, scripting languages like Perl are. I havent learned Python as of yet, but based on what I'm told, it's good for getting an app done quickly.

    --
    The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
  12. Yes, there is DB access by JimWeirich · · Score: 4, Informative

    There is a DBI module at http://www.ruby-projects.org/dbi/ . There are also a number of DB specific modules. See the Ruby Application Archive ( http://www.ruby-lang.org/en/raa.html ) for a list of other software modules that are available for Ruby.

    --
    -- Jim Weirich
  13. Why learn another language? by Dalroth · · Score: 5, Informative

    Well, I see a lot of people complaining as usual... Why should they learn another language? So I thought I would throw in my $0.02 for all a languages (not just Ruby, which I am particularly fond of).

    A lot of you people come from what I call the Computer Science Student mentality. This unfortunately something I've noticed as a side effect of the way computer science is taught in most schools. It's quite unfortunate, because that clearly isn't the aim of the Professor's when they are teaching classes this way.

    I'll use my school as an example. When I started at the University of Dayton, about 7 years ago, every class was taught in ADA. It was a horrible horrible expierence. The ADA compilers were horribly lacking at the time, and anybody who has done any work in ADA will know that it is an extremely strict and picky language. That has it's good and bad sides when it comes to teaching programming, but I'll save that for a different discussion. I had no problems, since, well, I had a good solid 4 years for Pascal and C/C++ programming experience before I even started college, but this seriously affected the other students in my class.

    The problem was, about two years into the program, my school decided (thank god) to switch the department over to C++. This was a great move, because now the students were being taught a language that they could actually apply in the real world (beyond the confines of the Wright Patterson Air Force base anyway). It worked out quite well for the newer students, but my classmates were blindsided. Most of them suffered through half a semester of C (the other half of the semester was 360 assembler) and never even touched upon C++. They should have just been able to pick up a C++ book, apply the concepts they learned from their ADA classes and the syntax from the C++ book and their C course and move on, but most of them had a hard time doing it.

    Why was that? They all knew the concepts. They all knew how to write their algorithms, and their trees, and their stacks and queues. Yeah, they weren't taught how to write real software, but they clearly knew the basics. I spent more time helping others learn these concepts than I did doing my own homework the first two years, so I know what they were capable of from first hand experience.

    The problem was entirely in their minds. C++ is a huge ugly beast, and it is a bit imposing when you first start. But if you've got two solid years of programming behind you, it should be a relatively smooth and easy transition. Most of them didn't realize this though. They were scared of C++, they were scared of new languages, and they suffered as a result.

    The simple fact of the matter is, if you know one language, you know them all. It's not the syntax that makes the difference, it's the concepts that you express within the framework of the language's syntax that are the real guts of programming. My classmates took awhile to realize this (and I'm sure many of them still don't). That's the same thing with Ruby, or Python, or Perl, or just about any language. Unless you are making the jump from procedural to OOP, or OOP to Functional for the first time, you *CAN* pick up a book and learn a new language in a days time. The only thing stopping you is yourself.

    Now, the other part of this is, why would you do that? I love learning new languages, and I love learning new languages for a few reasons. These reasons apply to every programmer, and I honestly don't understand why some people are so opposed to learning something new. I guess that's what seperates a good programmer from a bad programmer. So if you want to know why you should learn Ruby, or LISP, or Haskell, or even Visual Basic, I'll tell you why.

    1. It helps keep your skills in tip top shape. Perusing a computer manual may remind you of algorithms or techniques you haven't used in a long time and forgotten.

    2. You always seem to learn something new. Not some new technical trick that only works in one lanuage (although that definitely happens), but just a different way of approaching problems that sometimes can transcend language boundaries.

    3. You may find a new language that allows you to get the job done faster!

    4. You're enhanced knowlege of languages looks great on your resume no matter what you use as your primary language.

    5. You learn the way other people think. And I don't want to gloss over this one. As a programmer, you frequently have to work with other programmers. Learning new languages is a *GREAT* way to see how other people do things. To learn the way other people think, so to speak. By learning Ruby and Smalltalk, you start to learn why people in those communities are so die hard about OOP programming styles. By learning LISP or Haskell you start to learn why Functional styles even exist! And it all comes back full circle. Techniques I learned from Haskell I now use when writing C++ programs and vice versa. It only made my C++ code better.

    Knowlege is power, and learning new languages is one (of many) ways of increasing your knowlege. Go ahead and try it, even if you think you won't use the language, and even if you're just starting out and don't think the transition from your learning language to a new one will be easy. You just might be surprised by how much you already know, and how much you have yet to learn. That's the real benefit of it.