Kotlin — IDE-Oriented Programming

  • hype-driven development (using hyped tech for no reason, for example blockchain, NoSQL, or microservices; see also cargo cult programming)
  • voodoo programming (poking randomly at source code until the thing works; this is the main paradigm PHP programmers use)
  • Excel-based programming, where crucial business logic is kept inside of Excel sheets that have no version control and can easily be tampered with

IDE-Driven Development

I have already extolled the virtues of IDEs in “What I Wish My Computer Science Degree Taught Me About Programming”. Early on, “a developer wrote an application in a text editor, saved it, exited the editor, ran the compiler, wrote down the error messages on a pad of paper, and then traced back through the code again”. We have come a long way since then, with 1991’s Microsoft Visual Basic being considered the first real IDE, but I would argue that early Java IDEs (Eclipse 2001, IntelliJ 2001, NetBeans 1997) had the most profound impact on how we do development today.

There’s an old joke: If you build something even an idiot can use, only an idiot will use it. IDEs took programming out of the realm of arcane coding books as thick as a phone book and reduced many hours of work to just a few clicks.

Did it democratize programming, or enable bad programming? A little of both, say the veterans.

Java took the world by storm in the late 90s. Java proposed object-oriented programming, which envisioned a complex program broken down into modular encapsulated classes that could easily be swapped out. Managers started viewing developers the same way, as interchangeable with anyone from the large Java developer pool.

From Russia With Love

Enter Kotlin. It was April 2020 and I was out of a job when I first heard of Kotlin. It kept popping up in StackOverflow job ads, especially at companies I really wanted to work for. So I made a small demo app with Kotlin in Android Studio (which has since turned into Mundraub Navigator, a real app with 50K downloads). It fixes many of Java’s problems, like its verbosity, its lack of null-awareness, primitive types, and checked exceptions. It also adds string templates, operator overloading, and range expressions.

Dot-Based Programming

Compare the following Kotlin snippet to the equivalent Python:

solution.sortedBy { it.second }.map { it.first }.toString()

str([x[0] for x in sorted(solution, key=lambda x: x[1])])

Extension functions

Kotlin also allows you to define extension functions (which don’t get permanently attached to the object, only your code can use them essentially), so now even your helper functions can be used in dot-based style:

fun <T> List<T>.toPair(): Pair<T, T> {
if (this.size != 2)
throw IllegalArgumentException(“List is not of length 2!”)
return Pair(this[0], this[1])
}
val myList = listOf(7, 9)
val myPair = myList.toPair()
"http://whatthecommit.com/index.txt".httpGet()

More dots

You can even write infix operators like this. The following is legal Kotlin, calculating (3–5) * 2 = -4 (don’t do this):

3.minus(5).times(2)
cardInfos.forEach { it.submitted = true }for (cardInfo in cardInfos) 
cardInfo.submitted = true

Type and name hinting

The IDE adds additional information about variable/argument names and types (in grey), making Kotlin code much more readable in your editor than for example on GitHub or the Kotlin Playground:

A (maybe not great) code snippet from my Android app, Mundraub Navigator
def concat_lists(a):
return sum(a, [])


def concat_lists(a: list[list]):
return sum(a, start=[])

Conclusion

Java ushered in the age of cookie-cutter business app programming, and (with its simpler set of features compared to C++) was ideal for static analysis, moving the industry from obscure terminal-based text editors towards (too) easy to use graphical IDEs.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Konopka Kodes Blog

Konopka Kodes Blog

62 Followers

25/M software engineer from Düsseldorf, Germany. Developer of Mundraub Navigator (Android app) and Jangine (chess engine).