...

/

More Expressions, Fewer Statements

More Expressions, Fewer Statements

Languages like Java, C#, and JavaScript have more statements than expressions—if statement, for statement, try, and so on. On the other hand, languages like Ruby, F#, Groovy, Haskell, and many others have more expressions than statements. Let’s discuss which is better before we discuss Kotlin’s preference.

Drawbacks of statements

While statements are prevalent, they have a dark side—they don’t return anything and have side effects. A side effect is a change of state: mutating a variable, writing to a file, ...