Over a million developers have joined DZone.

Kotlin: Hackery Made Elegant

· Java Zone

Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience, brought to you in partnership with JetBrains

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.

 

Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.

Topics:

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

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

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

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

{{ parent.tldr }}

{{ parent.urlSource.name }}