| Author |
What would you add to Java?
|
Frank Spychalski
Greenhorn
Joined: Mar 19, 2006
Posts: 3
|
|
This is not really a Rails specific question. Neal Gafter blogs about adding closures to java. Which Ruby (or any other language) features would you like to add to the Java language. Or do you think it is possible to create a Framework with the power and flexibility of Rails with Java without any changes?
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11945
|
|
Personally, I'd like to have support for regular expressions built into the language syntax itself as well as expression interpolation in literal strings. E.g. something like
|
Author of Test Driven (Manning Publications, 2007) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
Justin Gehtland
author
Ranch Hand
Joined: Jan 30, 2007
Posts: 31
|
|
Personally, I'd much rather we just started using jRuby for all of our programming on the JVM. As Stuart would say were he online right now, in a perfect world, we'd write code in jRuby and Java itself would become the Assembler (and not the COBOL) of our generation. Put a gun to my head, and I'd say: Regular expressions as first-class entitiesClosures (and related items like enumeration support that makes use of them)Open classesMixins without having to resort to AOP
|
 |
Terry Jeske
Greenhorn
Joined: Apr 06, 2004
Posts: 17
|
|
So, why JRuby over Groovy? To the untrained -i.e me javascript: x() Wink they look very similar in syntax.
|
 |
Stuart Halloway
author
Greenhorn
Joined: Jan 04, 2007
Posts: 2
|
|
JRuby and Groovy have a family resemblance, but they are distant relations. The last time I looked Groovy code still gets "hardened" into Java classes. JRuby code, on the other hand, follows the Ruby way of being "the glue that never sets." JRuby code can dynamically modify the behavior of other JRuby code. The subtle danger is that JRuby and Groovy are similar for about the first 50% of what makes Ruby cool. For the latter half, only JRuby delivers the goods.
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8836
|
|
Mixins without having to resort to AOP
How does that work?
|
Groovy
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11945
|
|
|
Pradip, you can read about mixins from the online version of Programming Ruby.
|
 |
Justin Gehtland
author
Ranch Hand
Joined: Jan 30, 2007
Posts: 31
|
|
So, let's say you have a class that's buried somewhere, like, Rails' ActionController. And you want to add a new method to it, like, "help" (so that all your controllers had a /your_controller/help url that tells what that controller is for). You can create a module to hold the new, shared method: Then, you can, from anywhere in the code, call: Voila. Your controller now has a "help" method. What if you wanted to wrap a method already in a class? For that, you would use . If you then extend that into a class with a "save" method, it renames the original method, creates a new method of the same name (a proxy, if you will), and when it is called, the new method logs the process and forwards the call to the original method. There is a new addition to Rails 1.2 called alias_method_chain which makes the whole process a little cleaner, as well. [ January 31, 2007: Message edited by: Justin Gehtland ]
|
 |
 |
|
|
subject: What would you add to Java?
|
|
|