4 ms·
Give Kotlin a try. It's a JVM-language and 100% java-compatible, but it can also compile to Javascript (not sure if that backend is production-ready yet though)
by cel1ne 10y ago
Give Kotlin a try. It's a JVM-language and 100% java-compatible, but it can also compile to Javascript (not sure if that backend is production-ready yet though)
https://kotlinlang.org/ https://kotlinlang.org/
It's also backed by JetBrains the IDE-maker.
- jbverschoor 10y agoKotlin is a JVM clone of swift.
- realharo 10y agoA clone of something that appeared 3 years later? (2011 vs 2014 according to wikipedia)
- Nullabillity 10y agoAFAIK the official line has always been that it's a "simpler Scala". Not to mention that it's several years older...
- nostrademons 10y agoThey're actually quite different - a good chunk of my current project is in Kotlin, and all of my last project was in Swift. Things Swift has that Kotlin doesn't: associated types, file-based access control (changing in Swift 3.0), pervasive use of keyword arguments, trailing closures, full pattern matching (Kotlin can only destructure component1...N sequences), reference counting. Things Kotlin has that Swift doesn't: smart casts, declaring properties directly in the constructor, declaring constructors directly in the class statement, auto-delegation, data classes, singleton objects, implicit parameterizable 'this' (handy for builders & DSLs), garbage collection. Things they both have: null chaining & defaulting, class extensions, somewhat clumsy first-class method syntax, concise lambda syntax, lambda anaphora ('it' in Kotlin, $0 and $1 in Swift), concise range operators, property descriptors, operator overloading. Kotlin generally has the feel of a much more pragmatic, industrial language. It's Java without the warts, where the designers took note of the common Java patterns they wrote and provided a lot of syntactic sugar to dramatically improve brevity. Swift feels more academic; its type system is more modern and less ad-hoc, it has polished implementations of many features that academic languages have been trying to get right for years. Both are heavily influenced by their ecosystems; Swift feels like a better Objective-C, and Kotlin feels like a better Java.
- cel1ne 10y agoKotlin does have trailing closures: https://kotlinlang.org/docs/reference/lambdas.html#higher-order-functions https://kotlinlang.org/docs/reference/lambdas.html#higher-or... And some form of pattern matching via the "when" keyword: https://kotlinlang.org/docs/reference/control-flow.html#when-expression https://kotlinlang.org/docs/reference/control-flow.html#when...
- nostrademons 10y agoIt's a bit different in Swift. Kotlin lets you omit the parentheses if the closure is the only argument to the function. Swift lefts you place the lambda outside of the parentheses if the closure is the last argument to the function. That lets you construct a much larger variety of control-structure-like HOFs. Event handlers, for example, often take a functional argument plus a bunch of other data.
- cel1ne 10y agoNo, it's the same in Kotlin, from the docs: "There is a convention that if the last parameter to a function is a function, that parameter can be specified outside of the parentheses." So you can have normal arguments and specify the last parameter outside like. val col = "A" val row = 3 table.update(col, row) { it * 5 } You may have confused that with SAM-conversions (?), which are for java-interop: https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions https://kotlinlang.org/docs/reference/java-interop.html#sam-...
- nostrademons 10y agoCool. Learn something new every day. (I was confused because all the examples except for lock() are single-arg, and IntelliJ usually autocompletes with parentheses because there's often a non-functional overload.)
- premium-concern 10y agoI recommend you try the JavaScript backend. I'm so sick of people spewing JetBrains' marketing points without checking the substance of it.
- cel1ne 10y ago> I'm so sick of people spewing JetBrains' marketing points without checking the substance of it. I tried the backend already, last time I checked it wasn't production ready, like I pointed out in my post. Maybe it is now? OP mentioned he wanted to "foray into a new language will be something properly compiled like Rust or Swift, not a transpiled language." Where exactly did my suggestion to try Kotlin go awry?