News for hackers. Stuff that matters.
Re:Swift Changes Considered Harmful by drewcrawford on Saturday February 18, 2017 @03:40PM (#13676567)
This is already being done.

Swift 4 (unreleased) has source compatibility with Swift 3 [0], so all Swift code working today should work in the next version, no migrator necessary.

Additionally, the goal of Swift 4 is to finalize the ABI. Once that is done, you can mix and match different Swift versions in the same project.

The real "problem" here is that Swift wants to be a "big" language, in the vein of C++ or Rust, as opposed to a "small" language like C or JS where you can read one book. (Swift does have a book, it's 1200 pages.) There's a lot of "stuff": a complex typesystem, many basetypes, generics, extensions, both static and dynamic dispatch, programmer-assisted memory management, closures, visibility, ephemerals, optionals, a mutability-based memory model, etc. etc.

Inevitably some of that stuff won't be quite right and so you have churn. But ideally you only need 10% of those (it's just that everybody needs a different 10%) and so the amount of churn you personally have to deal with should be low, and can be lower with the appropriate tooling.

[0] https://swift.org/blog/swift-4-0-release-process/

[1] https://github.com/apple/swift-evolution

Re:Swift Changes Considered Harmful by 0x0 on Saturday February 18, 2017 @04:09PM (#13676694)
I thought they announced swift 4 would not finalize the ABI after all? http://mjtsai.com/blog/2017/02/16/deferring-abi-stability-fr...
Re:Swift Changes Considered Harmful by Someone on Saturday February 18, 2017 @04:01PM (#13676653)
"Swift does have a book, it's 1200 pages."

It is an ePub, so your mileage may vary. On my iPad, it is 1077 in landscape, 892 in portrait (edit: playing with the font size in iBooks, I got it down to 484 pages while still being eminently readable for my myopic eyes)

More importantly, that ePub on my iPad shows only 16-ish on a page in landscape mode, 22-ish on portrait. A printed book probably would be around 300-400 pages.

In comparison, the PDF I have for "small" language ISO C 2011 has 701 pages, a draft of ECMA-262 for JavaScript 252.

Re:Swift Changes Considered Harmful by edblarney on Saturday February 18, 2017 @04:15PM (#13676726)
"Swift wants to be a "big" language"

My guess is that it is not ideological. Swift feels like it wants to be 'everything'.

Because of this, it's almost too much.

I want to like Swift, but I run into a lot of trouble with it.

The decision to be compatible with ObjC was one of the big issues: obviously, pragmatically, they felt that they just had to do it. In hindsight, I wonder if it would have been better to just have a clean break.

Re:Swift Changes Considered Harmful by fiedzia on Saturday February 18, 2017 @04:49PM (#13676899)
> In hindsight, I wonder if it would have been better to just have a clean break.

Language-wise - sure, it adds a lot of complexity. Platform-wise, they would risk people staying on what they had and ignoring Swift entirely, and that would mean Apple would need to support objective-c a lot longer than they want to.

Re:Swift Changes Considered Harmful by edblarney on Saturday February 18, 2017 @05:16PM (#13677010)
Yes, that is the rationale.

But I wonder. They are a $700B company. What if they just 'did it right' - i.e. made sure all of the APIs and documentation were available in 'new Swift' which had no relation to ObjC.

Because the 'fallback on ObjC' has more problems than integration.

A lot of people want to make apps for iPhone and ObjC is not in their vocab. Me, for example.

Swift could have been an easy-to-approach language.

But because of 1) lack of docs and 2) dependency on a lot of ObjC residue ... guess what? To make app in 'Swift' - you still had better know a lot of ObjC!

So - to really make use of 'the new' - you still have to know 'the old' - which totally defeats the purpose!

I wish they had made a clean break - great docs, examples that are clear and well marked in terms of versions, all new APIs for Swift, left in beta for longer, and made mostly backwards compatible changes. And left a few things out.

Re:Swift Changes Considered Harmful by fiedzia on Saturday February 18, 2017 @05:41PM (#13677103)
> They are a $700B company.

But many of their customers aren't. Lot of them have no budget (or will) for complete rewrite. And if you force them (or just make them believe you may do it) they will complain and it means bad press, in a very competitive market. It may not be something Apple can afford.

> What if they just 'did it right'

You can't "did it right" without support of large amount of users, regardless of the money. The definition of "right" in programming languages is "works for users". And to get users onboard, you have make sacrifices.

> A lot of people want to make apps for iPhone and ObjC is not in their vocab.

And even more has existing apps to maintain. Tradeoffs have to be made.

> great docs, examples that are clear and well marked in terms of versions, all new APIs for Swift, left in beta for longer, and made mostly backwards compatible changes

All those things will come. If you want them, wait for them. Being early adopter has its cons.

Re:Swift Changes Considered Harmful by edblarney on Saturday February 18, 2017 @07:20PM (#13677455)
"Lot of them have no budget (or will) for complete rewrite. "

I don't mean they should force people onto Swift. I mean that Swift, should be totally independent of ObjC, so that customers, if they choose to use it are not dependent on it.

Also - Apple could feasibly provide a 'lib/bridge' - just as Android can use C++ code as well, if you want to use it.

I think Apple could surely commit to keeping ObjC around for quite some time - maybe 4 years official support, and then maybe 8 years on the devices, but with no more documentation/support.

"All those things will come. If you want them, wait for them."

I don't agree - this is 'doing it wrong'. It's been out for years. This is way past 'early adoption'.

'Doing it right' means that it is easy for new and old developers. Right now - it's hard.

Doing Swift 'right':

1) Make Swift a clean break, get rid of some of the more obscure things that make it difficult. Get rid of relationship to ObjC.

2) Detailed docs, tons of examples. Examples for every single class, every single attribute. 100% of functionality should be 'explainable by example'.

3) Beta for 1 year, then production.

4) No backwards-incompatible changes after out of beta. (Easier said than done).

5) Docs, examples etc that clearly demarcate versioning.

6) Tons of support on Stack Exchange: dedicated staff to simply monitoring, answering, clarifying issues just on Stack Exchange.

7) 'Free Support and Training' for anyone who wants it and who can make it to a major city, i.e. NYC Jan 1-5 or 'weekend course' for anyone who registers. Free. Once every few months. At least 100 Engineers just doing training, and going into dev/studios companies to help them with stuff.

8) Free online courses, for newbs, and those coming from other languages, and Objc.

They made Swift a little too complicated, and left devs hanging in the dark on so many issues.

Re:Swift Changes Considered Harmful by fiedzia on Saturday February 18, 2017 @10:05PM (#13677986)
> I don't mean they should force people onto Swift. I mean that Swift, should be totally independent of ObjC

If you will not provide seamless integration, you will seriously limit amount of people who migrate. There are other problems here too: what should library authors do? Write two versions?

> It's been out for years. This is way past 'early adoption'.

Looking at all programming languages I've ever used, getting out of this childhood period always took years. Sure, Apple could do better job perhaps in many aspects, but it really takes a very long time to get a language and stdlib to usable shape.

>Make Swift a clean break, get rid of some of the more obscure things that make it difficult.

If you make a clean break, you limit amount of your users. Without users, you can't tell what obscure things are difficult for those who didn't opt in.

I agree with all those beta periods, stability guarantees, docs and training. I am now appreciating more how well those things work in Rust.

Re:Swift Changes Considered Harmful by edblarney on Sunday February 19, 2017 @12:55AM (#13678372)
"If you will not provide seamless integration, you will seriously limit amount of people who migrate. "

I don't agree at all.

Tons of people are 'starting out' on Swift - moreover - if Swift were done a little better - it would actually be used on other platforms, etc. - as opposed to an 'iPhone only' type thing.

New projects start all the time.

Major re-factors and re-writes happen all the time.

Second - I do not believe that the premise of: "well I can switch some of my code to Swift, but keep most of my libs on ObjC" - is reasonable. This is a minority case.

And of course - as I said - they could have provided access to ObjC libraries through an interface exactly as Android does.

You want to use 'legacy C++ code' on Android? You can do it. It's just not so clean, but you can do it. The same should have been provided for Swift-ObjC

So - companies who don't want to migrate - can stick to ObjC for a few more years.

The rest can switch over.

"If you make a clean break, you limit amount of your users."

Again I don't agree at all. Node.js has more developers than Swift. With Apple backing it (i.e. 'making it good' - but also making it 'the basis for iPhone) - they could have had an incredible number of users.

There's no reason that Swift couldn't have been used in internal-alpha for a while, then external beta for a while - then then have a 'solid v1'.

AS you say - many languages were 'around for a long time' - but they have also been stable for a long time!

Java for example, did not do anything at the .lang level that was not backwards compatible. The only non-backwards compatible bit was java AWT, which they replaced with Swing. But even AWT is still supported!

So, there's no excuse for rapid rollout of versions that are incompatible with one another, no excuses for huge gaps in documentation etc..

Re:Swift Changes Considered Harmful by mpweiher on Saturday February 18, 2017 @05:37PM (#13677078)
>compatible with ObjC was one of the big issues

Considering that was going to be hard requirement, maybe the problem was introducing so many things that are so incompatible with ObjC? There are tons of ways you could vastly improve the programming experience without introducing all this incompatible stuff.

Re:Swift Changes Considered Harmful by hboon on Saturday February 18, 2017 @04:33PM (#13676809)
As noted in the first link above, source compatibility isn't kept with Swift 3->4 anymore. There are changes to the String APIs.
Re:Swift Changes Considered Harmful by mahyarm on Saturday February 18, 2017 @06:30PM (#13677273)
If your an objective-c programmer, a lot of swift concepts are very close to each other. Most of the time you just pick it up as you go along. In many ways it's a cleaned up objective-c.