Hacker News new | past | comments | ask | show | jobs | submit login

That Scala is a beast of a language with a huge surface syntax?



It is not. Its syntax is simpler and more regular than Java or C#, and on par with Kotlin. I haven't heard many complaints on them having complex syntax. Ironically Kotlin is promoted as simple, when its syntax is almost the same as Scala.


What are you talking about? Scala doesn’t even have a consistent syntax, on purpose. By design there are multiple ways to write many things in the language, often with unpredictable and inconsistent results, method syntax being the most obvious example.

I think you have confused Scala for something else. “Regular” it is most assuredly and deliberately not.


> By design there are multiple ways to write many things in the language

This can be said about any language. True for Java, true for Python, true for Kotlin.


Surely, you must be joking? Scala is much closer to C++ than Java, forget Kotlin. It is a kitchen sink with every feature under the sun.


Then how come most Scala code can be translated to/from Kotlin or Swift with just find-and-replace?

https://hackernoon.com/how-i-ported-10k-lines-of-scala-to-ko...

The syntax of both is extremely similar.

https://leverich.github.io/swiftislikescala/

Basically Swift and Kotlin based their syntax exactly on Scala.

> It is a kitchen sink with every feature under the sun.

You obviously don't know Scala and you're just repeating BS found on the Internet.

Scala is a much more powerful and much more abstract language than Kotlin, so comparing their syntax complexity is unfair from the start.

But if you restrict the problem space to what can be covered by both Scala and Kotlin, then Scala has in fact fewer features than Kotlin. It just happens to have a few more generic, and very powerful unique features, which might look unfamiliar to Java programmers.

Examples:

* Kotlin has special syntax for null-checking. Scala has no special syntax and implements the same feature in the standard library.

* Kotlin has special syntax for coroutines. Scala achieves the same with a library.

* Kotlin has special syntax for extension methods. Scala doesn't provide special syntax for extension methods - they can be created with implicit objects which are a much more generic feature and have other important use cases not possible in Kotlin nor Java.

* Java has special syntax for array access. Scala does not.

* Java has special syntax for interfaces with method implementations. Scala does not.

* Java has static members which are completely alien to OOP. Scala does not.

* Kotlin and Java have operators, and Kotlin has operator overloading (just like C++!), making operators second class citizen. Scala has just method names, so "operators" and regular methods are the same.

> Scala is much closer to C++ than Java

Only in terms of abstraction power (IMHO it is much above C++ in abstraction power; actually much closer to OCaml than C++), but not in terms of complexity. Scala language specification is ~200 pages long. Java is ~750 pages, C++ is ~1300 pages.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: