View Full Version : Ruby programming language

02-11-2008, 05:29 PM
I am learning Ruby language. I think C programming is much harder. Ruby is more like Perl

02-11-2008, 05:40 PM
It's a bit like cooking - if you buy a ready-mix, you don't need to know quite so much, but you still need to know a bit. Higher level languages are the ready-mix of programming. There's nothing wrong with that - if you can achieve what you want in a few lines of Perl or Ruby, and it performs the task quickly enough to provide you with reasonable performance - fine. I've written web-programs in PHP, which is another similar high-level language.

C is more complex, because the language itself is more powerful - it's the raw ingredients, so you need to know what you are doing mixing eggs with flour and milk to make pancake mix - and if you get it wrong, you get lumps and too thick mix, and the pancakes are awful. Sure you can get it wrong with the ready-mix too, but it's a bit easier to get it right because there are fewer components involved.

With assembler, you're grinding your own flour and hatching your own chickens ... :)


02-11-2008, 06:41 PM
Ruby rocks. Probably my favorite language. But, it has it's place, and in the world of speed requirements, it doesn't do too well.

As an example, last year I wrote a Ruby script to read some large files and convert them from one encoding to another. It took 21 minutes to process the 136MB file with Ruby. It worked great, but it was too slow for the client. I wrote a C++ app to do the same thing and was able to get the processing time down to 10 second for the same file.

But, it's a great language.

Mario F.
02-11-2008, 07:30 PM
It is also an excellent learning tool for a different programming paradigm. Much more accessible to the masses than smalltalk, perl or lisp, IMHO.

Frankly I'm surprised as how this language evolved in such short time. If I remember correctly, it was rudely criticized by many when of its inception.

EDIT: BTW, this should be on some other forum. Maybe Tech or GD

02-11-2008, 10:25 PM
For the most part it isn't that bad of a language. The metaprogramming is quite nice as a feature and in certain instances invaluable. Probably one of the more interesting things IMO.

(If you're interested in a language with similar amounts of dynamism, I cannot point you anywhere other than Io (http://iolanguage.com). Prototype-based objects, message based like smalltalk, differential inheritance, portable, extremely dynamic, and a lot of fun to play with. Unfortunately, it hasn't had a stable release yet so bugs are prone and you probably shouldn't write your next major commercial app since things are bound to change, but I absolutely recommend it for experimenting.)

The major gripe I have with ruby is that the current implementation sucks in relation to speed. And I mean it really sucks. Speed is in almost every other case a negligible thing as far as I'm concerned, but a lot of pure ruby code really just performs poorly and there's no way around it other than using modules that're already written in C (which is a valid way to cut runtime by half in certain instances, don't get me wrong.) I am extremely happy with my mail client, Sup (http://sup.rubyforge.org), but as a pure-ruby app, it really performs poorly on large volume mailing lists it's stated to handle well (see: linux-kernel mailing list.) I wouldn't give it up for an alternative though, because it seems to have really gotten threading and management of threads right.

In any case, having such massive slowdowns in some instances is nothing but annoying and makes me think less of the language when the major implementation performs so badly (if you want an idea, albeit the benchmarks are somewhat flawed, look here (http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=all). Ruby is next to last, trumped only by prolog (for gods sake, javascript has had some of the WORST implementations of any language, ever, and it's beating it.))

I am thoroughly happy for Rubyists everywhere though, since Ruby 1.9 will sport bytecode compilation and that should speed things up drastically (in certain places up to 70% increases from what I've heard.)

In fact, the main reason I really don't use Ruby is because I really like my static types. A lot. The only other major dynamically-typed language I would say I like and really use is Perl. After 1.9 has made an official release and gained some ground, I'll definitely have to take a look again. Until then, check please.

Big edit: and after reading Rails is a Ghetto (http://www.zedshaw.com/rants/rails_is_a_ghetto.html) after it's initial publication (which I suggest you read if you haven't, it's a very good article,) I have to say it put a major distaste in my mouth for Ruby in general when even a fragment of the community - the Rails one - can act such a way. Will I never ever write ruby because of it? Probably not, but it certainly taints the 'ruby shine' if nothing else.