From: Peter Hickman Date: 2002-05-13T20:09:48+09:00 Subject: Re: What is Ruby for? Steve Merrick wrote: >Or even 'Why '? I know it's me >that's ignorant. I'm hoping this forum can change that! ;-) Allowing for >my background in C++/C/Assembler/Pascal/Fortran..., can you help me to >understand what languages like Ruby are for? > First ask yourself 'What are languages like C++/C/Assembler/Pascal/Fortran for?' and then we can start. Ruby is a programming language in the same class as all the others, the scripting / glue metaphore is an indication that it can be a great deal easier to glue existing programs together rather than rewrite the functionallity. For example we have need to do some SGML parsing and the best tool we have is nsgmls (not the greatest of names) so in our programs we just call nsgmls, grab the results and carry on. I'm sure you could do it in any of the other languages you mentioned but in perl for example (a somewhat popular scripting language) $x = `nsgmls fred.sgml` will call the sgml parser and return all the results back into $x. No allocating buffers or whatnot or checking what malloc returns. That was the code, there are of course some tradeoffs. Ruby like Perl will eat more of your system to acheive the results than some handcrafted assembler but unless you are a very good programmer you can generally get something knocked up in a scripting language much quicker than than in a more traditional language. > >Surely they're not just better versions of the 'language' used for >writing MSDOS batch files? [No offence intended. ;-)] I know what to use >C++ for, but I can't visualise a situation where I would look at the >design problem and think 'No, not C++ - Ruby is what I should use here.' > Use Ruby to get something knocked together quickly and if it's not fast enough then look to code it in C++. Try using Ruby where you would use C++ and see what is easier or harder to do. > >I've tried to learn Ruby, and made some very basic progress, but I'm >stuck in a mental rut. I can't think of what to use it for, so I can't >see the point in learning any more about it. Help!! :-) > When I learn a new language I try to use it for everything to get the experience, I get paid to code Perl and I use C a bit but so far everything I want to do I can do in Ruby (Expert Systems, Genetic Algorithmns, Alife, Music composition and Mathematics). You can do everything in assembler so why do you use C++? The answer to that question is why people use Ruby.