JEvalCharter
JEval, the Java, open source, expression evaluation library that I wrote a number of years ago is still alive and kicking. Someone has taken the library and integrated it with a charting tool to create, JEvalCharter. Its cool to see that JEval is still providing value to developers out there. Its also neat to see that JEval have been getting 100+ downloads a month.
The Next Big Language: For the Enterprise or the Masses?
There’s a lot of talk these days about what will be the next “big” language. A lot of my fellow Java developers believe its going to be a language that runs on the JVM. Will it be Scala, Clojure, JRuby or some other language that has yet to be written? I think when we have such discussions, we need keep in mind that while the JVM may be the most popular platform for enterprise software development, its not the most popular platform for general purpose Web development. That distinction goes to LAMP and PHP.
Wordpress, Joomla, Drupal and many other immensely popular blogging and CMS software packages are mostly written in PHP and run on Apache servers. And there are countless Web hosting companies that will host applications running on these software packages for less than $10 a month.
I was recently looking into options for creatng an online store. If I were to go the JVM/Java route, I would need to mostly write that store myself or purchase expensive software to implement it with. I would then need to pay a high monthly fee to host the application on a JVM. This would be fine and probably desirable for a large Fortune 1000 company or a Web startup with lots of funding. However, for myself, I want to start with something I can develop as cheap and quickly as possible. With the popular PHP tools I mentioned, I can find multiple free or very low cost ecommerce plugins and themes I can install and have hosted for a small monthly fee. These tools also create Web sites that look attractive, modern and professional.
Although the JVM and Java has revolutionized software with its ability to run on many operating systems, its dominance is only in large enterprise business software. If there is to be a next “big” language, I think possibly it will be one that can bridge the gap between enterprise software and the general purpose software used by the masses.
Introduction to Scala
I gave an Introduction to Scala talk yesterday for the software team I am a member of. I have included here the slides and code examples used in the presentation.
Presentation
Code Examples
Hello World
package org.breidecker.scalaexamples
object HelloWorld {
def main(args : Array[String]) : Unit = {
println("Hello World!")
}
}
// Notes:
// 1. main method is required to run
// 2. ": Unit =" is optional
// 3. Unit in Scala's is similar to Java's void
Hello World #2
package org.breidecker.scalaexamples
object HelloWorld2 extends Application {
println("Hello World!")
}
// Notes:
// 1. Application provides the main method
// 2. The println statement is in the object's constructor
Accessors
package org.breidecker.scalaexamples
object Accessors {
def main(args : Array[String]) {
val person = new Person;
person.firstName = "" // Try different values here
person.lastName = "Smith"
println("Hello " + person.fullName + ".")
}
class Person {
private var theFirstName = ""
var lastName = ""
/* Overide the first name getter. */
def firstName = theFirstName.toUpperCase
/* Override the first name setter. */
def firstName_=(firstName : String) {
if (firstName != null && !firstName.trim.isEmpty) {
theFirstName = firstName
} else {
throw new IllegalArgumentException("First Name must contain a value.")
}
}
def fullName() : String = (firstName + " " + lastName).trim
}
}
// Notes:
// 1. The firstName property on the Person class is providing accessor method for the property
// 2. The instance variable for firstName had to be renamed to avoid a name conflict with the getter method
// 3. The lastName property is being referenced in the main method with its default accessors provided by Scala
List Comprehension
package org.breidecker.scalaexamples
object ListComprehension {
def main(args : Array[String]) {
for (val color <- Colors.ALL_COLORS) {
println(color.name)
}
}
/* This is an immutable class */
class Color(newName : String) {
val name = newName
}
/* This is a Scala singleton object */
object Colors {
/* These are Scala constants. */
val blue = new Color("blue")
val green = new Color("green")
val red = new Color("red")
val yellow = new Color("yellow")
val ALL_COLORS = List(blue, green, red, yellow)
}
}
// Notes:
// 1. This example simply shows how to iterate over a list of values in Scala
Twitter Client
package org.breidecker.scalaexamples
import java.net._
import scala.xml._
object TwitterClient {
def main(args: Array[String]) {
val screenName = "robbr" // Follow me! Try another Twitter name
val url =
new URL("http://twitter.com/users/show.xml?screen_name=" +
screenName)
val conn = url.openConnection
val xml = XML.load(conn.getInputStream)
val status = (xml\"status"\"text").text
println(screenName + ": " + status)
}
}
// Notes:
// 1. Scala uses an underscore instead of an asterisk for its package wildcard character
// 2. Java's network package is imported
// 3. Scala's built-in XML library is used
// 4. This example makes a URL request to Twitter for the current screen name
// 5. It then uses an XQuery like statement to reference status text
JEval 0.9.4
I couldn’t finish the year without writing one last post about JEval. A new maintenance release is available. For whatever reason JEval’s download rate had more than doubled over the last couple of months. The number of downloads has now exceeded 1500.
Thinking in Stacks (Revisited)
This is the third of three previously published articles related to Java web frameworks that I am republishing. This one is from about fifteen months ago. Choosing the correct stack of software to support a web framework is important. You can either build your own stack or choose from an already integrated stack.
———————-
The number and diversity of Java frameworks (and web/MVC frameworks in particular) is a great thing. But along with choice also comes drawbacks. Which frameworks do I choose for a new web application? Project X is using frameworks A, B and D - do you know these? Are they production worthy? I have heard for every project you should choose the best tools (or frameworks) for the job. Really? I tend to agree to an extent. But is one Web application so different from the next that I need to reevaluate which frameworks I use on each new project?
This leads me into what I really want to discuss. I believe there has been a positive development in the Java world, in that popular “stacks” of open source software are beginning to emerge for developing web applications. I am defining “stack” as simply “multiple software frameworks integrated and used together”. Wikipedia defines a similar term, solution stack. Should project teams start making stack selections instead of framework selections? While frameworks maybe should ultimately be selected based on their individual merits, I think a popular stack can be a great place to start. Some of the benefits of using a popular stack include: accelerated startup time, reduced learning curve, increased software quality and increased knowledge base. So far, I see three stacks emerging as the most popular.
The first stack is the Spring/Hibernate stack. Maybe this one is the most obvious. Over the last fews years Spring and Hibernate have become so popular that they have almost knocked EJB2 out of existence on new projects and forced the creation of the new EJB3/JPA specification. I think this stack is still maturing, in that projects are adding everything Spring has to offer in addition to the already popular Spring IOC and Spring Transaction frameworks. By that, I mean using Spring MVC for the web tier, Spring Web Flow for work flow and any other Spring frameworks that are found to be useful. Maybe I should simply call this stack the “Spring stack”. It should be noted that the very promising Grails framework is built on top of Spring MVC, Spring IOC/Transaction and Hibernate.
The second stack is the JBoss Seam stack, which is basically a stack by definition. JBoss Seam ties together the JSF framework specification, using MyFaces for its default implementation, to the JPA specification, using Hibernate (another JBoss product) for its default implementation. The JBoss Seam framework itself adds work flow and other capabilities to the middle of the stack. Other JBoss frameworks like JBoss Rules can easily be integrated into the stack. If you like the idea of working with J2EE specifications and tools designed for J2EE specifications, then this stack may be the one for you. A big positive of using JBoss Seam is that it reportedly handles of lot of issues developers encounter when working with JSF.
The final stack is the Ruby on Rails (RoR) stack. JRuby 1.0 has just been released and is expected to execute close to if not 100% of RoR applications on the Java platform. The increasingly popular and much imitated RoR gives you everything you need in one package, with ActiveRecord for persistence along with MVC functionality and much more. If you have ever read or listened to interviews with RoR creator, David Heinemeier-Hannsen, you might recall him talking about why he created RoR as a way to quickly create a new web application without having to start from scratch. David wants RoR to give you everything you need to create a web application right out of the box, with little or no configuration, so you can focus on the business logic and not the underlying framework code. I mentioned that the Grails framework/stack is built on the top of the Spring/Hibernate stack. Grails is a Java implementation of a RoR like framework.
This discussion wouldn’t be complete if I didn’t mention the AppFuse project. Created by Matt Raible, AppFuse let’s you quickly create an application skeleton using various combinations of the most popular Java frameworks. Without going into too much detail, you can choose from four popular Java web frameworks (Struts2, JSF, Spring MVC and Tapestry) and three Java persistence frameworks (Hibernate, iBatis and JPA). Spring is used to tie everything together. I think of AppFuse as being a nice alternative to choosing one of the above stacks, while still getting many of the same benefits.
The downside to the emergence of these popular stacks is there are some great frameworks not included in these stacks and not getting as much attention as a result. A few that come to mind are Struts2, Tapestry, Wicket, Rife, Guice and Google Web Toolkit. While I feel having a small number of popular stacks is a good thing, I also see diversity and innovation as good things. I guess you have to make a choice between what is most important to you, starting with a small group of popular technologies, or selecting from the latest and greatest.
If stacks truly become the way the Java community prefers to view software in the future, I think we’ll start to see the creation of new frameworks slow down and a lot more activity continue around the already popular stacks. In true Java tradition, perhaps there will even be a couple new stacks show up in the next year (Google stack anyone?).
JEval Eclipses the Century Mark
My open source, Java expression evaluation project, JEval, has now been downloaded 1,100 times in about the last 18 months. Thats nowhere near the numbers the big projects get, but with over 50 downloads per month, I feel pretty good about the level of interest.
Hell Freezes Over
Microsoft has donated $100,000 to the Apache Software Foundation. Apache is the home to widely used open source software projects such as the Apache HTTP Server, Tomcat, Ant, Struts/Strut2 and Tapestry.
Open Source Success Story, Red Hat
In the past I’ve explained to friends that were either against or did not understand open source software, that it is simply an alternative business model for competing again software companies selling proprietary software. Of course there are other, more purist reasons for those who advocate open source. However, I think this works for people simply trying to earn a living through software.
JEval Update
Since my JEval open source project was released on February 21, 2007, it has been downloaded 464 times. Far from staggering numbers. I doubt I will writing a book on it anytime soon. However, shortly after the release I got some positive feedback, which was cool and its still nice to see downloads every week.
What does JEval do you ask? Its a simple, lightweight functional expression parser and evaluator. And It has NO dependencies to any other libraries.
A few quick code examples:
Evaluator evaluator = new Evaluator();
String result = null;
// A mathematical expression.
result = evaluator.evaluate(”4 + (3 * 1) - (3 + 1) + 1″);
System.out.println(result);
// A built-in mathematical function.
result = evaluator.evaluate(”1 + abs(-1)”) ;
System.out.println(result);
// A string expression.
result = evaluator.evaluate(”‘A’ + ‘C’”);
System.out.println(result);
// A built-in string function.
result = evaluator.evaluate(”trim(’abc ‘) + ‘d’”);
System.out.println(result);
// A boolean expression.
result = evaluator.evaluate(”((2 < 3) || (1 == 1)) && (3 < 3)”) ;
System.out.println(result);
// A variable.
evaluator.putVariable(”a”, “‘Hello’”);
evaluator.putVariable(”b”, “‘World’”);
evaluator.evaluate(”#{a} + ‘ ‘ + #{b} + ‘!’”);
System.out.println(result);
// A nested function using a built-in mathematical function.
result = evaluator.evaluate(”atan2(atan2(1, 1), 1)”);
System.out.println(result);
// A custom function.
evaluator.putFunction(new StringReverseFunction());
result = evaluator.evaluate(”stringReverse(’Hello World!’)”);
System.out.println(result);
Download here.
