Live data from Hacker News

Swift is like Kotlin

nilhcem.com

171–180 of 364 posts

Re: Swift is like Kotlin

#171
post #129

One has structures, ARC, proper extensions, good protocols/interfaces, flexible enums, and runs natively. The other one doesn't. I think I'll choose the former.

They're not really in direct competition. Try writing an Android app in Swift, or an iOS app in Kotlin. Technically possibly either way, but one's definitely more suited than the other for each purpose.

Which one is easier? I need to write some cross-platform native code for my React Native app, and I'm having a really hard time deciding on the language.

I honestly didn't know that I could use either Kotlin OR Swift for both platforms. But which would be easier to get running on Windows? I also need to write a version that works on the web, and I've heard that Kotlin can transpile to JS. So that's pretty amazing if that works.

Otherwise I was considering C, C++, or Rust.

Re: Swift is like Kotlin

#172

Earlier quoted context omitted.

> Here in Ukraine it would be very hard to get adoption of a programming language that is named after a Russian military base. This sounds really stupid, considering that many Ukrainian programmers are already using JetBrains products and that punishing a great company for the actions of politicians is kind of sad.

Would you work in a programming language called Hitler? Any multinational company needs to do their research before deciding on a name.

Equating a programming language named after a Russian island to Hitler is a real stretch, unless you think that everything Russian is like Hitler. It's just an island and a language named after it.

Re: Swift is like Kotlin

#173
post #40
post #6

I like swift's conditionals without brackets, OTOH the syntax for string interpolation is ugly

Ugh, I know it's something that literally every programmer on earth can and often does bikeshed, but Swift just got string interpolation syntax wrong . Parentheses are something that are often part of the interpolated expression... they shouldn't be part of the interpolation syntax itself.

I agree. I prefer ES6 and Kotlin's interpolation syntax. Ruby is ok too.

Re: Swift is like Kotlin

#174
post #28
post #2

0..<count is a lovely little piece of language design

An alternative approach is Guava's Range class: Range.closed(1,5) == [1,5] Range.open(1,5) == (1,5) Range.openClosed(1,5) == (1,5] Range.closedOpen(1,5) == [1,5) Range.greaterThan(1) == (1,infinity) Range.atLeast(1) == [1,infinity) That class always strikes me as having high power-to-weight. It has methods like encloses(anotherRange), contains(aValue), and others. https://google.github.io/guava/releases/19.0/api/docs…

Too verbose for me. I always prefer short syntactic sugar.

Re: Swift is like Kotlin

#175
Neither of them do what I want which is to write some logic code once (logic / network / persistence) and run it both on Android and on iOS.

What I do now is use j2objc, but here I am stuck in Java land.

Re: Swift is like Kotlin

#176

It's strange that on the Kotlin side the author goes out of their way to show 'shorter' ways to do things that are also available in Swift but not illustrated. let sorted = [1, 3, 6].sorted() let sum = [1, 3. 6].reduce(0, +) as examples

while we're at it http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.16...

Why are you citing an FP comp Sci professor? I must've missed something

Re: Swift is like Kotlin

#177

Earlier quoted context omitted.

> Here in Ukraine it would be very hard to get adoption of a programming language that is named after a Russian military base. Well, except if you are an Ukrainian of Russian descent and root for the (ex)home team...

Which is actually not the case for most Ukrainians of Russian descent: Most of ethnic Russians in Ukraine signed for the Ukrainian army, fighting against Putin’s invasion, against the same Russians that came from the other side. (from http://marginalrevolution.com/marginalrevolution/2017/05/con... . Note the source is Kasparov, who is not an entirely unbiased source where Russia is concerned ;))

>Note the source is Kasparov, who is not an entirely unbiased source where Russia is concerned

To say the least...

Re: Swift is like Kotlin

#178

Earlier quoted context omitted.

One has a top-notch IDE from a top-notch IDE vendor. The other has XCode. Also, ARC aside, for the 3-4 items you mentioned, either Kotlin also also has them, or has just as good alternatives. And none of those are life-changing. ARC vs a good GC is just a different tradeoff (no cycle detection vs pauses, etc). I'm sure you can find some things where Swift is better at, and others where Kotlin is. But not that many to…

Sure thing... When will Jetbrain have a decent interface builder? Decent instrumentation? Decent documentation viewer? Can you get an object graph with JetBrains? Xcode isn't perfect, but it's way better than JetBrains. Just because one has one feature that one doesn't have, doesn't mean that Xcode beats JetBrain's IDE all day.

Refactoring is a dream with JetBrains. But it is very language dependent, with Java having most support. Haven't used Kotlin in Intellij so I don't know how well Kotlin is supported, though I imagine rather well given that it their own language.

Re: Swift is like Kotlin

#180
post #79

One has structures, ARC, proper extensions, good protocols/interfaces, flexible enums, and runs natively. The other one doesn't. I think I'll choose the former.

Kotlin Native ships with an ARC. But depending on the application ARC can be a disadvantage since it can't automatically handle reference cycles like Kotlin on the JVM can.

Is the Native AOT compiled, or just a different byte code VM? I assume the latter?
Post reply on HN