Live data from Hacker News

Swift is like Kotlin

nilhcem.com

321–330 of 364 posts

Re: Swift is like Kotlin

#321

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.

Unfortunately, you don't really get to make the decision by itself. You kinda have to go with which platform am I building on first.

Re: Swift is like Kotlin

#322

Earlier quoted context omitted.

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.

Nobody should be using IB at all for iOS development. Ever.

Except for people laying out the views. Visual things deserve a visual editor. Writing code to lay out views is the absolute worst.

Re: Swift is like Kotlin

#323
post #41
post #23

Earlier quoted context omitted.

Swift has both external and internal parameter names for functions. This is to make API design more readable, easier to parse through. For example, you can have a function like so: func greet(with greeting: String, to personName: String) { print("\(greeting), \(personName)!") } In the above code, "with" and "to" are external names, and are only available when calling the function but are not available inside the func…

Is there a parse-time reason that they required the "_" syntax, rather than simply: func greet(greeting: String, personName: String) { print("\(greeting), \(personName)!") }

The reason is that named parameters is the default, so in your case greeting and personName are both "internal" and "external" names. "_ greeting" sets the external name to _ (aka positional) and the internal name to "greeting" instead.

Re: Swift is like Kotlin

#324

Earlier quoted context omitted.

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.

> Xcode isn't perfect, but it's way better than JetBrains. O_o Are you kidding me? People whinge all the time about jetbrains subscriptions, but I've literally never spoken to someone who's actually used their products and think that the alternative editors available (visual studio, xcode, etc) are actually better. There are some features like UI designers that you can't do without, but it's been a long time since I…

I've attempted to use IntelliJ for javascript/typescript (React, Node.js) and Elixir. I've found myself continually going back to VSCode or other editors. Especially for the front-end ecosystem, VSCode's intellisense, syntax highlighting and plugin support blows everyone else out of water IMO.

I use IntelliJ/Android Studio for Java, and that's about it.

Re: Swift is like Kotlin

#325

Kotlin lacks the ability to do true functional programming that Swift has. Swift has pattern matching, recursive data structures (edit: specifically ADTs with enums or case classes is what I was thinking of here, should have written algebraic data types), tail call optimization, even some form of type classes, immutability (thanks @tmail21), and so on. Kotlin does not have any of these (edit: this is now partly false…

> Kotlin lacks the ability to do true functional programming...

Same goes for Swift.

Any "hybrid oo functional" language will not do the functional thing as well as a dedicated functional language. If you're still gluing things together with types, functions will never be quite as first-class as they should be.

Re: Swift is like Kotlin

#326

Kotlin lacks the ability to do true functional programming that Swift has. Swift has pattern matching, recursive data structures (edit: specifically ADTs with enums or case classes is what I was thinking of here, should have written algebraic data types), tail call optimization, even some form of type classes, immutability (thanks @tmail21), and so on. Kotlin does not have any of these (edit: this is now partly false…

What about immutability? A key part of functional programming is using immutable structures to avoid side effects. My understanding is that Swift has these to some extent ("let" vs "var", structs being immutable etc). And since Kotlin is built on JVM compatibility I _assume_ that Kotlin does not support an immutable style of programming. Maybe someone here has more clarity on this.

> And since Kotlin is built on JVM compatibility I _assume_ that Kotlin does not support an immutable style of programming.

The underlying host doesn't imply anything about language support as that's handled at the compiler level, not at the machine or VM level.

Even in Haskell data isn't immutable if you have a debugger or modify the machine code. It's simply a tool provided and enforced solely by the compiler - other JVM languages do support it like Clojure or Scala.

Re: Swift is like Kotlin

#327
post #153
post #14

Earlier quoted context omitted.

it's always confusing, in languages with ranges, whether the range includes the second boundary element or not. it's purely a matter of convention, after all. ruby has a..b and a...b, but even after years of using the language i have to look up which is which. a.. perfect notation - once you know the language handles both cases, a.. as for the "count - 1", it's not too bad because i find "inclusive" more intuitive th…

"a..b - 1" can also be written as "a until b" in Kotlin.

Which is not as obvious. I much prefer a..<b.

Re: Swift is like Kotlin

#328

Earlier quoted context omitted.

You now have https://github.com/Kotlin/kotlinx.collections.immutable

Cool. This needs to be built into the language or somehow standardized by the community. With lack of standardization of immutable collections, there would be lots of different ways that libraries would implement immutability. This would result in losing one of the main benefits of functional programming (i.e. awesome composability).

Well, that is part of the Kotlin project itself, so I assume it is or will be built in, should the proposal succeed.

Re: Swift is like Kotlin

#329
post #270

I find it very annoying that Google and Apple are creating new languages to solve similar problems and not worrying about cross platform. If you write for Apple you've been told to use Objective-C and Swift. If you're on Android it's Dart and now Kotlin. None of that stuff is used for Windows or Linux development or even mobile on the other OS. I'm not a fan of proliferation of "platforms" but when it goes beyond lib…

Imagine having just one programming language where there is likely one gatekeeper. I doubt language innovation would happen with that setup.

JS? Cordova supports Windows, Linux, OSX, Android, and iOS, for example.

:D

Re: Swift is like Kotlin

#330

Earlier quoted context omitted.

Ah, but is there a line? Where does it get drawn? Without explicitly naming them, once you get into the realm of Stalinism or the holocaust, surely it wouldn't take too much imagination to come up with a few names too unsavoury even for you?

There is no line. Expression is turing complete. That you might not like something I say does not have any effect on my right to say it as a human being. Obviously the names are tongue in cheek jabs. There's no language called Auschwitz, afaik, and even if there was, it would have as much right to exist as Java or Python or whatever. You don't get to tell people what to name things just because you're offended. You g…

At the same time, while you have the right to name something whatever you want, others do also have the right to tell you it's a terrible idea.

Your freedom to say what you want doesn't come with freedom from the consequences of saying it.

Post reply on HN