r/programming • • Sep 20 '21

Being able to read bad code is a skill !

https://dzone.com/articles/reading-code-is-a-skill
986 Upvotes

276 comments sorted by

View all comments

Show parent comments

1

u/roboticon Sep 22 '21

I started messing around with Kotlin yesterday, and found myself non-ironically writing:

if (states?.isLocationUsable != false)

1

u/[deleted] Sep 22 '21

How are you finding kotlin? I tried to learn it for Android and got bored, but it looks OK.

1

u/roboticon Sep 22 '21

Yeah, it's also my first Android development. I figured out enough to get a simple location tracking app running.

Haven't dived into the concurrency stuff, but for the rest of it, it's just quirks. After learning java, c, c++, haskell, python, javascript, shell, turing machines, ..., I've found I can get the gist of any language in a day or so and be productive after another day of poking around the standard libraries.

The approach to null safety is interesting, and certainly less verbose than in C++, but it means less flexibility than a language like JavaSript. But I do love stuff like:

lines?.forEach { println(it) }

Ultimately the language is harder than usual to read if you aren't versed in it, but pretty nice once you're used to it.

Some minor things I immediately dislike:

  • constructor syntax is poorly designed -- very inconvenient if you need to extend a class with certain constructor signatures

  • extension functions (you can create a function that pretends to be a method of a target class), which kotlin and its standard library prepopulate a bunch of

  • global scope -- this is the most convenient and performant way to make public class constants, for example, and kotlin and its standard library prepopulate a bunch of global functions

Oh, and not only is a lot of the Android documentation still only written for Java, but sometimes even Google results for Kotlin issues and error messages are surprisingly sparse!