In June of this year, I spent a few hours formulating a dynamic cousin to Duby. Duby, if you don't remember, is a static-typed language with Ruby's syntax and Java's type system. Duby supports all Ruby's literals, uses local type inference (only
... [More]
argument types *must* be declared), and runs as fast as Java (because it produces nearly identical bytecode). But with the advent of invokedynamic, Duby needed a playmate.Enter "Juby". Juby is intended to be basically like Duby, in that it uses Java's types and Ruby's syntax. But it takes advantage of the new invokedynamic opcode to be 100% dynamic. Juby is a dynamic Duby, or perhaps a dynamic Java with Ruby syntax. It's not hard to comprehend.But the name was a problem. Juby sounds like "Jewbie", a pejorative term for a Jewish person. So I sent out a call for names to the Twitterverse, ultimately ending up with far more names than I could choose from.The name I have chosen, Surinx, has a simple story attached. You see, when James Gosling created Java, he originally named it "Oak", after the tree outside his window. So I followed his lead; the tree (a bush, really) outside my window is a lilac, Syringa vulgaris. The genus "Syringa" is derived from New Latin, based on a Greek word "surinx" meaning "shepherd's pipe" from the use of the Syringa plant's hollow stems to make pipes. Perhaps Surinx is building on the "hollow stem" of the JVM to produce something you can smoke (other dynamic languages) with. Combined with its cousin "Duby", we have quite a pair.And in other news, the simple Surinx implementation of "fib" below (identical to Ruby) manages to run fib(40) in only 7 seconds on current MLVM (OpenJDK7 + invokedynamic and other tidbits), a five-fold improvement over JRuby's fastest mode (jruby --fast).def fib(a) if a < 2 a else fib(a - 1) + fib(a - 2) endendGiven that JRuby has started to support invokedynamic, the solid performance of Surinx bodes very well for JRuby's future.Please welcome Surinx to your language repertoire! [Less]
|
We often get the question "which deployment option is the best for JRuby on Rails?" The truth is that it depends on what you need out of deployment.If you have a fairly straightforward Rails app without a lot of service dependencies and a greenfield
... [More]
deployment target, your best bet is probably the GlassFish gem right now. It performs really well, can handle high loads and high concurrency, and automatically detects Rails' threadsafe mode, scaling better when it's turned on. I'm no longer a Sun employee, and I still think the GF gem is an outstanding piece of work. Here's my howto on GF gem + JRuby on Rails + Apache. Update: Here's information on using Capistrano with the GlassFish gem.If you have an existing Java EE or web container like Tomcat, JBoss, GlassFish, WebLogic, or WebSphere, you want to look into Warbler. Warbler packages your application as a .war file, suitable for deployment on any of these standard servers. The Warbler wiki is the best place to learn about deploying with Warbler.If you're looking for something that's somewhat greenfield but also needs more advanced services like scheduled asynchronous jobs, web services, and some level of EE integration, you should look at JBoss's TorqueBox, a customized JBoss specially tailored for deployment of Rack-based apps (like Rails) on JRuby.If you're looking for a hosting provider that can take your app and make it "just work", then you should look into Engine Yard's JRuby cloud offering. We don't yet have it 100% ready to go, but it won't be long and it will be fantastic. For now you can give us some direction and input on what that hosting/cloud should look like.All told, there's a lot of great options for JRuby deployment, and no one of them is going to be perfect for everyone. Choose wisely, and join the JRuby mailing lists if you have questions. [Less]
|
It's been a while since I was able to work on JRuby's Android support, but tonight I managed to finally circle back. And I've got something much more impressive working today: a real IRB application!(And yes, this works just fine on the phone too)It
... [More]
turned out to be incredibly easy to get this working. I'm not using any stinking plugin because they all seemed to just get in my way. So I generated a dummy application using the "android" tool, dropped the jruby jar in "libs", wrote up a quick interactive console, built and signed it, and that's all there was to it.JRuby turns out to work very well for this sort of thing because we have an interpreter, so we can parse and execute code dynamically. Hooray for interpreted support!I had to tweak a couple things to work around shortcomings in Android:I had to edit the dx tool to allow up to a 1024M heap, since JRuby's jar has a ton of stuff in itI had to catch and swallow an ArrayIndexOutOfBounds exception coming out of Dalvik's enum support. Bug!This is of course a proof-of-concept. Writing full applications in Ruby isn't far behind, but we'll need a couple adjustments to JRuby to support it well:Ability to run 100% precompiled with no runtime code generationStrip out parser, interpreter, compiler, and bytecode-generation bits to shrink the jarTidy up the AOT compiler and wire it into the app build processGenerate some Ruby stub logic for the Android APIs, so they'll work well from RubyStrip down the weirder and wilder Ruby features (eval, etc) to allow fastest-possible executionI know how to do all of this.I've pushed ruboto-irb to Github so you can check it out and play with it. I welcome contributors :)Ruboto lives!Update: Good news, everyone!First, the two bugs I've encountered have both been previously reported and are due to be fixed in an upcoming Android release. They are the enum bug and the reflection bug.Second, someone going by the handle of "Psycho" reports in the comments that the next version of the Android Scripting Environment (ASE) will include JRuby support! Of course I'm interested in more than just scripting applications with JRuby...I'd like to be able to write applications using only Ruby code, so I'll continue working on this. But JRuby support seems to be coming in from all directions. [Less]
|
I should have blogged this sooner, but things have been a little...crazy...lately.The JVM Languages Summit is coming up for its second year. The event last year was spectacular; representatives of all the major languages and several minor ones showed
... [More]
up and talked about their plans, their history, and their desires from the JVM. And JVM engineers from the three major vendors (Sun, IBM, Oracle) sat there and dutifully took notes. It was a great meeting of minds, and an incredibly uplifting event for those of us invested in the JVM.It's also not just an event for implementers; if you're keen on the nitty-gritty details of JVM languages and want to help improve them, promote them, or otherwise relate to them in some way, you should be here.Hope to see you at the Summit!=== CALL FOR PARTICIPATION -- JVM LANGUAGE SUMMIT, September 2009 ===http://jvmlangsummit.com/Dear colleague;We are pleased to announce the the 2009 JVM Language Summit to be held at Sun's Santa Clara campus on September 16-18, 2009. Registration is now open for speaker submissions (presentations and workshops) and general attendance.The JVM Language Summit is an open technical collaboration among language designers, compiler writers, tool builders, runtime engineers, and VM architects. We will share our experiences as creators of programming languages for the JVM and of the JVM itself. We also welcome non-JVM developers on similar technologies to attend or speak on their runtime, VM, or language of choice.The format this year will be slightly different from last year. Attendees told us that the most successful interactions came from small discussion groups rather than prepared lectures, so we've divided the schedule equally between traditional presentations (we're limiting most presentations to 30 minutes this year) and "Workshops". Workshops are informal, facilitated discussion groups among smaller, self-selected participants, and should enable "deeper dives" into the subject matter. There will also be impromptu "lightning talks".We encourage speakers to submit both a presentation and a workshop; we will arrange to schedule the presentation before the workshop, so that the presentation can spark people's interest and the workshop will allow those who are really interested to go deeper into the subject area. Workshop facilitators may, but are not expected to, prepare presentation materials, but they should come prepared to guide a deep technical discussion.The Summit is being organized by the JVM Engineering team; no managers or marketers involved! So bring your slide rules and be prepared for some seriously geeky discussions.The registration page is now open at:http://registration.jvmlangsummit.com/If you have any questions, send inquiries to [email protected] hope to see you in September! [Less]
|
I'm going to be speaking about JRuby again this year at eRubyCon, in Columbus OH. I just got back from Rails Underground, which reminded me how much I love the smaller regional Ruby conferences. So I'm totally pumped to go to eRubyCon this year.The
... [More]
idea of "Enterprise Ruby" has become less repellant since Dave Thomas's infamous keynote at RalsConf 2006. There are a lot of large, lumbering organizations out there that have yet to adopt any of the newer agile language/framework combinations, and Rails has most definitely led the way. I personally believe that in order for Ruby to become more than just a nice language with a great community, it needs to gain adoption in those organizations, and it needs to do it damn quickly. JRuby is by far the best way for that to happen.There's another aspect to adoption I think has escaped a lot of Rubyists. In 2006 and 2007, Ruby gained a lot of Java developers who were running away from bloated, over-complicated frameworks and the verbosity and inelegance of Java. When I asked at Ruby conferences in 2005, 2006, and 2007 how many people had done Java development in a former life, almost everyone in the room raised their hands. When I've asked the same question in 2008 and 2009, it's down to less than half the room. Where did they go?The truth is that the Java platform now has reasonably good answers to Ruby in Groovy, Scala, and Clojure, and reasonably good answers to Rails in Grails and Lift. And yet many Rubyists don't realize how important it is for JRuby to continue doing well, many still seeing it as simply "nice to have" while dismissing the entirety of the Java platform as unimportant to Ruby's future. It's an absurd position, but I blame myself for not making this case sooner.I believe that JRuby is the most crucial technology for Ruby's future right now. Regardless of how fast or how solid the C or C++ based Ruby implementations get, the vast majority of large organizations are *never* going to run them. That's the truth. If we can leverage JRuby to grab 1-2% of the Java market, we'll *double* the size of the Ruby community. If we completely lose the Java platform to alternatives, Rubyists may not have the luxury of remaining Rubyists in the future. It's that big a deal.So I hope you'll come by eRubyCon and hear what we've been working on in JRuby and what we have planned for the future, especially our work on making JRuby a stronger JVM citizen. I'm certain to expand on the Hibernate-based prototype code I showed at Rails Underground, and hope to have some additional, never-before-seen demonstrations that will shock and amaze you. And if there's time, I'll demonstrate my two research pets, the "Ruby Mutant" twins Duby and Juby.See you there! [Less]
|
|
Posted
over 16 years
ago
I am moving my blog to http://blog.enebo.com/I should even update it more often that this one...
|
Here's a list of talks about Ruby or that mention/relate to Ruby at CommunityOne and JavaOne 2009. Some of these are about other languages, since I just did a dumb search for any mention of "ruby".Add your suggestions in comments to help narrow down
... [More]
which talks people should go see.CommunityOne: S304128 Developing on the OpenSolaris™Operating System David Miner, Sun Microsystems; Nicholas Solter, Sun Microsystems Monday June 01 10:50 AM - 11:40 AM Esplanade 305 S307894 Sun GlassFish™ Portfolio: Where Sun's Application Platform Is Going Eduardo Pelegri-Llopart, Sun Microsystems, Inc. Monday June 01 10:50 AM - 11:40 AM Hall E 135 S304001 Pragmatic Identity 2.0: Invoking Identity Services with a Simplified REST/ROA Architecture Pat Patterson, Sun Microsystems, Inc.; Daniel Raskin, Sun Microsystems, Inc.; Ron Ten-Hove, Sun Microsystems, Inc. Monday June 01 11:50 AM - 12:40 PM Gateway 102-103 S304141 Programming Languages and the Cloud Ted Leung, Sun Microsystems, Inc. Monday June 01 11:50 AM - 12:40 PM Gateway 104 S304267 Beyond Impossible: How JRuby Has Evolved the Java™ Platform Charles Nutter, Sun Microsystems, Inc. Monday June 01 1:40 PM - 2:30 PM Hall E 134 S304040 Social-Enable Your Web Apps with OpenSocial Dave Johnson, IBM Monday June 01 4:00 PM - 4:50 PM Esplanade 300 S311290 JRuby Rails Workshop Arun Gupta, Sun Microsystems, Inc.; Jacob Kessler, Sun Microsystems; Vivek Pandey, Sun Microsystems, Inc.; Nick Sieger, Sun Microsystems, Inc Tuesday June 02 9:00 AM - 5:00 PM Breakout Room 7 S311294 Cloud Computing and Storage in Practice Tim Bray, Sun Microsystems, Inc.; Chris Kutler, Sun Microsystems, Inc. Wednesday June 03 1:30 PM - 5:00 PM Breakout Room 2 JavaOne:PAN-5348Script Bowl 2009: A Scripting Languages ShootoutPanel SessionRoberto Chinnici, Sun Microsystems, Inc.; Thomas Enebo, Sun Microsystems, Inc. ; Rich Hickey, Clojure;Guillaume Laforge, SpringSource; Raghavan Srinivas, Self; Dick Wall , Google; Frank Wierzbicki, Sun Microsystems, Inc.TuesdayJune 0210:50 AM - 11:50 AMGateway 104TS-4164Clojure: Dynamic Functional Programming for the JVM™ MachineTechnical SessionRich Hickey, ClojureTuesdayJune 0212:10 PM - 1:10 PMHall E 133TS-4487The Feel of ScalaTechnical SessionBill Venners, Artima, Inc.TuesdayJune 023:20 PM - 4:20 PMGateway 104TS-5015Welcome to RubyTechnical SessionYehuda Katz, Engine YardTuesdayJune 024:40 PM - 5:40 PMGateway 104TS-5216Toward a Renaissance VMTechnical SessionBrian Goetz, Sun Microsystems, Inc.; John Rose, Sun MicrosystemsTuesdayJune 026:00 PM - 7:00 PMHall E 133BOF-4434Hacking JRubyBOFOla Bini, ThoughtWorksTuesdayJune 028:30 PM - 9:20 PMGateway 104BOF-5058JRuby Experiences in the Real WorldBOFLogan Barnett, Happy Camper Studios; David Koontz, JumpBoxTuesdayJune 029:30 PM - 10:20 PMGateway 104TS-5413JRuby on Rails in Production: Lessons Learned from Operating a Live, Real-World SiteTechnical SessionNick Sieger, Sun Microsystems, IncWednesdayJune 0311:05 AM - 12:05 PMGateway 104TS-4921Dynamic Languages Powered by GlassFish™ Application Server v3Technical SessionJacob Kessler, Sun Microsystems; Vivek Pandey, Sun Microsystems, Inc.WednesdayJune 0311:05 AM - 12:05 PMHall E 133TS-4955Comparing Groovy and JRubyTechnical SessionNeal Ford, ThoughtWorks Inc.WednesdayJune 032:50 PM - 3:50 PMGateway 104BOF-4682Performance Comparisons of Dynamic Languages on the Java™ Virtual MachineBOFMichael Galpin, eBayWednesdayJune 036:45 PM - 7:35 PMEsplanade 300TS-5385Alternative Languages on the JVM™ MachineTechnical SessionCliff Click, Azul SystemsThursdayJune 049:30 AM - 10:30 AMGateway 104TS-4012Pragmatic Identity 2.0: Simple, Open, Identity Services Using RESTTechnical SessionPat Patterson, Sun Microsystems, Inc.; Ron Ten-Hove, Sun Microsystems, Inc.ThursdayJune 0410:50 AM - 11:50 AMEsplanade 307-310TS-4961"Design Patterns" for Dynamic Languages on the JVM™ MachineTechnical SessionNeal Ford, ThoughtWorks Inc.ThursdayJune 0410:50 AM - 11:50 AMGateway 104TS-5354Exploiting Concurrency with Dynamic LanguagesTechnical SessionTobias Ivarsson, Neo TechnologyThursdayJune 041:30 PM - 2:30 PMGateway 104TS-5033Scripting Java™ Technology with JRubyTechnical SessionThomas Enebo, Sun Microsystems, Inc. ; Charles Nutter, Sun Microsystems, Inc.ThursdayJune 042:50 PM - 3:50 PMGateway 104TS-3955Monkeybars: Tools-Enabled Swing Development with JRubyTechnical SessionLogan Barnett, Happy Camper Studios; David Koontz, JumpBoxFridayJune 0512:10 PM - 1:10 PMEsplanade 302 [Less]
|
I just released BiteScript 0.0.2, which mainly fixes some issues defining packages and non-public classes.BiteScript is basically just a simple DSL for generating JVM bytecode. I use it in Duby and now in the "ruby2java" compiler we'll be using to
... [More]
turn Ruby classes into Java classes.I've blogged about BiteScript here before, but I realized today I never posted any simple "hello world" examples. So here's a few of them, all using the command-line "scripting" mode.First, the simplest version:main do ldc "Hello, world!" aprintln returnvoidendObviously this is using a predefined "aprintln" macro, since there's no "aprintln" opcode on the JVM. Here's a longer version that shows how a macro would be defined, and accepts one argumentimport java.lang.Systemimport java.io.PrintStreammacro :aprintln do getstatic System, :out, PrintStream swap invokevirtual PrintStream, println, [Object]endmacro :aprint do getstatic System, :out, PrintStream swap invokevirtual PrintStream, print, [Object]endmain do ldc "Hello, " aprint aload 0 aaload 0 aprintln returnvoidendAnd of course this is just Ruby code, so you can just use Ruby to alter the generation of code:main do 5.times do ldc "Wow!" aprintln end returnvoidendThese "BiteScripts" can all be either run with the "bite" command or compiled with the "bitec" command:$ bite examples/using_ruby.bs Wow!Wow!Wow!Wow!Wow!$ bitec examples/using_ruby.bs $ javap -c examples/using_rubyCompiled from "examples.using_ruby.bs"public class examples.using_ruby extends java.lang.Object{public static void main(java.lang.String[]); Code: 0: ldc #9; //String Wow! 2: getstatic #15; //Field java/lang/System.out:Ljava/io/PrintStream; 5: swap 6: invokevirtual #21; //Method java/io/PrintStream.println:(Ljava/lang/Object;)V 9: ldc #9; //String Wow! 11: getstatic #15; //Field java/lang/System.out:Ljava/io/PrintStream; 14: swap 15: invokevirtual #21; //Method java/io/PrintStream.println:(Ljava/lang/Object;)V 18: ldc #9; //String Wow! 20: getstatic #15; //Field java/lang/System.out:Ljava/io/PrintStream; 23: swap 24: invokevirtual #21; //Method java/io/PrintStream.println:(Ljava/lang/Object;)V 27: ldc #9; //String Wow! 29: getstatic #15; //Field java/lang/System.out:Ljava/io/PrintStream; 32: swap 33: invokevirtual #21; //Method java/io/PrintStream.println:(Ljava/lang/Object;)V 36: ldc #9; //String Wow! 38: getstatic #15; //Field java/lang/System.out:Ljava/io/PrintStream; 41: swap 42: invokevirtual #21; //Method java/io/PrintStream.println:(Ljava/lang/Object;)V 45: return}This last example shows the resulting JVM bytecode as well.Future plans for BiteScript include making it have better error detection (right now it just falls back on the JVM bytecode verifier, which is not the most descriptive thing in the world) and improving the API to more easily handle all the various combinations of class, field, and method modifiers. I'd also like to make it detect if you're doing bad things to the stack to save you the hassle of interpreting verification errors that may not happen until runtime.Anyway, give it a try and feel free to contribute; the code is all Ruby, wrapping the ASM bytecode library, so anyone that knows Ruby can tweak it. The project page and wiki are hosted at Kenai.com: http://kenai.com/projects/jvmscriptAnd if you're not up on the JVM or JVM bytecodes, the JVM Specification is an easy-to-read complete reference for code targeting the JVM, and here is my favorite JVM opcode quickref. [Less]
|
A number of you have asked how you can help JRuby development. Well there's actually an easy way: fix RubySpec failures.You may have noticed we periodically update our RubySpec "stable" revision number, and usually have to file a few bugs. This isn't
... [More]
because we don't want to fix those issues...on the contrary, we would love to fix them. We just don't have enough manpower, and there's usually harder issues we need to tackle first.But most of the failures are easy to fix, and a lot of JRuby newcomers have gotten their feet wet fixing them. So here's a short guide on how to run the specs and fix them quickly.1. Get a JRuby working copy and build itThis is as simple as 'git clone git://github.com/jruby/jruby.git', then 'cd jruby' and 'ant'. You'll need Apache Ant 1.7 and Java 5/1.5 or higher (grab "Java SE Development Kit" from the Java SE downloads page.2. Run the CI spec runWe have a clean spec run that should be clean for you before you start. Just run "ant spec-short" and it will pull the mspec and rubyspec repositories, roll them to the stable versions, and run all known good specs. Now you're ready to investigate specific failures.3. Run specific spec files with bugs reportedYou can look in Jira under the "RubySpec" category, or look under spec/tags/ruby for "tag" files listing failing specs and Jira bug numbers. Once you find something you'd like to investigate, run that spec file using "bin/jruby spec/mspec/bin/mspec <path/to/spec/file>". For example to set the Range#initialize failures I just reported, run "bin/jruby spec/mspec/bin/mspec spec/ruby/core/range/initialize_spec.rb".Now you can proceed to fixing it.4. Identify where the problem is.Most of the core classes are pretty easy to locate. Any classes in the "core" specs will have a Java class named Ruby, like RubyArray, RubyRange, and so on. They're generally located in src/org/jruby. If you know any Java, these files are pretty easy to follow, and we're standing by on IRC or on the mailing list to hold your hand at the start.5. Create a patch and submit it to the bugOnce you have a working fix, you can go ahead create a patch, either with "git diff > somefile.patch" or by committing it to your local repository and using "git format-patch -1" to create a formatted patch for the topmost commit. Some git-fu may be necessary, so I usually just use "git diff".That's all there is to it! You'll be a JRuby contributor in no time! [Less]
|
Today David R. MacIver pinged me in #scala and asked "headius: Presumably you guys have spent quite a lot of time trying to make things like system("vim") work correctly in JRuby and failing? i.e. I'm probably wasting my time to attempt similar?"My
... [More]
first answer was "yes", since there's no direct way to exec a program like vim (which wants a real terminal) and have it work on the JVM. The JVM's process launching gives the newly-spawned processes the child side of piped streams, which you then have to manually pump (which is what we do in JRuby's system, backtick, and exec methods). Under these circumstances, vim may start up, but it's certainly not functional.But then I got to thinking...if you were doing this in C, you'd fork+exec and all would be happy. But we can't fork+exec on the JVM..OR CAN WE?As you should know by now, JRuby ships with FFI, a library that allows you to bind any arbitrary C function in Ruby code. So getting fork+exec to work was a simple matter of writing a little Ruby code:require 'ffi' module Exec extend FFI::Library attach_function :my_exec, :execl, [:string, :string, :varargs], :int attach_function :fork, [], :intend vim1 = '/usr/bin/vim'vim2 = 'vim'if Exec.fork == 0 Exec.my_exec vim1, vim2, :pointer, nilend Process.waitallRunning that with JRuby (I tried master, David tried 1.3.0RC1, and 1.2.0 works too) brings up a full-screen vim session, just like you'd expect, and it all just works. No other JVM language can do this so quickly and easily.We'll probably try to generalize this into an optional library JRubyists can load (require 'jruby/real_exec' or similar) and perhaps add fork and exec to jna-posix so that the other JVM languages can have sweet, sweet process launching too.JRuby rocks. [Less]
|