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:I think this said it all... by RevAaron · · Score: 3, Insightful
    Speeds up development my arse.

    Heh. Does perl speed up development? Everytime I've tried to use it, I had to have multiple browser windows open for docs and other people's code, in an attempt to figure out what the hell it's goofy syntax stood for. The small script I ended up making kind-of worked- doing the same read, search-and-replace, and write back to file only works some of the time on some of the files- I try it on a different and directory and BAM it doesn't work!

    I'm not saying perl is completely flaky and useless- but contrary to Wall's silly assertions, perl isn't a language you can pickup gradually, there are simply too many rules and funny symbols ($/, @_, $_ anyone?) to learn just to do simple things.

    And why the hell can you only store scalars into hashes? Pffft! And don't tell me I can just use references to non-scalar data, as refs are scalar- if I wanted to deal with C's bullshit, I would.

    --

    Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
  2. Re:Why learn another language? by StrawberryFrog · · Score: 4, Insightful

    Great post, but IMHO any 3-year CS course that aims to teach only one language is going about things completely the wrong way.

    You should spend time in (for e.g.) a simple teaching language to start off, 1 mainstream procedural/OO language, one functional language, one scripting language and study briefly a sampling of languages of comercial or academic interest, and what makes them interesting or sucessfull.

    IMHO when you learn your second language is when you start to 'get it' about what is an essential feature, and what is an accident of syntax or history in programming.

    I wouldn't call knowing only 1 language a "the Computer Science Student mentality" because a CS graduate should definitely not know just one language - they should know how to pick up any language quickly, having had practice at it.

    --

    My Karma: ran over your Dogma
    StrawberryFrog

  3. Other languages teach other ways of thinking. by Futurepower(tm) · · Score: 3, Insightful


    In the second half of his post above, Dalroth has made a very sensible case in my opinion, for learning other languages.

    (Dalroth seems like the kind of programmer employers want to hire. But he has provided no way to contact him. In fact, he is very negative about being contacted in his bio.)

    I'm tired of new languages (read my post #128), but Dalroth has a point that other languages sometimes teach other ways of thinking.

    The answer seems to be to put all the knowledge in one place, or as few places as possible. At some point even Dalroth will decide that one more language is too many.

    --
    Bush's education improvements were
  4. Re:Strict languages vs. hacked languages by Hrunting · · Score: 3, Insightful

    Usually the latter turns out to be some baroque conglomeration of features piled on features, creating a very top heavy feeling to the language, while the former classification languages all have a purity to them, e.g. smalltalk, lisp, and c.

    Well, I mean, as long as we're talking in generalities here, the latter also seem to be geared towards getting jobs done where the former are geared towards elegant problem-solving. Purity is great when you're admiring something, but no one wants to hang out with the righteous virgin when they feel like getting laid. Personally, when I program, I'm not looking for my code to fit some elegant theory. I'm looking for the job to get done as succinctly as possible.

    Some would defend the "hack languages" as a means to Rapid Application Development, but Smalltalk has been shown to be the most productive language, and Ruby/Python/Perl all seem to me to have a BASIC odor to them; I'm wondering if people are afraid to learn a new way of speaking?

    I would say that Perl stinks more of shell and C than it does BASIC. If you're talking because it has a lot of built-in features, there are plenty of languages that have it. But out of all the languages you've mentioned, I found it ironic you say that because Perl has problem undergone the most intensive language development of any (and the new process probably blows efforts for other languages out of the water). Larry Wall has a great affinity for languages (both spoken and programming), and it shows, because, for English speakers, Perl is designed so that you can write it like you almost would speak it. Now, you might say that that is "hack"-ish, but that shows a lot more care for the process of programming than a language that idealistically sticks to a theoretical truth in favor of making the language easier to use.

    And provide a link to a study that shows Smalltalk is the most productive language. I'm not saying I don't believe you, but I personally find the "hack languages" to allow a much more natural flow between my brain and the screen, so I'd be interested in seeing how that conclusion was reached.

  5. Re:Strict languages vs. hacked languages by smallpaul · · Score: 3, Insightful
    I get the stronger sense that you don't know Ruby -- most Rubyists tend to be ex-Pythoners and not the other way around, but nevermind.

    People do tend to progress from more well-known languages to less well-known ones. They don't go to a bookstore and pick up a K book and think: "this would be a good first language." I've played with Ruby enough to decide that it is neat but not appropriate for many of my projects and not a sufficient improvement over Python for the rest.

    Python lacks metaclasses, lacks a true unified object hierarchy, and supports multiple inheritance (considered a very bad idea by most experts in OO. Like the "goto" statement, multiple inheritance may seem useful at times but it leads to unmaintainable code). All these are simple repeats of the mistakes of C++.

    Python 2.2 has metaclasses, a unified object hierarchy and supports multiple inheritance which is quite useful and safe when used thoughtfully.

    It is simply a matter of historical fact that Python was not based upon C++. If it shares features with C++, those would probably be traced back to Simula through Modula-3. Smalltalk is also based upon Simula.

    Yes, Python is improving, but all these improvements (like allowing the subclassing of primitives) only serve to point out flaws in the design (why aren't primitives normal objects in the first place?)

    Nobody would claim that Python 1.0 was perfect, nor that Python 2.2 is perfect. Nevertheless, you haven't yet mentioned a feature of Ruby that isn't in Python 2.2. There certainly are such features -- but they get increasingly esoteric as Python improves. If I have to choose between Bertrand Meyer-approved-OO-cleanliness and native threads that don't block when you do I/O, I would choose the solid threads. OO-cleanliness is about conceptual elegance and native threads are about getting the job done.

    And how deep is Ruby's Unicode support? If you can please point me to documentation on using Ruby's regexp engine to match Unicode characters, I would appreciate it.

    My current Python projects depend heavily on both threads and Unicode. Mixins, multiple inheritance and the ability subclass "integer" really don't matter one whit! I am mostly happy that Python is unifying its type system for rhetorical reasons. Practically it hardly matters at all!

    If you want to impress the vast majority of programmers who are not language collectors, you'll have to show us some program that are hard to solve in (e.g.) Python and easy to solve in Ruby.

    For this and other reasons, it is not accurate to paint Ruby as the next step after Python. It is another good language with strengths and weaknesses. One day it will have a superset of features that Python currently has...but Python will itself have evolved by then.

  6. Re:Why learn another language? by RevAaron · · Score: 3, Insightful

    That is, for the most part true, but there are languages that make it difficult and some that make it easy. For me, no matter how much I am forced to use it in school, C++ is still a lot harder to express ideas (especially well-designed OO ones) than some of the other languages I know. This is for a lot of reasons, from syntax to manual memory management. Now, it's not that what I want to do is impossible in C++, but there's a lot more crap I have to think about and deal with to get the same basic stuff done.

    --

    Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
  7. Re:Strict languages vs. hacked languages by Jonathan · · Score: 3, Insightful

    And how deep is Ruby's Unicode support? If you can please point me to documentation on using Ruby's regexp engine to match Unicode characters, I would appreciate it.

    Here you have an issue of implementation, not design, but at present a legitimate issue. Ruby is a product of Japan, and ironically, from the perspective of Westerners, who generally see Unicode as a sort of peace offering to Asians to make up for the dark ages of ASCII, the Japanese hate Unicode and prefer their own multibyte solution. So, the status of Unicode in Ruby is somewhat primitive at present. However, as Ruby was designed with multibyte characters in mind, it should be much easier to improve the Unicode support than in other languages.

  8. Time for an icon.... by jeffy124 · · Score: 3, Insightful

    I think it's time for Slashdot to draw up an icon for Ruby topics. This story is about the 5th maybe 6th Ruby related item to appear on /. in the past few months. A simple picture of a good red-ruby you would find in a jewelery store would do fine, such as one of these. Anyone for it? Against it? Got a better pic to use?

    --
    The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
  9. missing the point by mj6798 · · Score: 3, Insightful
    If Python was the result of Lisp and C++ having a baby, Ruby is the result of Perl and Smalltalk having a baby.

    The key features of Lisp are the use of a uniform notation for programs and data, a notation that makes it very easy to write syntactic extensions, and full support for functional programming. Python 2.1 now has some limited support for lexical closures, but users almost never extend its syntax. The key feature of Smalltalk is its programming environment. As a language, Smalltalk's main feature is the use of very descriptive method and argument names. Neither of those is shared by Ruby.

    Python, Perl, and Ruby are nifty little scripting languages, but don't think for a moment that if you are using them you are using the next generation of Lisp or Smalltalk. The object models of Python, Perl, and Ruby are general but slow and memory intensive, their programming environments are oriented towards scripting, not large system development, and compilation to native code, when it exists at all, is of limited benefit. If the scripting languages ever evolve into something like Lisp or Smalltalk, their object models, syntax, and semantics will have to change dramatically and incompatibly.

  10. Re:Strict languages vs. hacked languages by Peaker · · Score: 3, Insightful

    I agree Ruby and Perl seem to be like the latter type.
    Python, however, is a truly clean, well-designed, quite-pure, strong-typed language.
    I wouldn't say it has a Basic odor at all, besides for a built-in 'print', perhaps :)

    Basic is braindead and has no library - instead, it has its entire library built into its syntax in a horrid way.
    Python is the exact opposite - many many libraries separated into modular modules, with only flow constructs, OO organization, functions and exception handling built in.

  11. Re:Strict languages vs. hacked languages by FFFish · · Score: 3, Insightful

    FWIW, within a week you'll learn to love whitespace. Yes, it imposes a visual "order" to your code. You'll soon appreciate the consistency: you can look at other code and immediately make sense of it, without having to mentally adjust for the other programmer's weird habits.

    --

    --
    Don't like it? Respond with words, not karma.
  12. Re:word math by ConsumedByTV · · Score: 3, Insightful

    but is there anything wrong with making it a simpler operation?

    --


    "Not my manner of thinking but the manner of thinking of others has been the source of my unhappiness." - M
  13. Okay, it looks simple enough.. by jcr · · Score: 3, Insightful

    ..so, what does it offer over Python once you get past "Hello World" * 3?

    Is there anyone who can fill us in on why this language is worth using?

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."