Archive for the ‘Journal’ Category

JRuby and Sinatra in 2 Minutes

Saturday, July 17th, 2010

While at RubyMidwest I decided to explore Sinatra in more detail. I’ve spent a lot of time with Rails, and while I love it, there is something alluring about the simplicity of Sinatra (and, well… ooh shiny). Being a recovering Java developer (Hi, I’m R.J., and I haven’t developed in Java for 18 hours) I have a server that runs Java, and would like to be able to use Sinatra to build my fancy-awesome web-apps. On those lines, I want all of the shiny benefits of JRuby’s multi-threading awesome-ness, as opposed to just trying to use WEBrick, which does not a powerful server make. So here is a 2 minute tutorial (well, depending on the performance of your computer, and how fast you type) startup with Sinatra, JRuby, Bundler, and Glassfish.

I’m cheating already by assuming you already have JRuby installed as your default Ruby installation. No? Go get it!

Next step is to get bundler:

1
gem install bundler

Now we need to make a home for our application, and prep it for Bundler:

1
2
3
mkdir testapp
cd testapp
edit Gemfile

Here I’m creating a new file in testapp called ‘Gemfile’ in your favorite editor. This is where we will sketch out our dependencies for Bundler to do all the hard work for us – here are the contents for this example:

1
2
3
source :rubygems
gem "sinatra"
gem "glassfish"

Frankly, that’s it. We tell Bundler to look for gems in RubyGems core repo, and then we ask it to make sure we have Sinatra and Glassfish. Now we can create the program – create the file ‘hello.rb’, and use these contents:

1
2
3
4
5
6
7
8
9
require "rubygems"
require "bundler"
Bundler.setup

require "sinatra"

get '/hi' do
    "Hello World!"
end

So what’s special for JRuby? Absolutely nothing. We do have special sauce for Bundler, (by calling Bundler.setup prior to the require for ‘sinatra’) but trust me – you’ll be happy you used it. You’ll also make @wycats happy.

And – that’s it! Now, if you were to start this file the standard (well, bundler-standard) way, we’ll see this:

1
2
3
4
5
realjenius$ bundle exec hello.rb
== Sinatra/1.0 has taken the stage on 4567 for development with backup from WEBrick
[2010-07-17 11:24:46] INFO  WEBrick 1.3.1
[2010-07-17 11:24:46] INFO  ruby 1.8.7 (2010-06-06) [java]
[2010-07-17 11:24:46] INFO  WEBrick::HTTPServer#start: pid=44490 port=4567

…and we can visit this URL: http://localhost:4567/hi. But, recall that our goal was to work with Glassfish, not WEBrick. All that has to change (and for folks who has done Glassfish/Rails before, this won’t be a surprise) is to run this startup instead

1
2
3
4
5
6
7
realjenius$ bundle exec glassfish
Log file /Users/realjenius/Projects/testapp/log/development.log does not exist. Creating a new one...
Starting GlassFish server at: 0.0.0.0:3000 in development environment...
Writing log messages to: /Users/realjenius/Projects/testapp/log/development.log.
Press Ctrl+C to stop.

Running sinatra

This time, we’ll visit this URL: http://localhost:3000/hi, and if all worked as desired, Sinatra will be crooning away. Boom goes the dynamite.

Upgraded to WordPress 3.0

Thursday, June 24th, 2010

I just completed the upgrade to WordPress 3.0. So far, the upgrade appeared to go seamlessly. Everything is running, no plugins are complaining, yadayadayada. If you have a problem on the site please be sure to let me know.

If you are a WordPress user, and want to see what has changed since 2.9, here is a lovely screencast that covers the particulars:

The Ides of March

Saturday, March 13th, 2010

So Monday is my birthday: March 15th. For years I remember two things about the way adults reacted to me as a child: (1) Oh, your name is R.J.! That’s just like Dallas! (and for the record, no, no it is not). Or (2) Oh my! You were born on the Ides of March!

It’s funny, because when I was a kid, I had no idea what the ides of march was; I just knew it carried with it a certain degree of playful dread, given the reaction of adults. As I’ve gotten older, I’ve learned a lot more about what the day actually is, and not what people seem to attribute to it.

If you have no idea what I’m talking about, I’m not surprised. It seems like the superstition around the date has faded in recent years. Historically speaking, the term ‘ides’ meant the middle of the month for either Martius (March), Maius (May), Quintillis (July), or October on the Roman calendar. On the Ides of March, the Romans actively celebrated for Mars, the god of war (who, by the way, is awesome). (more…)

Check Out the Play Framework

Monday, March 1st, 2010

play
I’ve spent a lot of time recently investigating a variety of languages other than Java, such as JRuby and Scala, and truly believe from these experiences that traditional Java MVC web frameworks are inherently flawed in design and implementation. The effort involved in implementing on a framework like Struts or Spring MVC is astronomical, especially if you are going to implement things “the right way”.

It’s amazing to me how much these platforms push “hello, world” examples that are simply not realistic web applications. After trying these short examples, developers turn around and start trying to implement a complete application, and this simple example balloons into a mess of code, and that’s without any real functionality yet in the application. A co-worker of mine is a fan of saying “[These frameworks] make the simple things trivial, and the hard things impossible”.

Historically, I’ve been known to say “If you are doing web-development in Java, use Wicket“; this was based on the fact that to my experience Wicket took the most advantages from the strongly-typed, and strongly IDE-supported, Java language, as opposed to trying to hide them behind anemic and broken templating languages that have horrid editors and basically trade one problem for another.

Recently, however, I spent some time doing some significant development with the Play Framework. I have to say that I think the Play Framework has eclipsed my Wicket fever. That’s not to say that I don’t still think Wicket is very powerful, but I have been particularly impressed with the feedback loop provided by Play. It has, without a doubt, the most direct code-test-cycle I have seen in any platform for Java (it approaches the instant feedback of Rails), and also has the distinct advantage of being stateless out-of-the-box (something Wicket is definitely not).

Play manages this feedback loop problem in a rather novel way – embedded in the framework is the Eclipse compiler for Java (ECJ). This means that when you’re coding for the play framework, you’re not sending it your class files, but rather your source files. This allows Play to recompile code in a running instance on the fly – I literally only restarted my application a handful of times while I was coding over the course of several days. It also integrates seamlessly with IDEs, and ships with an embedded HTTP runtime (no deployment is necessary during development).

There are a number of other benefits Play can provide by working with source files instead of class files. Much like Rails ability to add functionality to your application at runtime, Play can (and does) pre-process certain Java classes to add functionality.

I was further heartened to see that the next release of Play is meant to fully support Scala, which would allow for other modern language features to be used with this highly interactive framework.

It’s hard to describe all of the neat features Play provides in a few hundred words, but I would highly recommend you check it out – they have a 10 minute screencast they sells it better than I can. While I’m still convinced Java (as a language) will be surpassed for an overwhelming majority of the web-development as the language continues to stagnate, this is a compelling framework for the Java platform as a whole, even if Java isn’t your language of choice.

Fistful of Awesome: IntelliJ Open-Sourced

Thursday, October 15th, 2009

In a surprising move, the JetBrains team has decided to open-source the JavaSE portions of IntelliJ IDEA 9.0 and beyond under an Apache 2.0 license. They will begin offering two products, a community edition, and an ultimate edition:

Starting with the upcoming version 9.0, IntelliJ IDEA will be offered in two editions: Community Edition and Ultimate Edition. The Community Edition focuses on Java SE technologies, Groovy and Scala development. It’s free of charge and open-sourced under the Apache 2.0 license. The Ultimate edition with full Java EE technology stack remains our standard commercial offering. See the feature comparison matrix for the differences.

Very cool news! The impact in competition for other IDEs (namely Eclipse and NetBeans) remains to be seen, but this certainly brings another aggressive (and already well-liked competitor) to a broader market.

WordPress 2.9 Beta Testing Call to Arms

Tuesday, October 13th, 2009

wordpress-logo-stacked-bg

“For a limited time only – you can beta-test WordPress 2.9 from the comfort of your own installation!”

In the “another reason I like WordPress better for blogging” category, the folks over at WordPress.com have published a detailed article on how WordPress users can get involved in the beta-testing of WordPress 2.9 – the next major release. Included in the options for aspiring beta-testers is a plug-in that will automatically upgrade your site to the new version, and will keep you on the up-and-up. (more…)

What Am I Downloading Today, Eclipse?

Thursday, October 8th, 2009

With the release of Eclipse 3.5, the plugin installation and update manager was completely revisited once again; the update process was reorganized, and the strengths of the p2 provisioning framework were surfaced. It’s nice to be able to hop in, download updates, and go.

However, I think Eclipse, as a product, still has a way to go. (more…)

Danny Carey at Drum Explorers Clinic

Friday, October 2nd, 2009

d_careyAs most of my close friends know, while having only recently picked up any form of drum stick, I’m passionate about drumming (though I’m personally still a beginner in my ability to play). One of my favorite modern drummers is Danny Carey; I’m sure in no small part due to Tool being one of my personal favorite bands. Even if I attempt to exclude my bias, however, I can see that Carey is a well-admired drummer, generally somewhere in the top 15 of top-100 drummer lists of all time; sharing space with the likes of Neil Peart, John Bonham, Keith Moon and Mike Portnoy.

Danny Carey has a rare technical accuracy in his playing, but he is able to combine it with his singular artistic flair to create remarkable tapestries of sound. Tool songs are initially accessible to listeners in search of a driving rock sound, but continue to breathe and grow as the complex rhythms unravel over time.

I’m always amazed to pick up an album like Undertow (from 1993) and to this day still hear new  poly-rhythms in the beat and other minor adjustments for the first time. And it only takes listening to a song like Jambi, where the guitar, vocals, and drums are all on entirely different time signatures to be able to understand how capable he really is.

Recently, Danny Carey came into Kansas City for the 25th anniversary of KC Drum Explorers. He gave some tutorials, played along to some particularly drum-intensive Tool songs, and also had some great company: Terry Bozzio (another brilliant drumer) and Aloke Dutta (a wizard of the tabla, and mentor and teacher to both Carey and Bozzio).

I have no idea how I missed hearing of this event; it was mere minutes from my house (in a high-school auditorium in suburban Overland Park of all places), but thankfully YouTube has come to the rescue to make me feel like something other than a total failure.

I’ve dug up some videos of the event, and included them here (thank you evo462, jdub816, and andrewl85). Enjoy! (more…)

JRuby 1.4 Plan Details Discussed

Monday, September 21st, 2009

Ruby LogoThe JRuby team has posted some key JRuby 1.4 details over at the Engine Yard blog.

Of high-level note:

  • Ruby 1.8.7 is the new Baseline – This promises a number of library changes and backports from 1.9. To see the 1.8.7 changes you can look here.
  • Ruby 1.9 Compatibility Improvements - As mentioned in the blog entry, Ruby 1.9 is a moving target, however they are moving a lot closer to having major libraries working as desired. Some high-visibility features (like Fibers) are still on the pending list, however.
  • New YAML Parser - Ola Bini re-visited the YAML parser in Ruby recently (he has blogged about the creation of the new parser and how he ported it). The new parser, Yecht, is said to be completely compatible with Syck (the Ruby parser), warts and all.
  • Java Method Dispatch Improvements - One of the major promised features of 1.4 for quite a while has been improvements to the Java integration; they have been wanting to formalize this portion of the language for sometime. This involves calling Java methods, calling overloaded Java methods, the coersion of types (Java string <–> Ruby string), etc. Charles Nutter has posted a very detailed, developer-centric breakdown of the plans in this integration on the Developer mailing list (which goes beyond what’s available in the blog entry). Certainly an interesting read.
  • Java Class Generation via JRuby - JRuby will finally be able to construct runtime-available Java classes on the Java classpath. This will be available on-demand only, however that could be quite handy in a number of difficult integration scenarios.

This set of features is exciting to me, particularly for the Java integration features. The current Java integration functions, but can be somewhat tempermental, and can end with surprising results at times (I have learned this the hard way via hand-coding Swing and SWT apps).

Additionally, one of the killer features of Scala, in my opinion, is its ability to interact seamlessly with Java libraries at compile-time (create a class in Scala, and code against it in Java). While the semantics defined for JRuby are more runtime-centric for now, it does provide an ability to construct something that can be fed into Java APIs at runtime that expect certain “inferred” contracts to exist (such as the Jersey example they used in the original post).

Android Quick Search Box Details

Sunday, September 20th, 2009

droid
The Android folks have posted more details about the ‘Quick Search Box’ feature of 1.6 Android.

One of the new features we’re really proud of in the Android 1.6 release is Quick Search Box for Android. This is our new system-wide search framework, which makes it possible for users to quickly and easily find what they’re looking for, both on their devices and on the web. It suggests content on your device as you type, like apps, contacts, browser history, and music. It also offers results from the web search suggestions, local business listings, and other info from Google, such as stock quotes, weather, and flight status. All of this is available right from the home screen, by tapping on Quick Search Box (QSB).

This post is largely targeted towards application developers (which now have the 1.6 SDK) who should be seriously considering about integrating their app into the quick search box.

It seems fitting that the Google mobile OS would have a ubiquitous search mechanism like the text bar in Google Chrome, and for that matter, like most people use Google.com.

One additional note – if you are like me, you may have previously heard there were concerns that the faithful G1 early-adopters may not get Android 1.6 in all of it’s donut-y glory because the G1 couldn’t handle it. Thankfully, it appears that may not be the case anymore.