News for hackers. Stuff that matters.
Re:Swift: Challenges and Opportunity for Language and Compil... by sssilver on Sunday December 18, 2016 @06:03AM (#13205328)
I actually love the source breaking changes. The alternative is easier and much worse, and it takes boldness to not roll with the alternative, e.g. add language bloat and keep suboptimal decisions as part of the language just to support code that's already shipped.

C++ is the prime example of what the alternative looks like.

Re:Swift: Challenges and Opportunity for Language and Compil... by mike_hearn on Sunday December 18, 2016 @07:35AM (#13205583)
I'm not sure I agree.

My girlfriend has decided to learn programming. She started with Swift because she wanted to write iOS apps. The course she's using targets Swift 2 but her install is Swift 3, or something like that (I haven't looked into it much).

XCode constantly flags stuff like x++ being replaced with x += 1. Really? Surely that's the kind of decision you make before version one of a language, not years after release. Why this pointless churn?

If these sorts of totally-indecisive deprecations were rare then you could overlook them, as otherwise Swift is a rather nice language. But they're everywhere. Even in trivial examples intended for beginners line after line of code gets the yellow deprecation warnings. "What does deprecated mean" was literally one of the first questions my girl asked me as she started out learning programming, which is ludicrous. You shouldn't be encountering deprecation warnings over and over when targeting a brand new platform using a teaching course barely a year old.

Re:Swift: Challenges and Opportunity for Language and Compil... by pivo on Sunday December 18, 2016 @09:16AM (#13205856)
If your girlfriend wants a stable language for iOS development she should use Objective-C. Apple have been very clear about the fact that Swift is evolving and that there will be breaking changes.

Changes to Swift are hardly indecisive or pointless. A very clear rationale for removing the ++ operator was laid out here: https://github.com/apple/swift-evolution/blob/master/proposa....

While these changes may be painful now (though the removal of the ++ operator seems minor to me), they should result in a stronger and simpler language in the long run.

Re:Swift: Challenges and Opportunity for Language and Compil... by mike_hearn on Sunday December 18, 2016 @09:25AM (#13205880)
The course she bought (without my input btw, she's pretty independent!) uses Swift. And that's probably right. Swift is a much nicer language than Objective-C, much closer to modern languages and has far less of the C heritage poking through. Even with the deprecation warnings, it's probably easier to deal with.

Removing x++ is indeed minor, which is why it's so curious. Sure, there are arguments for removing it. But there are also arguments for minimising language churn and just living with these things.

Re:Swift: Challenges and Opportunity for Language and Compil... by mmariani on Monday December 19, 2016 @05:19AM (#13210558)
You could give a little help to your girlfriend. How about installing for her the required swift version by her course with swiftenv? This way she could learn the basics without getting nagged by Xcode. Later she could read up the differences and port her code to practice.
Re:Swift: Challenges and Opportunity for Language and Compil... by timjver on Sunday December 18, 2016 @12:52PM (#13206727)
Living with x++ wouldn't be terrible, but I don't mind having to make changes to my code now that Swift is still very new if it ends up becoming a better language. Teaching x++ and ++x to beginners can be quite a pain.
Re:Swift: Challenges and Opportunity for Language and Compil... by hota_mazi on Sunday December 18, 2016 @11:28AM (#13206332)
It feels backward to modify the language in a way that makes it less functional: replacing a construct that returns a value with one that returns Void.

Definitely going against the general language trend, there.

And the justifications to remove ++ are downright bizarre in my opinion.

Re:Swift: Challenges and Opportunity for Language and Compil... by boterock on Sunday December 18, 2016 @09:02AM (#13205830)
The c style for loops were also dropped. now you do `for idx in 0...5` or you can also do `for idx in 0..<5` I think this makes clearer if you want to include or exclude the last index in the loop.

I think that this kind of break is not that bad, swift is a young language, and there are some things that only after so much testing you realize it could be better.

Swift is 2.5y old, it has just one year being open source, so I don't think these breaking changes as a big deal. It is not in a situation like Python 3. Even the compiler helps you fix it and XCode is very helpful when translating Swift 2 to Swift 3, so it is not that bad.

Re:Swift: Challenges and Opportunity for Language and Compil... by mike_hearn on Sunday December 18, 2016 @09:22AM (#13205871)
Swift development started in 2010, so it's about 6.5 years old at this point.
Re:Swift: Challenges and Opportunity for Language and Compil... by hyperpape on Sunday December 18, 2016 @01:00PM (#13206769)
Which is still younger than Rust or Go, it's probably the youngest widely used language.
Re:Swift: Challenges and Opportunity for Language and Compil... by kibwen on Sunday December 18, 2016 @02:32PM (#13207157)
Rust didn't start real development until 2010, it was mostly notes and incomplete PoCs before then (which I'm sure Lattner was doing for Swift before 2010, and Pike for Go as well).
Re:Swift: Challenges and Opportunity for Language and Compil... by hyperpape on Sunday December 18, 2016 @04:46PM (#13207847)
As I understand it, July 2010 was literally the first commit for Swift in any form (https://techcrunch.com/2014/06/04/apples-new-programming-lan...), as a personal project for Chris Lattner. I think the complete history is on Github now.

Of course, age only tells you so much about the amount of work put into the project, and Rust in particular took a huge amount of conceptual work to get its current model of ownership.

Re:Swift: Challenges and Opportunity for Language and Compil... by danappelxx on Sunday December 18, 2016 @01:45PM (#13206975)
Source?
Re:Swift: Challenges and Opportunity for Language and Compil... by mike_hearn on Sunday December 18, 2016 @02:00PM (#13207034)
Wikipedia.
Re:Swift: Challenges and Opportunity for Language and Compil... by gaurav-gupta on Sunday December 18, 2016 @11:57AM (#13206460)
A month ago, I tried the getting started on Apple's website. Even that had deprecated syntax =:)

Btw, Xcode still doesn't support refactoring Swift code

Re:Swift: Challenges and Opportunity for Language and Compil... by bad_user on Sunday December 18, 2016 @10:17AM (#13206060)
No, it is Java that is the prime example of what the alternative looks like.

And in spite of all problems with Java and its standard library, there's something very liberating about having code written in 1997 that still compiles and works in 2017.

And the beauty of Java is that it became a platform, so if you hate the language, you can pick another that's closer to what you think programming should be, like Scala, Clojure, JRuby, Groovy, Kotlin, etc. and still benefit from that piece of code written in 1997, all made possible due to Sun's fanatical devotion to backwards compatibility.

Re:Swift: Challenges and Opportunity for Language and Compil... by Recurecur on Sunday December 18, 2016 @11:59AM (#13206467)
I've been a heavy Java platform user for years, mainly Java language but also with some Groovy and Scala. I agree with what you're saying to as far as it goes.

Where Swift excels is that it has the performance of C for the most part, and it will continue to improve. Another strength is ARC over Java style GC. As the slides point out, to get the same performance with GC, you need 4x the memory. With only 2x the memory, you get 70% lower performance with Java. Most important, though, is determinism. GC is simply not suitable for real time, hard or soft.

I'm very excited about Swift, and the current version of Xcode is working pretty well for me. I love the aggressive goal of replacing the C family of languages down the road...

Re:Swift: Challenges and Opportunity for Language and Compil... by yxhuvud on Sunday December 18, 2016 @12:52PM (#13206721)
> As the slides point out, to get the same performance with GC, you need 4x the memory.

I'd take that claim with a pretty big grain of salt. The paper they referenced used an experimental GC without use in production. Who knows how well or bad the default collector in the JVM would perform.

Also, it is not exactly recent. Hardware changes could have shifted the result in any direction.

Re:Swift: Challenges and Opportunity for Language and Compil... by Recurecur on Tuesday December 20, 2016 @11:05AM (#13221031)
The exact numbers are worth a grain of salt. The general point aligns well with my JVM experience. Requiring at least double the working set for decent performing GC doesn't seem congruent with running the leanest possible data centers.

Regardless, determinism is the really big win. :-)

Re:Swift: Challenges and Opportunity for Language and Compil... by vorg on Sunday December 18, 2016 @05:37PM (#13208143)
Scala and Apache Groovy benefit from the JVM's backwards compatibility, but programmers can't benefit from backwards compatibility in those languages. Groovy even broke compatibility between various 1.x releases.
Re:Swift: Challenges and Opportunity for Language and Compil... by bad_user on Monday December 19, 2016 @03:38AM (#13210260)
Which is a pity. We take backwards incompatible changes too lightly. I'm working with Scala for example and love the language, but it breaks binary compatibility between major versions because Scala's features don't map that well to the JVM's bytecode and the encoding of things like traits are fragile. Well, the community is kind of coping with it by having libraries support multiple major versions at the same time. Well, it's not much, but at least the tools have evolved to support this (e.g. SBT, IDEs, etc).

That said, if you're looking for a language that has kept backwards compatibility, that's Clojure. Rich Hickey has a recent keynote that I found very interesting: https://www.youtube.com/watch?v=oyLBGkS5ICk

I don't know how to feel about it. On one hand this means Clojure will probably never fix some obvious mistakes in its standard library, without changing its name (like what they did with ClojureScript). On the other hand, as I said, it is liberating to have code written in Clojure 1.0 still working in 1.8.

Re:Swift: Challenges and Opportunity for Language and Compil... by pjmlp on Sunday December 18, 2016 @08:38AM (#13205773)
Python is the prime example what breaking a language looks like.
Re:Swift: Challenges and Opportunity for Language and Compil... by dom0 on Sunday December 18, 2016 @10:21AM (#13206081)
If anything Python is a good example for breaking not enough in the main language.
Re:Swift: Challenges and Opportunity for Language and Compil... by madgar on Sunday December 18, 2016 @10:07AM (#13206028)
> it takes boldness to not roll with the alternative,

Yes, like the "courage" it takes to remove the 3.5mm headphone jack.