Posts

Showing posts with the label JRuby

Using the Microsoft Translation APIs from Java, Clojure, and JRuby

I wrote last July about my small bit of code on github that wrapped the Microsoft Bing Search APIs. I recently extended this to also wrap the Translation APIs using the open source project microsoft-translator-java-api project on Google Code . I just provide a little wrapper for the microsoft-translator-java-api project and if you are working in Java you should just use their library directly. Hopefully this will save you some time if you need to use the translation services. The free tier for the translation services is currently 2 million characters translated per month.

Alternative JVM languages

I am enjoying Martin Odersky's course "Functional Programming Principles in Scala." I use JRuby and Clojure a lot in both consulting projects and my own projects but my main use of Scala in the past was writing some programming examples for my book "Practical Semantic Web and Linked Data Applications, Java, Scala, Clojure, and JRuby Edition" that is available here for free. I had purchased three Scala books and occasionally played with Scala but it never really "clicked" with me (same situatuon with Haskell: bought three books on Haskell, lots of experiments, never had the "clicked" experience). Taking Martin's class is definitely helping me become more comfortable with Scala. Having an interactive repl for Clojure and JRuby has always been a big win for me over Java development, even with great Java tooling (e.g., when I have to do GWT or SmartGWT development, having both the server and client side code in Java, all debuggable in I...

Ruby Sinatra web apps with background work threads

In Java-land, I have often used the pattern of writing a servlet with an init() method that starts up one or more background work threads. Then while my web application is handling HTTP requests the background threads can be doing work like fetching RSS feeds for display in the web app, perform periodic maintenance like flushing old data from a database, etc. This is a simple pattern that is robust and easy to implement with a few extra lines of Java code and an extra servlet definition in a web.xml file. In Ruby-land this pattern is even simpler to implement: require 'rubygems' require 'sinatra' $sum = 0 Thread.new do # trivial example work thread while true do sleep 0.12 $sum += 1 end end get '/' do "Testing background work thread: sum is #{$sum}" end While the main thread is waiting for HTTP requests the background thread can do any other work. This works fine with Ruby 1.8.7 or any 1.9.*, but I would run this in JRuby for a lon...

Nice: Neo4j version 1.2 final released

Neo4j is a high performance graph database that I usually use with the JRuby neo4j gem and sometimes with Clojure ( documentation here ). Neo4j is open source (AGPL v3) and is alternatively available for a reasonable fee with a commercial license (where you don't need to AGPL your project). I took advantage of the free offer to get your first Commercial Basic Server license, even though I am likely to open source my project anyway.

A great way to get around the long loading request times on AppEngine

I wrote yesterday about my experimental project my-foc.us that is currently a prototype app running on Heroku. In parallel, I wanted to experiment with doing an AppEngine deploy but I got rather frustrated this morning by the both long and unpredictable cold loading request times. Even with some clever new work to manage the load time of JRuby apps, there is still a lot of work to be done to get the cold request load times under a reasonable limit (perhaps a three or four seconds?). I think that Python AppEngine apps have the fastest cold request load times but I am not Python developer (very rusty!). I tried a Java app and the load times were very much better that JRuby, but then I ran across a great project that reduces the load time for Java apps by not using JDO and instead using the light weight objectify-appengine project. I am not sure what is the best way to accurately measure cold loading request times except for letting an app get swapped out (wait a few minutes with no r...

JVM: JRuby's advantages over Clojure and Scala

Don't get me wrong, since using Clojure and Scala quite a lot over the last month, I very much like both languages. If I were to do a very large project from scratch, I would likely choose Scala (love the concise syntax). Clojure's interop with Java is great and Clojure is a nice language to code in. Both languages have helpful communities behind them. All that said, I saw two things this morning that convinced me that JRuby has a real advantage because it combines the rich Java and Rails infrastructures. These two cool things were: Using Datamapper with two different back end stores (MySQL and MongoDB) - architectually pleasing! The Neo4j + Lucene JRuby wrapper that provides a very "Ruby like" interface for the Neo4j graph database with seemless indexing/search support using Lucene (I just did something similar wrapping Lucene and Sesame (RDF data store)).

New (very) rough drafts available for both Java and Lisp editions of "Practical Semantic Web and Linked Data Applications"

While I have been following Semantic Web technologies for over 8 years, I find the slow adoption to be frustrating. I am trying to do my part to promote the Semantic Web by writing two editions of "Practical Semantic Web and Linked Data Applications." One edition has examples in Java/Clojure/Scala/Jruby and the other has examples written in Common Lisp. There is a lot of common material in both editions so I expect people to only read the edition that covers their favorite programming language. I will sell physical print books via lulu.com and there will always be free PDF versions on my Open Content web page. I hope to have the Java/Clojure/Scala/Jruby edition finished by early April and the Common Lisp edition finished sometime in early summer. I just posted PDFs for both editions. That said, these are very rough cuts, with large sections still to be written. There are a lot of very good Semantic Web tools and frameworks - both open source and commercial. I am using the co...

The beauty of Latex: my AllegroGraph book becomes two books, one for JVM languages and one for Lisp

Image
I have been working on and off for 16 months on a book about Semantic Web (or Linked Data) application programming using the AllegroGraph product. I have decided to substantially increase the scope of this applications/tutorial style book to also include support for Sesame . The figure on the left shows the software architecture road map for the book using JVM languages. I am splitting the book into two volumes, and using Latex makes this really easy to share small amounts of common material so both books stand on their own. Latex also makes it easy to combine both books into one all-inclusive book, eliminating the duplicated parts. The two volumes are: Volume I: will cover the use of both AllegroGraph and Sesame using JVM languages: Java, Scala, JRuby, and Clojure. I am working on a common wrapper written in Java that supplies my own (rather simple) API to both AllegroGraph and Sesame. My wrapper implements Sesame support for geolocation and free text indexing and search so the wrapp...

Using nailgun for faster JRuby startup

I finally got around to trying nailgun tonight. On OS X with JRuby 1.4.0RC2, I built nailgun using: cd JRUBY_HOME/tool/nailgun ./configure make # I ignored the warning "no debug symbols in executable (-arch x86_64)" In one terminal window just leave a nailgun server running: $ jruby --ng-server NGServer started on all interfaces, port 2113. When you want to run JRuby as a railgun client, try something like: jruby --ng text-resource.rb On my MacBook, this cuts about 5 seconds of JRuby startup time off of running this test program. Sweet. For small programs, using ruby is still faster than jruby but this makes developing with JRuby faster.

Glassfish v2: Update Center and port 4848 Web Admin are cool, but...

Although I have been paid to work on both the Enhydra Enterprise Java application server and on the JBoss based Jaffa framework, I must admit that Tomcat has always been my favorite platform: lean, and add just what I need. As a result of my 'build up just what I need' preferences, I just got around to experimenting with Glassfish. The Update Center is great, and as more instant install frameworks and applications become available, this will be a time saver. The web admin tool is refined - no complaints there. I do have one complaint about the 200 MB resident memory footprint. A lot of what I do involves deploying to low cost servers, often semi-managed VPS systems. Smaller memory use is cheaper, but for most large server deployments, an extra 100 MB makes no difference. I thought that it was very cool that one of the available instant install components is JRuby with the most excellent Goldspike. I have written before in this blog about the ease of running Rails web apps with ...