Ruby Off the Rails
An anonymous reader writes "IBM DeveloperWorks has an interesting writeup on Ruby that takes a look at the programming language as a stand-alone solution rather than defining it in terms of Rails. From the article: 'Ruby on Rails is just one facet of what makes Ruby great, just like EJB is only part of the Java enterprise platform. Andrew Glover digs beneath the hype for a look at what Java developers can do with Ruby, all by itself. Ruby's syntax is quite different from that of the Java language, but it's amazingly easy to pick up. Moreover, some things are just plain easier to do in Ruby than they are in the Java language.'"
I love it how the Rails fanatics always take great personal insult at even the mere suggestion that code generation isn't its strong point. Even though, surprise surprise, the infamous tutorial video advertises just this very feature throughout pretty much the entire clip. It's like watching a little kid cry and stamp their feet at a grocery store trying to get their parents to buy them cereal.
Why was this modded up? The article doesn't even mention code generation. It compares Ruby and Java as generic development languages.
If speed and memory usage is your only criteria when choosing a language, why not use C or assembly?
ikkibr is a robot that looks for similar past articles and reposts highly-modded comments from those articles. See http://ask.slashdot.org/comments.pl?sid=171820&cid =14310500
Ruby is useless to me because it has no unicode support.
e st=all&lang=java&lang2=ruby&sort=fullcpu
In this shootout it was found that Ruby had lower memory consumption, but also ran much more slowly than Java:
http://shootout.alioth.debian.org/benchmark.php?t
I too like Python, but let's put this into perspective. This is an article about Ruby and Java, not about Python. Just because someone starts talking about Ruby doesn't mean they're mandated to mention the alternatives.
You just have to love java programmers making the easy more difficult. What I have learned in managing developers is that you have to constantly fight their desire to make things more complicated without a valid reason for doing so.
He's correct that certain tasks are easier in Ruby than in java, not to mention that the code is more readable. But he is missing in my opinion the most important part of Rails and that the ORM. Use scaffolding or don't use it. But if you bypass Active Record you're just making more work for yourself.
Man Holmes
Congratulations Java, you've finally proven yourself as the new Benchmark(TM). Enjoy a lifetime of groundless belittlement.
By the way, if moreover isn't on this list, it sure ought to be. Over.
Before I even consider Ruby: is it faster and less memory hungry than Java.
Yes on both counts. It's faster for you to write programs, and requires less of a learning curve.
Why? The speed of C and C++ are hardly needed for most applications, and languages like Ruby and Python can leverage GUI toolkits like Qt and GTK. If your Qt Ruby application is indistinguishable from your Qt C++ application, why waste time developing in C++ if you don't have to?
...is a good guy to write this sort of thing since he's been programming Java for a long time and has also branched out into "dynamic Java" things like Groovy. He's done a bunch of stuff on dbUnit (including a dbUnit chapter in Java Testing Patterns), too. So he's had enough experience with Java to know what's what.
I'm probably biased, though, since Andy also wrote the CPD Ant task.
The Army reading list
Why? The speed of C and C++ are hardly needed for most applications
This is the same excuse I have heard for decades when fans of a language try and 'justify' it's lack of performance. Sooner or later a lack of performance really does become a problem - if it wasn't then many Ruby developers would not be working on high-performance VMs for the language.
There are situations where performance doesn't matter, but this is not true for 'most' applications.
I really like Ruby, but I will find much wider use for it when it is truly fast.
why spend more time developing a program in Java, when you could develop it faster in Ruby?
Because not getting the best performance out of hardware, no matter how old or new it is, puts your application at a disadvantage compared to your competitors. No matter how much you may try and justify things, your users don't care about the language you use to develop - they care about performance.
There are alternatives - you can use both Ruby and Java together (JRuby works on the JVM). I think this 'mix and match' approach will be more widely used in the future.
That goes for any sane modern language.
I am trolling
As for Shakespeare, he couldn't even spell his own name, so he didn't care.
I've often heard comparisons of .Net to Java and for a while there it seemed to me like they were two separate but somewhat equal development environments. Now it seems that several languages/environments have been coming up (PHP/Ruby) and many articles I see compare it to Java or explain how it's competing with Java.
.Net doesn't seem to have such competition?
What does the future hold in terms of what environment will "come out on top" when Java seems to be compared to or even competing against so many languages while
I'm a big tall mofo.
The ruby crowd positions themselves as none other than mortal enemies of Java and anyone stupid enough to still be using that pathetic excuse for a language!
Ruby could be just an also-ran if it didn't have Java to kick around. After ten years of spotlight, it's not hard to find detractors. The real question is, can ruby be defined on its own terms, and not Java's? Doesn't seem like it so far, which isn't good news for longevity.
Also, what you're forgetting is that some programmers like the clarity of a well-defined class hierarchy, and Java's got that. Ruby has got some pretty muddy classes that try to do too much.
O lord, bless this thy holy hand grenade, that with it thou mayest blow thine enemies to tiny bits, in thy mercy.
I find this rather hard to believe. The resources needed to run Halflife 2, and the resources required to run a Instant Messenger application, are on a quite different scale from one another. Clearly, therefore, you can afford more inefficiencies in an IM application, than you could in the latest 3D game. Are you claiming that this isn't the case? That we need the latest graphics cards and processors to run text-editors, personal organisors or IM programs?
Performance matters up to a point, but it's important to realise that there is a point where it ceases to matter. Where this point is depends on your application. A user isn't going to care whether a function takes 1 millisecond or 40 time as long. So long as it is below the barrier at which the inefficiencies become noticable, these inefficiencies don't matter.
Programming languages like Ruby, are less efficient from the computer's point of view, but more efficient from a programmer's perspective. If you can develop your product and push it out into production 3 times faster than your competitors, with little noticable performance loss, then you're going to make more money. If you can add more features and adapt to the market 3 times faster, then you're going to make more money. Sometimes the advantages of using a language like Ruby or Python outweigh the disadvantages.
But if your product comes out 6 months before your competitors, and is developed at three times the rate, who's going to have the advantage then?
I really don't believe it will. Ruby is a wonderful language I agree, but actual language coding is not a major part of any project. Design, testing and debugging are. In these areas, in my opinion, there is little difference between the language (in fact, Java has a wider range of high-quality IDEs and debugging tools).
Most of the things I love about Ruby are qualities that it inherits from the Smalltalk programming language. Typing objects instead of variables, everything is an object, object-based encapsulation, blocks as objects, polymorphic collections with enumerators, and the overall style of programming. Ruby is the first language since Smalltalk that I could really grow to love. It adds a lot that Smalltalk doesn't have, like regular expression syntax and better case statements, modues and mixins, and easier access to metaprogramming.
In some ways Ruby is a bit too dynamic - one of the strengths of Smalltalk is its simplicity and the predictability of your code. With Ruby it's easy to adopt a programming style that makes it difficult to predict what will happen when you do something in your code. Experienced programmers should be able to avoid those pitfalls, but I worry that some of the features will ecourage neophytes to create code that is difficult to maintain or understand.
It does everything every other language
does but some things are easier and some things are harder.
Because its relatively new you get to rewrite a bazillion
lines of library code and API's that already exists in other languages.
Furthermore you will become even more multilingual than you used
to be so you can raise language critique to an even higher (f)art
form. One profound difference, for example, is that Booby uses braces
but they are reversed from C++ and Java i.e. the open brace is } instead of {.
I expect to see a whole book on the ramifications
of that alone.
I must disagree here. I can think of several commercial Java web-based projects that I know could have been done in at least the third the time in Ruby on Rails. And the programmer and author Paul Graham holds his startup's use of Lisp as the major factor in their resulting success. In my experience, the choice of language is far more significant than you make it out to be.
> Sooner or later a lack of performance really does become a problem
my limited history of languages says, a lack of performance is taken care of by compiler/VM writers when a market for such comes about.
C was unacceptable, and is now the standard for speed. C++ was way too slow now their are 100's of optimizers to turn off all the features that cause it to be slower than C.
Java started out with horrible performance, but this story talks many times about how fast it is, it has compilers now, and a hundred different optimized VM venders to speed it up.
I see no reason why Ruby would be slower as a language, except the lack of optimizers, perhaps due to the lack of time in the spotlight, and thus the lack of a market requesting it.
...the basic definition of being derailed?
I like Rails, but I love Ruby. The hardest part of learning Rails was (for me, an experienced Ruby coder) learning all of the things that you lose when you go to Rails. (One example out of many: in Ruby when you create a Hash you can provide a default function (rather than just a default value) to be used when an element is missing; with Rails, this generally doesn't work since the functions don't serialize).
Conversely, if you like Rails you really should explore standalone-Ruby to see what you are missing.
--MarkusQ
The chosen language is one of the things that the Consumer (maybe they not think the same, but, whatever) is most aware of. Let's see... The Consumer wants programs that are:
1 - Efficient (memory, processor, net, and disk usage,...)
2 - Bug-free
3 - Cheap
A low level language leads to 1, but not to 2 and 3. A good hight level language leads to 2 and 3, but not to 1. How well received your programs is depends only on how well it fits the Consumer's expectations (and how fat is your marketing bill), so the language matters.
Also, Ruby + Java doesn't lead to a nice combo. The ideal combinations are with languages of different abstraction levels, like Ruby + C, or Ruby + some excelent hight level framework for web pages, aka Rails. So bad Java doesn't combine well with low level languages.
Rethinking email
If your text editor truly takes up as much processing power and memory as the latest 3D chart-topper, then perhaps you should look for a piece of software with a little less weight?
Ruby's conciseness is a by-product of its power. Working around Java's limitations often isn't a trivial task, and Ruby's powerful syntax makes it possible to design some very flexible frameworks. For instance, one commerical java project I was involved in required a web-based file storage system. When I look back on it, Ruby on Rails would have made the job infinitely easier; once the user and file database tables were set up, Rails would have automagically generated class and html interfaces for them. A login helper would have created the login, and then it would have only required a few lines of code to connect in Rail's file upload handling. The entire project could have done in days what had been done in weeks using Java tools.
From my own experience, Ruby has been considerably faster than Java.
http://groups.google.com/group/comp.lang.ruby/brow se_thread/thread/71e50a25544210a9/
Because not getting the best performance out of hardware, no matter how old or new it is, puts your application at a disadvantage compared to your competitors. No matter how much you may try and justify things, your users don't care about the language you use to develop - they care about performance.
Simply not true. 95% of software is developed in-house, by small development teams that don't exactly have time to spare. Managers care about productivity, about getting more features implemented in the same time. An extra server costs what, the same as hiring a programmer for a single month?
I believe posters are recognized by their sig. So I made one.
I'm doubtful. I bump up against the limitations of Java every other day, and it seems like the only way you could get around such things is with an awful lot of code generation.
For instance, I was recently writing a Java class to convert an XML DOM into a custom object tree. This largely involved writing getters and setters, and for loops to iterate over NodeLists to pull out descendant elements. I couldn't help thinking that with Ruby, I could have written "has_attributes" and "has_descendants" methods, and generated the getters and setters and DOM handling automatically. Instead of my classes being 50 lines apiece, they could have just been 4. It would have taken me far less time in Ruby than I did in Java, because Java hasn't got metaclass-like abilities like Ruby or Python.
I work as a java developer, but I still still have plenty of other languages in my toolbox. I have just started with experimenting with Ruby. The biggest thing I see is that Ruby fills gap for me between perl and Beanshell.
The programming hierarchy I tend to think of for my work,
1. Shell- Basic scripting. Glueing commands together.
2. Perl- More powerful sripting features, but not really OO.
3. Ruby- Still a scripting language, but designed around OO.
4. BeanShell- Good for quick glueing of java classes together
5. Java- When I need a full compiled application environment.
For me each language has its purpose and I use them where it best gets
the job done.
Python better add the features that Ruby hypers won't shut up about or risk getting left in the popularity dust. It is not that Ruby is better, but if people keep talking about certain features then people will *expect* them because they hear about them, not necessarily because they really are a Silver Bullet. Hype works, I am sorry to say.
Table-ized A.I.
But if I find that a project done in Rails is N times faster than a Java project of a similar nature I've done in the past, I'm hardly going to discount it based on the unseen evidence of someone on Slashdot. If, in my experience, Ruby proves to be a far faster development language than Java, I'm not going to hum and say, well, what about those project managers who decided language wasn't a deciding factor.
Add to this the fact that there are many experienced developers who take the opposite of your position; Paul Graham, as I've already mentioned, and quite a few of the chaps at Google. I'd dig up more examples, but it's Christmas Eve and decidedly late.
In my opinion, people should try out both languages and decide for themselves based on the results, rather than rely upon the experience of others. Wouldn't you agree?
Rails as has been said, is a framework. Ruby is the language, and all rails is just ruby with a design in place to make it easier. Some great tools for using rails are becoming available though, due to its increasing user-base. A lot of people are still "trying it, and going back to php" but its got a core user group now and that's what counts.
No, verbosity like this serves no purpose whatsoever. It's just like writing: if you want those that come after you to understand it, write clean, spare code with useful symbol names and use comments on the non-obvious parts, for chrissake - that's what they're for. In fact, verbosity does just the opposite - it encourages vast amounts of cut-and-paste monkeywork, and all the attendant bugs and inefficiencies that come with it.
I've seen enough cryptic, overterse code that was incomprehensible, but I've seen just as many 2000 line monster modules that took a week of tracing through to understand what was going on. What's worse, the more verbose the code, the harder it is to modify and extend it, or - god forbid - try to use it for something else.
It's not elitist to want to write as little code as possible - it should be your goal. I have a lot of work to do and not a lot of time, and I do not want to write 20 lines where 3 will do. If you have to resort to tools to autogenerate gobs of code to use your language, you're doing something very wrong.
Excessive verbosity is great if you're a) overly anal retentive, b) not really a very imaginative programmer, or c) getting paid by the hour.
Oh, and Sun's primary contribution seems to be shovelloads of methodolgies and APIs starting with the letter 'J', thrown aperiodically at the community in the hopes that some of them will stick, most of which are deprecated or outright disappeared when some new strained coffee metaphor comes out saying "No, *this* is the Right Way To Do It!"
What if life is just a side effect of some other process and God has no idea we exist?
Because not getting the best performance out of hardware, no matter how old or new it is, puts your application at a disadvantage compared to your competitors. No matter how much you may try and justify things, your users don't care about the language you use to develop - they care about performance.
Come again? This might be true for a rather small percentage of software, but I don't think it applies even for a majority.
What I find funny is that I remember these same arguments being made about C because it was so inefficient and "high level", and how assembler was the way to go for performance reasons.
Most software development is for fixed-function, limited, internal use by a company, organization, or small niche marketplaces. In these environments, getting feature N to work quickly is very important, getting it to work rapidly is marginally important, and the language or platform is irrelevant.
High-level languages like Ruby, Perl, and PHP (and possibly Java) allow developers to focus on getting the job done quickly, without spending as much time worrying about things like memory management. They allow you to switch types dynamically, so that adding 5 to a character '3' results in an 8.
If a total of 200 people are using the software, it's very reasonable to expect that the software would perform nicely on commodity software, even if it's not particularly efficient. In this space, all that matters is that it works, and is developed as quickly and cheaply as possible. The cost of development is typically much, much higher than the cost of the total hardware involved - so who cares if it takes a $10,000 server to make it work, if it saves $120,000 in labor expenses for development, and gets to implementation 4 months earlier?
Where's your smart money going to go?
I have no problem with your religion until you decide it's reason to deprive others of the truth.
I'm sorry. I've probably written 200kloc of Java in my life. I have never noticed this painful repitition? Where is it?
Thanks,
Sean
I live in a giant bucket.
Given the number of posts in java.net and slashdot on how Ruby is the greatest thing of all (and no mention at all of any negative side) I start wondering why is Ruby desperate to move Java programmers from Java to Ruby
Personally I do not trust a language that has no negatives sides (or at least the Ruby people seems to think so), until it becomes clear what is the other side of Ruby I am not going to use it.
(Yes, I have visited the Ruby website)
StringTokenizer st = new StringTokenizer(s);
Free Java games for your phone: Tontie, Sokoban
Actually in an array (it doesn't work so well in a hash) you can just do this:
puts array
That's it.
Well in Python you can just do
print array
Oh, wait, that's 1 character more. That's it, I'm switching to Ruby.
I must conclude that you don't think
/* increment i */ is silly either.
i++;
Let's just leave it there, then.
-Lasse
Bullshit. Managers like Java because it helps their team achieve their business objectives better than the other languages you describe.
Hmmm, this attitude sounds somewhat familiar. Oh yeah, Paul Graham has written about it at length in this essay:
The pointy-haired boss miraculously combines two qualities that are common by themselves, but rarely seen together: (a) he knows nothing whatsoever about technology, and (b) he has very strong opinions about it.
Suppose, for example, you need to write a piece of software. The pointy-haired boss has no idea how this software has to work, and can't tell one programming language from another, and yet he knows what language you should write it in. Exactly. He thinks you should write it in Java.
Why does he think this? Let's take a look inside the brain of the pointy-haired boss. What he's thinking is something like this. Java is a standard. I know it must be, because I read about it in the press all the time. Since it is a standard, I won't get in trouble for using it. And that also means there will always be lots of Java programmers, so if the programmers working for me now quit, as programmers working for me mysteriously always do, I can easily replace them.
On your own dime, go jump in leaf piles, run through a field of flowers, play with Python, Ruby or whatever is good for your spiritual wellbeing, but when you're working to pull a paycheck, you don't get to put your own flights of fancy before things which make your team (not you as an individual performer, but your team as a whole) more effective in achieving business objectives.
Horseshit. Python and Ruby and Lisp are real-world workhorses that don't need tens of millions of dollars in hype to be successful. For instance I have tens of thousands of lines of Python code out on the field doing real work, 24 hours a day, seven days a week for really demanding clients, including governments and advertising agencies. In one case, I finished a project in a third of the time it took three Java programmers - and mine was smaller, faster and more maintainable for the guys who took it over. Time is money and succinctness is power in software development and Java doesn't make the cut on either. Oh sure, it's a great tool to allow development by the lowest common denominator (money quote from James Gosling) but the really smart teams I know despise it for the ugly hack it really is. When I expressed this opinion in a column for a local computing mag, I was assailed with all kinds of outraged squeals from the local Java gurus. But none of them could answer my points honestly.
If readers disagree, answer honestly with words rather than modpoints. I've tried Java. I really have. I found it ugly, slow, anal and seriously limiting to work with. And I don't seem to be allowed to fix flaws in it either. That's not good.
--- Hot Shot City is particularly good.
Tsk tsk. You're taking this way too personally.
I'm sure it's easy to copypaste some strawman argument containing hilarious phrases such as "pointy-haired boss" which the children will find irresistible, since they know nothing about the actual merits of the arguments, having never managed anyone, let alone a group of people who work together to achieve objectives such as saving people's lives, or even less noble objectives such as creating a software platform to aid the collective research efforts of thousands of researchers.
I rest my case. The above paragraph is one sentence! Obviously working with Java's crufty verbosity has affected your writing. I'd suggest taking a course in a more pithy language. By the way, Graham's argument is not a strawman: he's made it clear over a few different essays that because programming languages vary in power, smart coders who use more powerful languages can code circles around those using Java. Also if you're going to drag in logical fallacies then I need to point out yours too: "saving people's lives" and "aiding
I have used hundreds of thousands of dollars on Python code which the author believed to be really maintainable and work really well, but in the reality-based world turned to be such crap that the whole team, including me, had to work a breakneck pace to rewrite it in Java, which has such incredible features as working threading support, no Global Interpreter Lock, actual Oracle and LDAP support that doesn't leak memory like anything, and isn't 20 times slower than the Oracle and LDAP support in other languages, no monkey patches (oh yeah, Python coders seem to think that it's SUCH a good idea to monkeypatch others' code, since after all, SMART people should know without any documentation what's going on, and documentating code is useless anyway, people should just go in and read all of those millions of lines of code if they want to know what's going on) and, you know, clear and accurate documentation and HORDES of pre-existing components which make your life so much easier, if only you're not infected with the dreaded Python community NIH disease.
Sheesh, I thought the previous sentence was bad but this one takes the cake. Full stops are your friend. So is coherence. Some answers:
Java does have an additional useful feature: because of its mandatory coding practises and standards it's pretty easy to spot when an amateur has written something really broken, and contain the problem to those components which the amateur has touched. Perhaps this is what has happened to you?
Entirely possible. But I've seen good Java - really top of the line guru-doing-an-exercise-proposed-by-Martin_Fowler-s tandard type Java - and it was just plain ugly because the language is just plain ugly.
I've used, in production, Python, Perl, C, C++, Pascal, Java, x86 assembly, a little AutoLisp, and so on. Hundreds of thousands of lines. (The C code I have out there is pretty crappy, for which I apologise, but I was an amateur and thought of my work much as you seem to think now.)
Can't recall making any comments about your work or even you personally. *Checks* - nope. You
--- Hot Shot City is particularly good.