Do you code in ruby to build Java applications?
Recently I've come across http://monkeybars.rubyforge.or开发者_开发问答g/ and Rawr. It seems sufficient to build Java applications.
My question is, is there any disadvantages of choosing this approach ? Jruby to Java ? Will my application suffer performance loss compared to writing it in Java ? For me the advantage is I don't have switch to Java, and can use ruby which I find is a lot easier to write stuff.
Of course you will lose some performance. Ruby (like e.g. Smalltalk and Python, among others) is inherently very dynamic and high-level, plus dynamically-typed. Many claim that this enables programmers to be much more efficient (I tend to agree), but OTOH, calls have to be dispatched and decision have to be made at runtime which can and are, in a static language like Java, decided at compiletime. So yes, there will be some performance loss.
But: Does it really matter? For 99% of all GUI application code, it does not. On a modern home computer, from the user's perspective, an average ruby method seems to take the same time as an average Java method: About zero seconds. And in both languages, by far the most time will be spent waiting for user input, and to a lesser degree by disk I/O and by the GUI framework drawing new stuff to the screen.
Addendum: A possible drawback may such bridges generally tend to be fragile - like, hard to integrate with the original (in this case Java) or breaking with newer versions. But I can't judge that...
精彩评论