Live data from Hacker News

Swift is like Kotlin

nilhcem.com

241–250 of 364 posts

Re: Swift is like Kotlin

#242

Earlier quoted context omitted.

> # using \ is looking for troubles Are you referring to escaping and other special sequences (e.g. unicode codes)? Though it is odd-looking I actually find it rather smart that they decided to reuse an existing mechanism for that: aside from delimiters the only magical character in a string is \ rather than have e.g. both \ and $. > # the useless () My beef is more with 1..5 being inclusive and there apparently bein…

About \, yes it's the possible clash with a real quote. More an inconvenience to the reader that a source of bugs, but also that. About ranges, Ruby has both .. and ... and after 12 years I don't remember which is what. Maybe an inclusive one is enough and 1..(n-1) About syntax in general, it should be easy for developers no matter how hard it is for the compiler/interpreter to parse it. I don't like to have to type…

"When you see that third dot, imagine opening the accordion slightly. Just enough to let one note from its chamber. The note is that end value. We’ll let the sky eat it." - http://poignant.guide/book/chapter-3.html#section2

Re: Swift is like Kotlin

#243
post #225

Earlier quoted context omitted.

I assume Google will try to replace Java with Dart, because they have recently been focused on Flutter [1] [2] and Fuschia [2] development which are (mostly) C++ and DartLang stack. [1]: https://flutter.io/ [2]: https://github.com/flutter/ [3]: https://github.com/fuchsia-mirror

> I assume Google will try to replace Java with Dart I would have expected this, but not after pushing Kotlin. Kotlin is shiny enough to temporarily distract the typical developer from the daily struggles with the abysmal Android API. Kotlin and Java it will be for the next 10 years, for better or worse. Dart is not very popular within Google itself, and Fuchsia is nothing more than a paid hobby project[0]. [0] See h…

According to what Fuchsia developer Travis Geiselbrecht said in the public Fuchsia IRC channel,the OS “isn’t a toy thing, it’s not a 20% project, it’s not a dumping ground of a dead thing that we don’t care about anymore.”[0]

[0]https://arstechnica.com/gadgets/2017/05/googles-fuchsia-smar...

Re: Swift is like Kotlin

#245

There does seem to be broad agreement across a range of typed languages -- TypeScript, Swift, Kotlin, ES6 + Flow -- about notations for classes, control flow and data structure declaration. But true convergence remains far away...

Is this broad agreement due to theoretical alignment, or a deliberate attempt to increase programmer adoption? If true convergence happened, there wouldn't be a need for different languages. :-)

I think there is real convergence. All serious new languages have some form of static typing augmented with some form of type inference. All are lexically scoped. All have first-class functions and map/reduce/filter. None have unchecked manual memory management. None have checked exceptions.

There are still areas of debate, but at the same time I think there is real progress; we have learnt from past mistakes and they won't be repeated.

Re: Swift is like Kotlin

#246
post #225

Earlier quoted context omitted.

I assume Google will try to replace Java with Dart, because they have recently been focused on Flutter [1] [2] and Fuschia [2] development which are (mostly) C++ and DartLang stack. [1]: https://flutter.io/ [2]: https://github.com/flutter/ [3]: https://github.com/fuchsia-mirror

> I assume Google will try to replace Java with Dart I would have expected this, but not after pushing Kotlin. Kotlin is shiny enough to temporarily distract the typical developer from the daily struggles with the abysmal Android API. Kotlin and Java it will be for the next 10 years, for better or worse. Dart is not very popular within Google itself, and Fuchsia is nothing more than a paid hobby project[0]. [0] See h…

Given the level of activity on [Fuchsia's project repos][0], I find it very unlikely that it's just a hobby project. That amount of activity is on-par with Android itself. If it is just a hobby, it's an extremely expensive one.

[0]: https://github.com/fuchsia-mirror

Re: Swift is like Kotlin

#247
post #35

Earlier quoted context omitted.

Yes, but the corresponding design decision would be "0..=n". Swift's "0...n" is a bit less obvious. Also, exclusivity is almost always what you want, so "0..n" should just default to exclusivity and "0...n" could be inclusive.

As an alternative opinion, I personally hate when ranges are exclusive by default. In addition to it feeling somewhat unintuitive to me that I need to use range(0, 6) to include 5, it also makes downward ranges quite awkward, e.g. needing range(5, -1) to count from 5 to 0.

Right-Exclusive ranges are superior to inclusive ranges because they can represent empty ranges, which removes one rare degenerate case and not overemphasizing it.

Another benefit: creating a series of right-exclusive ranges from a sequence [a, b, c, f] is easy: [a, b) [b, c) [c, f)

Re: Swift is like Kotlin

#249
Is there any tool that converts one to the other?

I think it is worst to have such similarities with very small different details than having completely different languages. For a developer working on both ecosystems it feels like hell to remember the tiny details.

Re: Swift is like Kotlin

#250
The article is missing the similarities between Swift Optionals and Kotlin Nullables.

Swift code:

  var name: String?

  name? ///returns a safe value
  name! ///returns an unsafe value and throws an exception in case of a nil value

  if name != nil {
   ///Now we can use name! forcing unwrap because we know it's not nil
  }

  if let unwrapedName = name {
   /// Here we can use unwrapedName without forcing the unwrap
  }
The null checks are almost the same in Kotlin: https://kotlinlang.org/docs/reference/null-safety.html
Post reply on HN