Apple's Swift 4.0 Includes A Compatibility Mode For 'The Majority' Of Swift 3.x Code (infoworld.com) 122
An anonymous reader quotes InfoWorld:
Swift 4.0 is now available. It's a major upgrade to Apple's Swift, the three-year old successor to the Objective-C language used for MacOS and iOS application development. The Swift 4 upgrade enhances the Swift Package Manager and provides new compatibility modes for developers. Apple said Swift 4 also makes Swift more stable and improves its standard library. Swift 4 is largely source-compatible with Swift 3 and ships as part of Apple's Xcode 9 IDE...
Swift 4's new compatibility modes could save you from having to modify code to be able to use the new version of the compiler. Two modes are supported, including the Swift 3.2 mode, which accepts most source files built with Swift 3.x compilers, and the Swift 4.0 mode, which includes Swift 4 and API changes. Apple said that some source migration will be needed for many projects, but the number of source changes are "quite modest" compared to many previous major changes between Swift releases.
Apple calls Swift 4.0 "a major language release" that also includes new language changes and updates that came through the Swift Evolution process.
Swift 4's new compatibility modes could save you from having to modify code to be able to use the new version of the compiler. Two modes are supported, including the Swift 3.2 mode, which accepts most source files built with Swift 3.x compilers, and the Swift 4.0 mode, which includes Swift 4 and API changes. Apple said that some source migration will be needed for many projects, but the number of source changes are "quite modest" compared to many previous major changes between Swift releases.
Apple calls Swift 4.0 "a major language release" that also includes new language changes and updates that came through the Swift Evolution process.
The *majority* of code (Score:3, Funny)
Don't you just love things that nearly always work?
Re:The *majority* of code (Score:5, Insightful)
I used to be somewhat critical of the compatibility-breaking change of Swift, but I'm wondering if this isn't a decent approach for the long-term benefit of the language. It certainly seems to be better to make incompatible changes early in the language's adoption life cycle than to wait too long, then break things, which causes a lot of problem when there's a huge existing body of source code. Moreover, everyone was warned well in advance that Swift would be making changes up to at least version 3 (and apparently, slightly beyond), so it's not like this should catch developers off guard.
I'd imagine the benefit of making changes post-release is that you can account for real-world feedback based on actual experience with the language, rather than purely theoretical designs. I'd have to think this makes for a better language in the long run.
The big caveat here is whether the Swift developers stop tinkering with the core language and allow it to stabilize for the long term, at least in terms of backwards compatibility.
Re: (Score:1)
Re:The *majority* of code (Score:4, Informative)
This doesn't break shipped apps. Any app using Swift right now deliberately has everything compiled and bundled to be self-contained. Changes to Swift have no impact on shipped binaries.
Re: (Score:2)
I don't think you're a developer, cos we know that breaking existing products already in the users hands is a good way to stop sales.
How many end-user products are still in (Swift) source code? And, if such products are not common - how do language changes affect already-compiled products?
Re: The *majority* of code (Score:2)
Re: (Score:2)
I almost put "nearly" in italics. Probably should have done.
Incompatibility per se[1] isn't the issue. It's this #smegma or whatever it is that doesn't work for the *minority* of code. In what way does it not work? Compiler warning[1]? Compiler error? Just do random shit?
[1] Who takes notice of those?
Re: (Score:3)
My response was slightly tangential to your point, I suppose. Yeah, I agree an issue is definitely the behavior of that "nearly." If it simply flags an error, no problem - you correct it manually and move on. If it's more ambiguous, then that could be a problem. I looked at the linked article, and didn't see an immediate answer to this. Not that affects me in any way, of course, as I'm not using Swift. Objective-C is far better at interop between my C++ code and the Cocoa APIs, so that's what I'll con
Borland Delphi 7 (Score:2)
Is this sort of like the whole community of Delphi Pascal users who have cut themselves of from whatever Embarcadero is selling and are still using Delphi 7?
Embarcadero Delphi (Score:2)
Compiler errors, dude. Lots and lots of compiler errors.
Both (Score:1)
Every new version of Swift shifts some things around slightly, mostly those changes result in error messages - usually clear enough the fix is obvious right away.
Also though, with each new release of Swift they add new compiler warnings, so usually you end up with a number of new warnings across your codebase. However these have generally been really helpful warnings, that were pointing out potential problems and really did require a fix. That has been a very useful component of each new version of Swift.
Re: (Score:3)
At least Python only breaks compatibility every 10 years or so, not on an annual basis. And the transition from 2 to 3 was handled pretty well, with __future__ allowing devs to write forwards compatible code before the switch, a 2to3 converter that mostly automated the migration itself, and continued development of the 2 branch afterwards. As for people arguing about changes that's true for every feature in every language and has little to do with compatibility.
Re: (Score:2)
Re: (Score:2)
XCode always offers auto migration for new Swift versions. Deals with the easy stuff. In most cases will deal with everything.
Re: (Score:2)
I don't hate Rust. I am completely indifferent to it, though.
Re: (Score:2)
Re: Swift is doing great. Go is doing great. But R (Score:2)
Security, dynamic libs allow distros to deliver new versions of libs like openssl whch have security fixes, staticaly linked libs make that very hard.
Re: (Score:2)
It also opens up ways to decrease security (by replacing a library module). In most other ways I think statically linked code is the best choice at this point given good infrastructure support.
But it isn't like a combination of static and dynamic linking isn't possible today, mix and match to suit the program under development. Or even ship the main code as pre-compiled code and link at installation time -> possible to replace with a new openssl library if needed. Or even better allow installation time s
Re: Swift is doing great. Go is doing great. But R (Score:1)
Because Rust is backed by a dying company.
There are plenty of good niche languages like Elixir, but people only have so much free time. They want SDK support, they want a wealth of Stack Overflow support, they want upper management to say yes to it. This is why niche languages stay niche.
Rust is dead unless a major player backs it.
Why Swift over Modern C++? (Score:1)
What benefit does Swift have over Modern C++ (C++14 & C++17)? Why should I choose Swift instead of Modern C++?
Re:Why Swift over Modern C++? (Score:5, Informative)
- Emphasizes compile time & native code much like C++
- More powerful type system
- Safer language by design
- Native string type built into the language that is Unicode compliant (not a library like C++)
- No header files
- Large standard library (Foundation) being made cross-platform with built-in things like networking, date handling, file system abstractions, regex
- Features to replace the runtime things that GUI programmers found useful in Obj-C/Cocoa, but doing them at compile time and with stronger type safety
- Syntax is not constrained by C legacy compatibility
- Will eventually have stable ABI so you can share binary libraries
Re: Why Swift over Modern C++? (Score:3)
"Eventually" will have a stable ABI. In the mean time, they still break the whole language about as often as C++ releases a new revision.
Now I feel about about already having used the Apple "courage" joke today.
Re: (Score:1)
It's a new language, you don't have to use it yet. This drastic breaking is to make it a better language in the long run. Even though C++ is certainly the more practical language at the moment, you have to admit it carries some terrible historical decisions along with it.
Assuming Swift stabilises down in a few years, maybe consider it then.
Re: (Score:2)
Ummm... you forgot optionals and closures being first-class citizens.
As to the OP, if you want to write software for OS X / iOS / Apple TV / Apple Watch, you can't do so in C++.
Re: (Score:2)
I didn't forget. I just didn't think it would be interesting to the OP.
- I didn't think optionals would be a familiar concept to a C++ programmer. They are also integrated with the type system and I already listed the type system.
- C++ has lambda functions now. Swift has simpler syntax, but I already listed syntax.
I am curious if you say C++ lambdas are not first-class citizens. What are examples of its limitations?
Re:Why Swift over Modern C++? (Score:4, Insightful)
C++ lambdas don't automatically extend scope of capture expressions, so you need to know what you're doing when you use them. If the lambda is going to outlive its containing invocation scope, you need to capture by copy or move. C++ gives you more low-level control over how the lambdas behave.
C++17 adds optionals, variants and any type to the standard library. They're inspired by the corresponding types in Boost, but with a lot of the rough edges cleaned up. There's some argument to be had over language vs library, but the C++ way has always been to prefer library.
Claiming that you can't write OSX apps in C++ is just silly - I do it all the time.
Re: (Score:3)
You can write software for Apple OS's in C++. You do need a layer of Objective-C++ for the Cocoa interface though.
Re: (Score:2)
I think a potential for a future stable ABI isn't worth much when they can't even release an update of the main language that is compatible with existing code.
majority? (Score:2)
You know, ReactOS runs the majority of the Win32 programs. So, who's ditching Win10 and heading to ReactOS?! ;)
Re: (Score:1)
At this point in time, it's possible that ReactOS runs more Win32 programs than Windows 10.
I certainly have a few Win32 favorites I can't run on Windows 10.
Re: (Score:2)
There's a nice ReactiveX library for Swift. (RxSwift)
This is why I jumped off the Apple treadmill (Score:3, Interesting)
For the code which I write in Apple's languages, I use a simple subset of the language, trying to avoid features that are likely to be changed in the future. It makes me sad because there are some nice features, but I don't want to use them because the pain of rewriting code (for no reason) is worse than the benefit I get from those features.
Re: (Score:3)
That's a reasonable risk/reward position. It's good that the state of the art moves forward, and it's also good that stable not-moving options exist too.
In general the problem is that these languages aren't moving forward. They are just churning. In some cases, the only difference is the order of parameters in a method.
Re: (Score:1)
It's only churn if the changes are going back and forth. There is nothing wrong with improving an API,
Language design is an old, old problem. Parameter ordering consistency is also a well known, old old problem. If you can't get it right the first time, then you have no business designing a language.
Re: (Score:2)
Can you give an example of an Apple API that has simply changed the order of the parameters?
Re: (Score:1)
Re: (Score:2)
The selector, then an object to be passed to the selector, then whether to wait to continue.
That hasn't changed order, has it?
Re: (Score:2)
Re: (Score:2)
No with me I don't think.
Swift didn't come out till 2014. And there certainly wan't any switching round of parameters in long established APIs in Obj-C.
I'm not sure you are complaining about anything real here.
Re: (Score:1)
I'm not sure you are complaining about anything real here.
I'm not sure you're not a moron. So there. Insults traded, good job.
Re: (Score:2)
So you have nothing. You were making it up. Don't be surprised when you get called out on it.
Re: (Score:1)
You were making it up.
Liar.
Are you seriously going to commit to the position that Apple maintains backwards compatibility? Because they don't.
Re: (Score:2)
It's not a lie. You claimed they switched around the order of parameters. I asked you for an example, and the one you mentioned wasn't true.
Backwards compatibility: no they don't keep or pretend to keep that. But that wasn't the point in question.
Re: (Score:2)
It's not a lie. You claimed they switched around the order of parameters.
They did.
Backwards compatibility: no they don't keep or pretend to keep that. But that wasn't the point in question.
IT is the entire point.......why do you think this thread started?
Languages that aren't stable have users with Stockholm Syndrome.
Re: (Score:2)
Backwards compatibility is a good thing. But it's not the only thing. It's balanced against improving the language for the better. There's a balance to be made.
But this isn't about why the thread started, it's about this particular comment you made: "Language design is an old, old problem. Parameter ordering consistency is also a well known, old old problem. If you can't get it right the first time, then you have no business designing a language."
Apple hasn't been reordering their parameters, and "you have
Re: (Score:2)
Got any good examples as to "order of parameters changing in a method"?
Swift was originally tied pretty closely to the Objective-C API and headers. Swift 3 did do a host of function/parameter renaming, but on the whole they simplified the language and API quite a bit. Besides, one auto-migration and you're done.
And if you're skipping most of the new features, then you're not using optionals, closures, enums, and other new features to your advantage. Apple has some numbers that indicate Swift reduces the num
Re: (Score:2)
And if you're skipping most of the new features, then you're not using optionals, closures, enums, and other new features to your advantage.
Oh what a shame.
Re: (Score:3)
How much say did you have over the directions that C and C++ have taken lately? None.
It's the nature of the changes. C++ and C both have heavy commitment to backwards compatibility (your stupid examples to the contrary notwithstanding). Apple has a 3 year commitment to backwards compatibility. They change things for cosmetic reasons.
C++11 altered the "export" keyword's behavior. C++17 removes support for trigraphs.
ok, you convinced me. I'll use C for better compatibility.
Re: (Score:2)
At some point in C it became illegal to omit int as the return type of a function. It's also no longer legal to use a function before the compiler has a prototype. Those are two examples off the top of my head.
Re: (Score:2)
btw, you can use a function before the prototype, and you can also omit the return type of a function. LLVM will give you a warning, but it will compile. I've also noticed that in his modern code, Donald Knuth prefers the old style function parameter declarations. Kind of weird, I didn't realize those still work, too.
Re: (Score:3)
Actually there's a swift-evolution project where quite a few people (including non-Apple employees) are involved with Swift language design, proposals, and evolution.
https://github.com/apple/swift... [github.com]
And as there's a Swift roadmap out there, I don't think the whole "on a whim" thing has merit either.
Re: (Score:2)
Ah, come on phantomfive! ... just transform old code into libs and use the new Swift for new projects.
You are smarter than that.
Just because Swift 4 is out, it makes Swift 3 not dead. And as both compile down to ordinary *.o/*.lib/*.so files, they can interlink each other.
No need to rewrite Swift 3 code to Swift 4
If the old code can't be a lib, just keep it as Swift 3 and use the old compilers for it, problem solved.
Re: (Score:2)
Ah, come on phantomfive! You are smarter than that.
Thanks :)
Just because Swift 4 is out, it makes Swift 3 not dead. And as both compile down to ordinary *.o/*.lib/*.so files, they can interlink each other.
How long do you think Swift 3 will be maintained?
Re: (Score:2)
Does not really matter how long it will be maintained, as long as you keep the tool suit around.
As it is open source, and there are already alternative compilers, I would assume you have a decade or more.
Actually I would like to do some work with Swift, too. But I have no idea about a program I could write. Except my idea of a kind of HyperCard clone :D but I guess I make that for Android first, and not iOS.
Re: (Score:2)
Re: (Score:2)
You can't link Swift 3 to Swift 4. They haven't nailed down the ABI yet.
Re: (Score:2)
But you can recompile the Swift 3 source code with the Swift 4 compiler and get a Swift 4 compatible binary.
https://stackoverflow.com/ques... [stackoverflow.com]
Re: (Score:2)
That's exactly what I felt when I was doing iOS development. All my code was littered with yellow "depreciated" warnings. Trying to keep stuff "current" was an exercise in futility, because they would just depreciate a load of other stuff with the next iOS release.
Re: (Score:2)
The word is deprecated, not depreciated.
And you've got to fix those warnings, no matter who caused them. Leaving them hanging around is a recipe for things getting worse and worse, no matter what language or platform.
Re: (Score:1)
No they're not, but I take it you've never developed for iOS
Re: (Score:3)
No what aren't?
Yes, I'm an iOS developer. Have been since 2008, and a developer in general since the 1980s. Seriously, always fix your errors then your warnings before you do anything else. Anything else will bite you in the arse.
Re: (Score:2)
Even then, get rid of them. Even if you have to suppress them individually after checking with a #pragma to get a clear build. Because if you get into a habit of ignoring warnings with each build, you won't notice new warnings when they appear.
A rhetorical flourish (Score:2)
Claiming backwards compatibility is easy when your reference point was standardized 15 years after the creation of the language.
(Note: this metric still leaves Python3 as fair game.)
Re: (Score:2)
This is why I'm staying on (Score:1)
It makes no sense to to keep a new language tied to features introduced at start, because you find slightly better ways or syntax to do what you were trying to do before - especially when you heavily factor in community feedback, as Swift does far better than almost any language I have seen (Java actually did a decent job of this earlier).
In practice Swift has been great to use - you have a large timeframe to migrate code to newer versions (hence the backwards compatibility mode), and so far even on very la
Re: (Score:2)
Swift is the first language I've seen that I think has a real shot at displacing C/C++,
Shake your head and wake up man, you're in the Apple bubble. Swift will never be used much on non-Apple platforms, just like Objective-C before it (which frankly, is also a much nicer language than C or C++).
You need to look outside your own bubble (Score:2)
Shake your head and wake up man, you're in the Apple bubble. Swift will never be used much on non-Apple platforms
I'm afraid it is you who seem to be very much asleep [ibm.com].
just like Objective-C before it
That is why I know I'm right on this, because I fully agree with you about ObjC - I could tell that was not going to be of use outside of Apple's platforms (though I liked working in it anyway).
But having done a wide range of programming in the past, from Java to C and C++ and Javascript and Lisp and various flavo
Re: (Score:2)
Still peering inward I see (Score:1)
It's a completely non-Apple platform; in general Swift server side development has been advancing fairly well and is not just tied to IBM.
You truly cannot see the value of using Swift server-side, as well as on the client?
I wonder if you even knew that Swift has been running on Linux for quite some time now...
Re: (Score:2)
Journey to the Center of Willful Blindness (Score:1)
Uh, these aren't even arguments.
They are, I'm sorry you cannot see them, but to paraphrase an old saying, you can't lead a horse to think...
Plainly you are being obtuse, and cannot see the larger picture here. I'll let you have the last response so you can firmly cement your position in history for me to look back on and laugh ten years hence.
Re: (Score:2)
Re: (Score:2)
Shake your head and wake up man, you're in the Apple bubble. Swift will never be used much on non-Apple platforms
I'm afraid it is you who seem to be very much asleep [ibm.com].
Wellll.... I very much enjoy my hacking in Swift. But I don't give it a big chance of taking off among the open source crowd. Yeah it runs on Linux, and I love it for that. But I think we'll see adoption like Mono: used here and there, but not in any major way.
That said, Swift strikes a number of very nice balances in my opinion. I really like the expressiveness of the language, especially how easy it is to throw in some .filter {} , .map {}, and what have you.
Re: (Score:2)
..just like Objective-C before it (which frankly, is also a much nicer language than ... C++).
Objective-C has one or two nice syntactic tricks, but it's a very weak language compared to C++. About the only thing that it had going for it was that Apple provides a decent set of libraries- not like that isn't also available for C++, but at least Objective C had "one true standard" for such things.
Re: (Score:2)
Objective-C has one or two nice syntactic tricks, but it's a very weak language compared to C++.
Except for anything "Smalltalky" that Objective-C can do but C++ can't? I mean, I agree that Objective-C has quite a few problems, but C++ turned out to be a clusterfuck with no clear direction.
Re: (Score:2)
C++ has operator overloading.
Re: (Score:2)
When I need to write for iPhone, the meat of the code gets written in C or C++
Then I wonder what you write, because the meat for most apps basically is the interface. For which Apple gives you a nice framework, UIKit. Are you saying that you avoid UIKit? Not trying to be sarcastic or anything, just genuinly curious what kind of apps you build.
Re: (Score:2)
Meh. NBD (Score:5, Interesting)
I have a whole bunch of apps, going back years (ObjC). I have also been programming Swift since announcements.
I don't need no steenkin' compatibility modes; mostly because I tend to keep in my lane, and don't use too may shiny "tricks."
It took about five minutes apiece for me to fully (and buglessly) convert all my apps. More than 40,000 lines of Swift.
Several of the apps have already passed App Review, and are in the wild.
However, all you Apple haters can have all the fun you want, slagging Apple. I've been hearing the same lame shit since the mid-'80s. You ain't exactly blazing a new trail, here.
Its only 3 years and has had 4 major releases?? (Score:2)
This doesn't exactly sound like a stable platform to develop on if they can't even manage full backwards compatibility at compile time, never mind run time. Unix C programs I wrote back in the 90s I can still compile today on modern compilers - Swift will probably just be another language footnote in 20 years time but even if it isn't, I suspect the chances of being able to compile a program written in Swift 4.0 unchanged in 2037 I suspect will be near zero.
Seems like Apple is following MS in the rush to ma
Re: (Score:2)
Good luck tying to keep up with a modern programmer, whilst doing all your coding in C.
Re: Its only 3 years and has had 4 major releases? (Score:2)
I write a lot of to the metal system code including drivers. What will this âoeModern programmerâ be using? Swift? Python? Please...
Re: (Score:2)
If all you are doing is writing drivers or embedded stuff, then C will serve you fine. But be clear about the fact that your preference is suitable for your niche, and most people are not in that niche.
C is not a good general purpose programming language any more.
Re: (Score:1)
How sad to see posts on Slashdot complaining that technology is moving too fast.
Re: (Score:2)
Most compilers will still compile K&R style C without a fuss , albeit with come compile flags needing to be set.
Re: Its only 3 years and has had 4 major releases? (Score:2)
Could is not the same as will.
Re: (Score:2)
Comprehend Python? I can't even see it!
Re: (Score:2)
...there's way too much information to decode the Python. You get used to it, though. Your brain does the translating. I don't even see the code. All I see is blonde, brunette, redhead. Hey uh, you want a drink?