Over a million developers have joined DZone.

Kotlin: Hackery Made Elegant

DZone's Guide to

Kotlin: Hackery Made Elegant

· Java Zone
Free Resource

Learn how our document data model can map directly to how you program your app, and native database features like secondary indexes, geospatial and text search give you full access to your data. Brought to you in partnership with MongoDB.

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.


Discover when your data grows or your application performance demands increase, MongoDB Atlas allows you to scale out your deployment with an automated sharding process that ensures zero application downtime. Brought to you in partnership with MongoDB.


Published at DZone with permission of Rob Williams, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


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

{{ parent.tldr }}

{{ parent.urlSource.name }}