• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

What would you add to Java?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 entities
  • Closures (and related items like enumeration support that makes use of them)
  • Open classes
  • Mixins without having to resort to AOP
  •  
    Greenhorn
    Posts: 17
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    So, why JRuby over Groovy? To the untrained -i.e me javascript: x()
    Wink they look very similar in syntax.
     
    author
    Posts: 2
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    Ranch Hand
    Posts: 8944
    Firefox Browser Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Mixins without having to resort to AOP


    How does that work?
     
    Lasse Koskela
    author
    Posts: 11962
    5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Pradip, you can read about mixins from the online version of Programming Ruby.
     
    Justin Gehtland
    author
    Posts: 31
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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 ]
     
    A magnificient life is loaded with tough challenges. En garde tiny ad:
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
    reply
      Bookmark Topic Watch Topic
    • New Topic