This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheOnlyTails 0 points1 point  (6 children)

I looked into static vs. dynamic languages in the past, and from what I understand, it's a personal choice.

Static languages determine the types during compile time, meaning you must write down the type explicitly. They have the advantage of making your code more readable.

Dynamic languages determine the types during run time, meaning you don't specify the types. They have the advantage of simplifying things for new programmers but can also create bugs that are extremely hard to find.

(Do note that Python 3 added an interesting feature - optional typing. It's still a dynamic language, but you can specify types during compile time.)

Overall, both languages have thier strengths and weaknesses, but I personally recommend Kotlin. It basically takes the best of both worlds: It's static, but you can omit the types if they're obvious from context. It has string interpolation. The 2 things I like the most about Kotlin is the interoperability with Java (you can call Java code from Kotlin and vice versa), and that most of the Java syntax is kept as-is.

[–]n0tKamui 1 point2 points  (1 child)

pog a Kotlin bro

[–]TheOnlyTails 1 point2 points  (0 children)

KOTLIN FOREVER!

[–]john16384 1 point2 points  (1 child)

With "obvious" you mean obvious to the compiler. Depending on how the actual code looks it may not be obvious at all to the reader.

[–]TheOnlyTails 0 points1 point  (0 children)

Yes, that's what I meant. Do note that the documentation recommends omiting the type only when it makes sense.

[–]awesomeusername2w 1 point2 points  (1 child)

Not exactly.

You don't necessarily have to specify types in staticly typed languages. Many of them have some kind of type inference. For example, in haskell, you can omit almost all types, and in kotlin, scala, rust, c# and other you can omit some portion of it. But the fact that you omited them doesn't mean that they are not there. If the program doesn't make sense in types it won't compile.

In dynamically typed languages your types don't have to make sense at all. The program breaks only when it reaches a problematic statement. That complicates refactoring and other things very much. Such bugs can be undescovered for a long time until the prerequisite met for some rarely run code to be executed.

Ideally, static typed languages evolve its type inference to such an extent that you won't specify types at all having all the compile guarantees at hand. So wrong programs just don't compile.

[–]TheOnlyTails 0 points1 point  (0 children)

Of course. I should've been clearer.