April 16, 2008
The new Groovy book by Venkat Subramaniam has been released recently. It’s called “Programming Groovy: Dynamic Productivity for the Java Developer” and has the most detailed coverage of the Meta-Object Protocol (MOP), one of the coolest and most powerful features of Groovy.
Details about the book can be found here.
A first review can be found here.
Buy the book via amazon.com
Posted in Groovy, Java
No Comments »
March 4, 2008
I’ve just read the great news. Sun hired Ted Leung and Frank Wierzbicki to work in Python and Jython. Also check out Charles Nutter’s blog announcement.
This is exciting news for Python.
Posted in Python
No Comments »
February 9, 2008
Python has received a lot of attention from web developers during the last years, most due to the appearance of new frameworks that often drastically improve developer productivity.
I’ve compiled a list of useful resources for web developers getting started with Python web programming. The list also includes the frameworks I consider the most useful for Python web developers. Enjoy the lists.
General stuff
WSGI. WSGI stands for Web Server Gateway Interface and is a Python standard for the communication between web servers and web applications. It’s supported by several Python web frameworks.
Paste. A set of WSGI tools.
CGI scripts with Python. Sometimes a simple CGI script will do.
Database interaction
Python supports interfaces to all common databases including the open source databases MySQL and PostgreSQL. As almost all web application also use a relational database, I’ve included the most important resources for Python and database interaction.
Pytohn Database API Specification 2.0. If you want to do the low level stuff yourself, you should learn the Python Database API Specification 2.0. Almost all libraries that interact with a specific database support this API.
Supported Databases. Here you will find a list of supported database systems.
SQLAlchemy. SQLAlchemy is IMHO by far the best database library for Python developers. It includes a powerful OR Mapper and many other goodies. It is also supported by several of the web frameworks mentioned below. If you’re using Python for any serious database interaction, you will love SQLAlchemy.
SQLObject. SQLObject is another popular OR Mapper for Python. I prefer SQLAlchemy but SQLObject is also a wonderful piece of software and definitely worth checking out. The next Version is called SQLObject 2.
Web frameworks
Webware for Python. Webware has been around for quite some time. It’s somewhat similar to Java Servlets and Java Server Pages. Although a good framework, it never really god a popular as the following frameworks.
TurboGears. TurboGears is a popular and powerful framework, building on the foundation of other tools like SQLObject, CherryPy and others. Future versions will also support SQLAlchemy. To stay up to data about what’s going on, follow Planet TurboGears
Django. Django is another very popular and powerful web framework. Together with TurboGears it’s the most popular framework among Python fans. Definitely worth checking out. Also have a look at the free Django Book.
Pylons. Pylons is another wonderful framework worth a closer look. It allows you to use your favorite Python libraries. You can choose among several OR mappers including SQLAlchemy, many templating systems and AJAX libraries.
web2py. Another new and interesting framework.
Comparisons
I’ve also included some comparisons of the above mentioned frameworks either with each other or with Ruby on Rails. The comparisons are sometimes already two years old which is quite a lot in the software world, but they may still give you an overview about the difference between the various frameworks.
Django vs. TurboGears. A comparison between Django and TurboGears.
Performance comparison. Performance comparison between Django, Ruby on Rails and PHP’s Symfony.
Rails vs. Django. A Rails vs. Django comparison in various formats.
TurboGears vs. Rails. A balanced, but somewhat dated comparison between Rails and TurboGears.
Useful Blogs and Python sites
Ian Bicking. Ian Bicking is a very active member of the Python community, involved with several Python projects like SQLObject, Paste and more. His blog contains many useful articles and is always a pleasure to read.
The Daily Python URL. A site with many useful current information about Python updated almost daily.
I hope that list was helpful. If you think there is anything missing, please leave a comment.
Posted in Python
6 Comments »
February 5, 2008
I’ve just read Billy Burke’s Dynamic Languages: Rationalizations and Myths. Very interesting read. Bill has many good points. I especially agree with him about the importance of great thread support. Java clearly is better here than current Ruby, PHP or Python implementations. (unless you use JRuby or Jython).
But I think Bill misses something.As I wrote in my last post, it’s the framework that’s more important than the language. For many websites Rails or Grails are a perfectly good solutions. I wouldn’t use them to build the next Amazon, but for many projects they have proven themselves very powerful and productive.
About the advantage or disadvantage of static vs. dynamic typing: I think this is a matter of taste. Some argue that writing good unit tests are more important than relying on a compiler. Others say that Java is not that typesafe anyway, otherwise there would not be a ClassCastException. I think both approaches have their advantages. And both are here to stay. Learn both and pick what’s best for your job.
Posted in Groovy, Java, Python, Ruby
3 Comments »
February 4, 2008
Software developers like fighting over programming languages: Java vs. C++, Ruby vs. Groovy, Python vs. Perl and so on. Once they have settled on a language, they like to fight over frameworks: JEE vs. Spring, Wicket vs. JBoss Seam, Django vs. Turbogears.
I think the discussion over frameworks makes more sense than the discussions about languages. Not a stupid fight but a serious discussion.
Why ?
Because I think frameworks are more important than the language. Take Ruby, for example. It has been around a quite a long time, but only when Ruby on Rails appeared, did it become really popular.
Or Python. There had been many web frameworks for Python before Rails came along. But Python never really got interesting for web programming because all those pre Rails frameworks were not nearly as productive as Rails. Soon after Rails, new Python frameworks appeared, most notably Django (which is NOT a rails clone) and TurboGears. Suddenly Python became popular again among web developers.
Java had all the J2EE stuff, but for web application that was not enough. So Struts was born and took the Java world by storm. EJB 2.1 (and older) was also a framework, but never popular. When Spring came along, Java developers started to have fun again. Similar for JEE 5 with EJB 3.0.
Another powerful player emerged with JBoss Seam, which in my opinion is currently the best solution for Java web programming.
Groovy would never be as popular without Grails.
What Seam, Spring, Rails, Django, Grails and others have in common is that they all help programmers accomplish difficult tasks and focus more on the business logic. This is what most programmers want. They don’t care about low level stuff like cookie handling, socket programming or database connection pooling. Programmers want to focus on business logic because this is what customers are interested in. And customers pay the bill.
The conclusion off all this is, that a good framework is more important than a good language. If language A is much more productive than language B, but B has a great framework for a certain task and A doesn’t, I would go for language B with a great framework than for language A with no framework or a crappy one.
My advice for programmers is to ask what else does a programming environment offer beside a great language. Frameworks (and a good library as Java or Python have) are more important than some fancy programming languages features.
What are your thoughts ?
Posted in General
1 Comment »
February 2, 2008
Today I wrote my first Scala program. When I try a new language I always write an “eagle class” first. The reason is quite simple: I am totally fascinated by those huge birds. So here is my first Scala program with an eagle class.
package birds;
// wingspan is in cm
class Eagle(name: String, wingspan: Int) {
def fly() {
println("I am flying")
}
def fly2 = println("I am flying 2")
override def toString = name + " has a wingspan of " + wingspan + "cm."
}
object EagleTest {
def main(args: Array[String]) {
def goldenEagle = new Eagle("Golden Eagle", 220)
println(goldenEagle)
goldenEagle.fly
goldenEagle.fly2
}
}
I am still a completely new to Scala and don’t yet fully understand what’s going on here. On thing that’s different in Scala than in Java is the definition of a class. You don’t have to write a constructor. You define the parameters that are necessary to define an object right behind the class name. Scala also uses a different syntax for parameter names, using the form parameterName: type. If this is necessary for some reason or just suited the Scala developers better than the Java style, I don’t know.
Apparently it is also possible to define methods in different ways as you can see here with the fly and fly2 method. If there is a difference between those two, I can not yet say (I haven’t yet read all the Scala docs).
What’s also different from Java is the definition of the class (or better object) with the main method:
object EagleTest {
...
}
This defines a so called singleton object, which is a class with a single instance.
In the main method, we define an instance of an Eagle object (using a Golden Eagle as an example. Female Golden Eagles have a wingspan of about 220cm. Males are a little smaller). When we have our Eagle objects, we can let it fly, calling the two methods defined for the Eagle class.
So far Scala looks interesting, but I haven’t yet found out why I should prefer it over Groovy or Java. But it wouldn’t be fair to give such an answer right know, as I still have a lot to learn about Scala.
I will continue writing about my adventures with Scala
Posted in Scala
No Comments »
January 31, 2008
I just came across this Guide to the Scala Community. After reading it I downloaded and installed Scala on my Linux machine. Recently I’ve read a lot about Scala on sites like artima.com (they also published the first book on Scala) or the Scala on Netbeans posts on this blog.
I am completely new to Scala, but what I’ve read so far on the Scala website looks very interesting. In the future I hope to post my experiences while learning Scala. Someone told me it is great for multithreaded applications, a topic I am very interested in.
What are your experiences with Scala ? Is it worth learning ?
How is the Eclipse plugin ?
Posted in Java
No Comments »
January 30, 2008
Language wars can be fun. But one should not take them too seriously.
Recently there has been a lot of discussion, especially about Ruby and Java. A couple of years ago, it was mostly Java vs. C++ or Python vs. Perl.
I’ve been working as a programmer for about 8 years and I’ve used many languages, including Java, C, C++, Python, PHP, Ruby and Perl. Currently I use with Java almost exclusively at work and at home I use Java, Ruby and Python. I am also trying to get a deeper understanding for Groovy.
Which languages is the best ? None!!
Why not ?
A programming language is a tool and some tools are better suited for certain tasks, other tools better suited for other tasks. If I want to do low level Linux system programming, I would go for C or C++, but definitely not for Ruby. If I want to parse log files, I would use Groovy, Ruby or Python but not Java or C++. If I wanted to write a complex GUI application, I would prefer Java because Swing is great, Netbeans and Eclipse are great IDEs and Java is fast and platform neutral.
I too have my preferences. For example, I like Ruby more than Perl and Java more than C++ but I think it is important to know several programming languages so one can choose the appropriate tool for the given problem.
Unfortunately you can’t learn everything. Even if you know Java very well, to really be a Java master, you would also have to be very good with stuff like Hibernate, JEE 5, Swing, GWT, Spring and more.
For me the best strategy is to get a deeper understanding for some languages and tools (for me that would be Java and the ecosystem around it) but also know what other options are around. I think it’s good to see how others do it. If you’ve been programming web applications in Java for the last 5 years, it would be a good idea to see how Grails, Ruby on Rails or Django works. Learning new stuff will help you to get know ideas. Even if you continue working with Java, you will look at problems differently after playing with the just mentioned solutions.
Java is here to stay for many years. So there is no point constantly saying that it is doomed in the near future. Neither do I believe that Ruby or Python will go away anytime soon. And Groovy probably will have a bright future too. So I think the smartest thing to do is to spend some time with all those languages and some of the libraries and frameworks for them. You will always learn something.
And if you still want a language war, why not go back to Java vs. C++. I miss those times 
Posted in Groovy, Java, Python, Ruby
No Comments »
January 28, 2008
Recently I was listening to two programmers sitting close to me in a train. They were discussing the performance of String concatenation vs. StringBuilder. One said that it doesn’t matter anymore with new java versions. The other didn’t believe it. Neither did I and so I made a short and simple test.
Here are two methods:
public static void testStringPlus1() {
for (int i = 0; i < ITERATIONS; i++) {
String str = "";
List<String> strList = getRandomStringList(RANDOM_STRINGS);
for (String s : strList) {
str += s;
}
}
}
public static void testStringBuilder() {
String str = "";
for (int i = 0; i < ITERATIONS; i++) {
StringBuilder strBuilder = new StringBuilder("");
List<String> strList = getRandomStringList(RANDOM_STRINGS);
for (String s : strList) {
strBuilder.append(s);
}
str = strBuilder.toString();
}
}
the constants are defined like this:
public static final int ITERATIONS = 10000;
public static final int RANDOM_STRINGS = 5;
getRandomStringList returns a list with RANDOM_STRINGS elements of type String.
I tried both methods and the time in milliseconds needed for running both methods on my machine were:
stringPlus:432
stringBuilder:343
You can see that the difference is not that much, but using StringBuilder is still faster than using “+” for adding Strings.
The StringBuilder code is a little longer and needs an extra assignment to another String variable.
I think it is always good to write short test methods before jumping to conclusions about performance.
Posted in Java
No Comments »