Kotlin: It’s the little things
Dan Kim
54721

I kind of like seeing the type on the left side, it acts as a comment. However, there were comparisons made to C#, and some have even said it is not strongly typed. Let me clear this up.

C# allows you to:

  • declare just like Java (a.k.a. explicitly typed)
  • use the var keyword (like Kotlin, a.k.a. implicitly typed)
  • use the dynamic keyword.

In C# and Kotlin the var keyword is simply syntactic sugar to infer the type from the right side, which is done anyway by the compiler to verify correct type. This has NOTHING to do with type declarations from scripting languages.

Now, C# goes a step further with the dynamic keyword. This works just like Javascript/php etc. The type is determined at RUN-TIME. It is extremely powerful but we all know what could happen there. Basically it says, hey Mr. Compiler, don’t check if that method exists in the class. I’m responsible about it and may be returning something by reflection or whatever. I don’t believe Kotlin can do that. Remember that the .net framework has languages such as IronPython, so that functionality is needed.

Interested in more about dynamic? Check here: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/using-type-dynamic

C# is an excellent language. LINQ is great too. Also, in the .net world you can write in Python or Ruby or whatever, as long as it runs on the .net framework.

Events are added using a += syntax to a delegate (C# function pointer). You could even write raw C code with pointers using an unsafe{} block, and have easy C# access to all your C code as well, and even some asm if you dare. For some real time data intensive apps I wrote I could use the latest processor instructions and get scary performance. For most Android apps, that would be totally unnecessary.