Monday Apr 15, 2013

A new article, up on otn/java, by yours truly, titled “The Advent of Kotlin: A Conversation with JetBrains' Andrey Breslav,” explores the new statically typed language, Kotlin, which was named Language of the Month in the January 2012 issue of Dr. Dobb's Journal. Kotlin is a product of the highly lauded Czech software development company, JetBrains, maker of the Java IDE IntelliJ IDEA. Project Kotlin aspires to create for developers a general-purpose language that can serve as a useful tool that is safe, concise, flexible, and 100 percent Java-compatible. Both the compiler and the IntelliJ IDEA plug-in are open source under the Apache 2 license, with source code available through GitHub.

Breslav, the lead language designer for Kotlin, discusses Kotlin's features in the interview. Here are some things he points out:

* “Extension functions and properties in Kotlin can be added to any class/type without altering the definition of the class. This enables us to beautify even existing Java libraries so that the good old JDK looks nice and shiny.* Higher-order functions (passing code around as values) are a lot more convenient, because Kotlin supports proper function types (as opposed to Java 8's SAM conversions that make you create a new interface every time you need a new function signature to be passed around).* Declaration-site variance, and variant collections in particular, make common data processing much more natural by eliminating the need for ubiquitous wildcards in generic types.”

Breslav says that Kotlin promotes null safety, through nullable types and “offers control over data modification through read-only collections and data classes and enables safer runtime checks through smart casts.”

He states that Java developers who are in search of a new language will enjoy Kotlin’s clean abstractions, concise syntax, and type safety. Breslav encourages developers to download the compiler and/or a plug-in for IntelliJ IDEA, and start writing their own applications. Any feedback about what developers like and dislike, what they find difficult to understand, and how they are making use of Kotlin will be much appreciated.

Thursday May 31, 2012

In a new interview up on otn/java, titled “Java Champion Dick Wall on the Virtues of Scala (Part 2),” Dick Wall explains why, after a long career in programming exploring Lisp, C, C++, Python, and Java, he has finally settled on Scala as his language of choice.

From the interview:

“I was always on the lookout for a language that would give me both Python-like productivity and simplicity for just writing something and quickly having it work and that also offers strong performance, toolability, and type safety (all of which I like in Java). Scala is simply the first language that offers all those features in a package that suits me. Programming in Scala feels like programming in Python (if you can think it, you can do it), but with the benefit of having a compiler looking over your shoulder and telling you that you have the wrong type here or the wrong method name there.

The final ‘aha!’ moment came about a year and a half ago. I had a quick task to complete, and I started writing it in Python (as I have for many years) but then realized that I could probably write it just as fast in Scala. I tried, and indeed I managed to write it just about as fast.”

Wall makes the remarkable claim that once Java developers have learned to work in Scala, when they work on large projects, they typically find themselves more productive than they are in Java. “Of course,” he points out, “people are always going to argue about these claims, but I can put my hand over my heart and say that I am much more productive in Scala than I was in Java, and I see no reason why the many people I know using Scala wouldn’t say the same without some reason.”

“The exception handling changes in Java SE 7 allow you not only to program more concisely, as demonstrated in the multi-catch examples, but they also allow you to partially handle an exception and then let it bubble up, as covered in the re-throw examples. Java SE 7 also facilitates less error-prone exception cleanup…”