Over a million developers have joined DZone.

Kotlin: Hackery Made Elegant

DZone's Guide to

Kotlin: Hackery Made Elegant

· Java Zone ·
Free Resource

Java-based (JDBC) data connectivity to SaaS, NoSQL, and Big Data. Download Now.

I have an open mind about languages. I love the new features in O-C and like a lot of stuff in C++ 11.

Recently, on StackOverflow, I weighed in on a question tagged Design Patterns and said instance of was considered a sign of bad design. Almost everyone on the thread was like ‘says who?‘ Really? So I went and got a link that mentioned it as the first language anti pattern to avoid, and the main guy was still like ‘that doesn‘t prove a thing.‘

Just saw an article mentioned on Twitter looking at VM languages, clicked on it, and it‘s about Kotlin this time, the JetBrains language. The author starts by saying ‘it sure does deliver on the elegant code promise,‘ and shows this abomination:

when (stream) {
is Reader -> stream.close()
is Writer -> stream.close()
is InputStream -> stream.close()
is OutputStream -> stream.close()
is Socket -> stream.close()
else -> System.err.println("Unable to close object: " + stream)

How does this code make any sense? If it‘s anything close, otherwise, throw an error?

File under:

  1. Fitness function in languages today is did the ADHD coder have to type fewer symbols? yes? good, no? bad.
  2. ‘Design‘s a drag, who said goto was bad? You know, the good thing about goto is, you tell the computer to do something and it just does it.‘

Who‘s working on languages that are going to solve problems that have been around forever?? Like nulls? or having to reconstruct graphs at child nodes? I like Categories in O-C, but I would like to see them made into Traits that are a little less universally-glommed functions.

If you like these types of language innovations, my recommendations are learn how to type faster and use IDE shortcuts more.


Connect any Java based application to your SaaS data.  Over 100+ Java-based data source connectors.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}