Swift Vs. Objective-C: Why the Future Favors Swift 270
snydeq writes: InfoWorld's Paul Solt argues that It's high time to make the switch to the more approachable, full-featured Swift for iOS and OS X app dev. He writes in Infoworld: "Programming languages don't die easily, but development shops that cling to fading paradigms do. If you're developing apps for mobile devices and you haven't investigated Swift, take note: Swift will not only supplant Objective-C when it comes to developing apps for the Mac, iPhone, iPad, Apple Watch, and devices to come, but it will also replace C for embedded programming on Apple platforms. Thanks to several key features, Swift has the potential to become the de-facto programming language for creating immersive, responsive, consumer-facing applications for years to come."
Uh... (Score:5, Insightful)
Since when is embedded programming associated with "immersive, responsive, consumer-facing applications"? I don't think Swift is going to replace C anytime soon in that department.
Re:Uh... (Score:5, Insightful)
More to the point, who outside Apple develops embedded software for an Apple platform?
Re:Uh... (Score:5, Funny)
The NSA.
Re: (Score:2)
The NSA.
Literally laughed out loud. Good way to start the day! :-D
Re: (Score:3)
Since when is embedded programming associated with "immersive, responsive, consumer-facing applications"? I don't think Swift is going to replace C anytime soon in that department.
It was not obvious from the summary what the heck was meant by "embedded programming". In TFA, in addition to the quoted paragraph, the word "embedded" is also used in "The ability to defer loading in a mobile app or an embedded app on Apple Watch will improve the perceived performance to the user.", "Swift provides the development community a direct way to influence a language that will be used to create apps, embedded systems (if Apple ever licenses an embedded framework and chip for third parties), and
Re: (Score:2)
Since when is embedded programming associated with "immersive, responsive, consumer-facing applications"? I don't think Swift is going to replace C anytime soon in that department.
I think their idea of an "embedded system" is one where you "embed" an Apple product into it. And sure, by the strict definition you are embedding a computer in something. I'm sure there will be a market for such devices going forward. But that's really a very small corner of the embedded systems world.
I doubt very much the author of the article has any real idea what a true embedded system really is.
Re: (Score:2)
Re:Swift is destroying Rust. (Score:4, Insightful)
The important thing to remember here is that Swift is absolutely destroying Rust.
Rust has been nothing but hype so far. Many Ruby on Rails hipsters have rallied around it, but they haven't actually managed to produce anything useful with it.
Anything that can be done using Rust can be done better by using C++.
C, C++ and Go are the dominant languages on Linux. Rust has made no inroads here.
C++ and C# are the dominant languages on Windows. Rust has made no inroads here.
Now that Swift is seeing tremendous uptake within the iOS and OS X sphere of influence, Rust has even less of a chance than it had before.
I think that Swift will be seen as the final nail in Rust's coffin. Swift has provided developers with productivity, while Rust has provided them with false hopes.
We're seeing a convergence on exactly three languages: C++, C#, and Swift. Every other language is becoming a minor player compared to these Three Giants.
According to the TIOBE Index [tiobe.com], Java has more usage than all three of them put together. I'd hardly call it a "minor player".
Re:Swift is destroying Rust. (Score:4, Insightful)
I was studying programming in college when the hype for Java began. We were using C and C++. What was true then still holds true today, in that in C/C++ you can write operating systems and conventional programs, but in Java you are limited to conventional programs. Java has the theoretical interoperability feature between OSes and hardware platforms, but in practice there's a lot of customization to make programs actually do this, and if one has to write versions for several platforms, it's not a whole lot more burden to compile those and distribute binaries instead of Java runtimes.
As for servers, I've always liked the mindset of putting as little as possible on the production server beyond what its job is. Hell, the idea of statically-compiling everything to allow one to eliminate libraries, let alone compilers on the production box, appeals in that if someone does break in there's a lot less they can do once on there. Java for server-side applications flies in the face of that, there are more general-purpose tools on the server rather than less.
I'm aware that I'm not in the majority for this stuff, and I didn't make programming my profession anyway so perhaps even I should be taken with a grain of salt, but it seems like in this speed to push features we've taken steps backward in real system security, and we're being bitten in the ass by it with ever increasing frequency. The very choice of programming language appears to be fundamental to that.
Re: (Score:3, Insightful)
There's a shit load more "conventional programs" than there are operation systems
Java also solves your libraries and compile problem.
Last project I worked on the build server was Windows 2008, my dev PC was Windows 8.1 and test and production ran Linux. I don't even think prod was x86.
No cross-platform issues at all with ~ 100,000 lines of code.
Re: (Score:3)
Re: (Score:2)
Well don't forget to set the character encoding to UTF-8 on the JVM while in windows or else your URL parameters will only accept ANSI characters when using servlets. By default the JVM uses the system character encoding if you do not set it (which in windows is ISO something) so you either have to manually set the JVM to UTF-8 or configure your application to handle that.
That is just one thing that made my life annoying as a dev that needs to deploy to windows and linux. There are many more.
Re: (Score:2)
Re: Swift is destroying Rust. (Score:2)
Even when running Java you're executing more C++, because that's what the JVM is written in.
Re: (Score:2)
Re: (Score:3)
Re:Swift is destroying Rust. (Score:5, Insightful)
We're seeing a convergence on exactly three languages: C++, C#, and Swift. Every other language is becoming a minor player compared to these Three Giants.
Baghdad Bob, is that you?
Re: (Score:2)
Re:Swift is destroying Rust. (Score:4, Insightful)
We're seeing a convergence on exactly three languages: C++, C#, and Swift. Every other language is becoming a minor player compared to these Three Giants.
Wait, what? Swift is basically statistical noise at this point. "Dead" languages like ML and Pascal are higher in the tiobe index than swift is. It may become a force in the future but it's nowhere near that now.
Re: (Score:2)
We're seeing a convergence on exactly three languages: C++, C#, and Swift. Every other language is becoming a minor player compared to these Three Giants.
..."Dead" languages like ML and Pascal...
Has Netcraft confirmed that?
Re: (Score:3)
Pascal's not dead. Delphi targets every major hardware platform using Object Pascal and up to 64 bit code too.
In the tiobe list Pascal is listed separately from Delphi. Delphi is higher in ranking than pascal, which itself is higher in ranking than swift.
Re: (Score:2)
Re: (Score:2)
Even setting asside that use, in scientific computing, you pretty much either use Python, Matlab, R, or FORTRAN, depending on the complexity of your non-equation needs.
Re: (Score:2)
Speaking of C++... I'm currently learning Objective-C rather than Swift. Why? Because all I want is a thin interop layer between my cross-platform C++ code (the bulk of my game engine and game code) and the operating system APIs. Objective-C can iterop with C or C++ fairly easily, while Swift can only interop with Objective-C.
Frankly, I wish I could use Swift instead of Objective-C, whose syntax takes some real getting used to.
Re: (Score:2)
Swift can also interop with C, but it's ugly.
Re: (Score:2)
Really? Everything I dug up during research said you pretty much had to interop with Objective-C, since Swift classes are exported as Objective-C classes. I'm not doubting you, as I'm sure there's some horribly ugly way to do it, given that we're talking about C here.
Still, for my purposes, it doesn't really matter that much. I'd still prefer a "clean" interop, since I'll be doing a lot of that.
Re: (Score:2)
Re: (Score:2)
Lets not forget microcode - which is pretty much needed to make assembly work.
Unlikely (Score:5, Insightful)
It is highly unlikely that Apple is going to rewrite all that GPL and BSD code at the heart of iOS with Swift. As long as those core projects are based on 'C', they'll stay in 'C'.
Re:Unlikely (Score:5, Interesting)
I think a wholesale rewrite is unlikely, but I would guess that they are going to eventually do something about the GNU code they use. Apple doesn't like the GPLv3's patent clauses, so they have frozen all their imported GNU utilities at the latest GPLv2 version. Some of these are now getting quite old and not maintained upstream, so Apple has to handle even routine maintenance. They managed to transition off one big one by moving from gcc to clang/LLVM, but there is still a bunch of old GNU code shipped in the base system that I don't see them keeping forever. Now whether they rewrite it in Swift seems more questionable.
Re: (Score:2)
Re:Unlikely (Score:4, Insightful)
It is highly unlikely that Apple is going to rewrite all that GPL and BSD code at the heart of iOS with Swift. As long as those core projects are based on 'C', they'll stay in 'C'.
Precisely, that's what wrapper code has been for since I started coding back in the early 90s. It always cracks me up when people let fly gold nuggets like "...the Python implementation of OpenCV...". As far as I am aware, nobody rewrote all of OpenCV in Python, they created Python bindings [python.org] which is a fancy way of saying they created a Python wrapper for OpenCV. Programmers don't always realise that the API's they are using are actually wrappers. I used to use a C++ Linear Algebra library but because I just installed it with yum or apt-get I didn't pay it much thought. it wasn't until I tried to compile it for an embedded computer that I realised the thing was actually a wrapper for a Fortran 77 library that was ported to Fortran 90 and then given a C++ wrapper and that made it a bit of a bitch to compile (largely due to the fact that I didn't know squat about Fortran). Apple will provide Swift wrappers for at least some of the C/C++ libraries and the ObjC stuff if that's necessary (never used Swift myself so I don't know how well ObjC libraries integrate into Swift). Any other approach would have Apple's developers busy doing nothing but rewriting and debugging ported code for the next decade at least. What interests me is how far up shit creek will a developer be if he/she realises that they need a C/C++/ObjC library for his Swift application?
Re: (Score:3)
You don't get it, do you? Apple lives on open source code that they didn't write.
Re: (Score:2)
And a lot that they did write. That's the beauty of open source - no need to reinvent the wheel, and returning your code means you don't have to maintain a fork.
Re: (Score:2)
Why would you worry about someone "stealing" something you didn't create or pay for in the first place?
Re: (Score:3)
Re: (Score:2)
On iOS platforms. (Score:5, Insightful)
Re: (Score:2)
Apple will likely force you into using Swift for iOS9 compatibility in the next 12 months.
Nope. That is not going to happen unless they don't care about 95% of the apps on the app store not working on iOS 9. It's more likely that they will just not make new APIs available in Objective-C, so that Objective-C apps can't use the latest features.
Re:On iOS platforms. (Score:5, Insightful)
How should Apple be able to force you to use one or the other?
should or could?
Apple can easily do both.
should: because Apple says so, and they control the App Store. Apple doesn't have to give a reason other than deprecation.
could: compiled swift code looks different than objective-C code. It also links against the swift runtime and not the objective-C runtime. It's not hard to tell the difference.
Re: (Score:2)
could: Because apple compile every app submitted to the app store from source code
FTFY
Re:On iOS platforms. (Score:4, Interesting)
Re: (Score:2)
Knowing that malware authors likely submit to both platforms at the same rate
Ah, but do they? Both platforms are probably not equally easy to exploit, and both platforms probably do not provide equal returns. (Obligatory apple users easier to deceive yet wealthier comment here)
Re: (Score:2)
So if they stop including the Objective-C runtime libraries in iOS, what happens to Objective-C code?
Re: (Score:2)
Why would they do that? Preventing new app submissions (including updates to existing apps) from linking to the ObjC runtime is a lot different than not including the runtime with the OS.
Also, someone else pointed out that even Swift apps link to the ObjC runtime. I don't know if that's true for pure Swift apps, but either way, it's extremely unlikely that Apple will stop including the runtime.
Re: (Score:2)
Apple tried the whole "your app must be written natively for IOS in ObjC" before, specifically to kill off projects like Xamarin who were at the time doing a great job of allowing people to write iPhone and iPad apps in c# - the ban lasted a few months, before Apple decided the legal challenges it was facing weren't worth it and dropped the clause.
The main way in which they will force use of Swift is by dropping ObjC library updates - Xamarin succeeded because there were people willing to develop a parallel
Re: (Score:2)
Makes no sense.
could: On iOS binaries are hard linked. Without a very careful inspection, you don't know if it is linked against a Swift runtime or an Objective C one. No one is going to do that, there is no point in it.
should: Apple is long beyond the point to dictate the languages you use. There are plenty of JavaScript, LUA, Python and even SmallTalk Apps in the App Store.
Re: (Score:2)
How should Apple be able to force you to use one or the other?
Well you're going to have a hard time writing for iOS9 if the iOS9 SDK doesn't come with Objective-C bindings for the API. If they do that then practicality will dictate that you use Swift or a cross-platform language & toolchain. Sure you could create a wrapper for the SDK like some other cross-platform tools do but given that Objective-C is really only used for Apple's products it would seem pretty pointless and impractical.
Yes you're right that they can't actually force you and you could go way out o
Re: (Score:2)
have a hard time writing for iOS9 if the iOS9 SDK doesn't come with Objective-C bindings for the API. ... very hard to not be able to call that from Obj-C
The API is C/C++
The tools might be a problem, as they might in future only generate Swift code ...
Re: (Score:2)
I think you're missing the point FireballX301 is trying to make. It's not about the languages, it's about the tools. If Apple wants to move developers to Swift for whatever reason, there are ways they could enforce that to an extent by removing support for Objective-C within their tools. Sure, there may be third-party solutions that pop up (such as Xamarin with C#), but if Apple's tools don't support Objective-C code, I think that would effectively force quite a few developers to make the change.
With that s
Re: (Score:2)
Tool support is ofc an interesting point. Did not think about that as I'm not really using the Apple Tool Chain.
Re: (Score:2)
How should Apple be able to force you to use one or the other?
The same way they did when, under the old MacOS, they switched the preferred language from Pascal to C: all the documentation refers to the "new language" examples, all data structures are listed in the "new language" formats, some information needed for compatibility with the "old language" is omitted or brushed under the carpet, some data structures will favor the "new language" (e.g. C vs Pascal strings in system calls), etc.
Of course it will take time but they can do it, no doubt about that.
Re: (Score:2)
For a Pascal programmer it does not matter that the "new data types" are documented in C style.
Changing from Pascal to C strings only affected new APIs, the old ones kept the Pascal types until they finally got abandoned/deprecated.
Same with Swift, who cares if the doku favours Swift? Everyone who can C/ObjC easily can interface with the Swift libraries.
Re: (Score:2)
Microsoft is going to deprecate C# in favor of blowing a mule. Spend all of your education on mule blowing and not C#.
I have to admit, i lol'd a bit on this one.
Re: (Score:2)
I'm just waiting for the IDE for mule blowing. Is the debugger any good?
Re: (Score:2)
I'm just waiting for the IDE for mule blowing. Is the debugger any good?
It had better be -- mules can carry some pretty nasty bugs down there....
Re: (Score:3)
As an OS X/iOS dev who has used Swift... (Score:2)
Re: (Score:3)
What's with the outbreak of people who can't spell COBOL? It's like kids are trying to sound older than they are by using jargon but completely screwing it up.
Debate settled. We know the future! (Score:5, Funny)
Re: (Score:3)
Objective-C was ahead of its time (Score:4, Funny)
Objective-C was ahead of its time. It uses messaging for communication between Objective-C, and using "the runtime" (a tiny virtual machine that is embedded into each executable) messages are resolved to a function pointer. Other compiled languages use static dispatch, vtable dispatch (allows overriding) or in-lining. However, messaging gives an advantage in that it affords features that are available in higher-level 'interpreted' or 'managed' languages:
The above features allow all kinds of useful things like Aspect Oriented Programming, instrumented objects at runtime (eg for object-relational-mapping), Cocoa's elegant property observers, etc. Another advantage is that Objective-C is close to the bare-metal so its very easy to take advantage of the above, while dropping back to raw C (or C++) as needed for performance tuning, which given the 95-5 rule is not too often.
Contrast these dynamic features, with C++ which fills another niche. Now the industry has had 30 years to forget how useful these features are, so Swift uses static and vtable dispatch. Given a virtual machine, with just-in-time compilation this is no problem, but as a compiled language it means forfeiting the above. Swift allows the above if a class extends a Cocoa Foundation class, but this problems are:
I'm surprised more people didn't raise concerns about this.
Re: (Score:2)
* Object introspection - describe the methods and properties of an object
* Dynamic invocation - reflectively invoke methods of an object.
* Method interception - add or reroute methods for all instances or a single instance of an objection, optionally calling the original.
All that has nothing to do with "message passing".
Re: (Score:3)
* Object introspection - describe the methods and properties of an object * Dynamic invocation - reflectively invoke methods of an object. * Method interception - add or reroute methods for all instances or a single instance of an objection, optionally calling the original.
All that has nothing to do with "message passing".
You think so?
Runtime method interception is supported in languages that use vtable style dispatch rather than messaging, only because these languages feature a virtual machine, and class-loader. Otherwise the function-pointers are compiled right in. It is not possible to perform method interception without evil [github.com]. With Objective-C we can perform method swizzling - modify the lookup table to resolve methods to a function pointer) or isa swizzling - change the 'class', to a dynamically generated one, for a giv
Re: (Score:2)
You think so?
Yes, I do.
No idea what you want to say with the two paragraphs you "quote".
They again have nothing to do with "message passing".
The question if you can do "Reflection/Introspection" is answered by having meta data of the classes available and an API to query it.
E.g. Java supports reflection and introspection and: does not use message passing!
Re: (Score:3)
E.g. Java supports reflection and introspection and: does not use message passing!
Read my comment again. I said that Java supports method interception while still using vtable dispatch. The reason for this is that it has a virtual machine and class-loader, which provides another point of interception. Examples of this are:
Re: (Score:2)
Ahead of its time and just a decade or so behind Smalltalk in this regard.
It still amazes me how languages are still trying to catch up with what I was doing in Smalltalk 20 years ago and others had been doing in Smalltalk since the 70s.
And, yes a lot of what Smalltalk did was predated by other languages.
Agree. Objective-C was most certainly based on SmallTalk. Though except for the message parsing, which can be considered a kind of interpreter, its compiled, and interoperable with C, which was its value proposition. It does seem that we're mostly just rehashing now, doesn't it.
Re: (Score:2)
It uses messaging for communication between Objective-C
doh - I meant to write 'for communication between objects', ie method invocation.
Re: (Score:3)
yea, yea yea; Python has all of that and is scripting language too boot. Google screwed up. Instead of java, morphed into android, they should have use python with a gtk stack.
Python is great, but Java, by virtue of having a virtual machine can supports method reflection, method interception and dynamically generating new methods or instrumenting classes too, even though it uses vtable dispatch. Its still considered a 'late binding' language because the class-loader provides a hook-point, prior to emitting a just-in-time compiled class, the class loader can check for method interceptions and emit and instrumented one. . The catch is that Android's Dalvik platform introduces some
What is Swift written in? (Score:5, Informative)
What is Swift written in?
It is built with the LLVM compiler framework included in Xcode 6, and uses the Objective-C runtime...
So... C. Ok, we're done here.
No wait. One more thing. It's the Objective-C runtime. Which means Objective-C programs will just keep running, as they ever have.
Swift and Objective-C code can be used in a single program, and by extension, C and C++ as well.
The new language can't supplant the old one while the old one exists in the same environment. More to the point, compatibility with Objective-C, C, and C++ was an explicit design goal. So you can just pack up all the bullshit about taking over the world.
Re: (Score:2)
The new language can't supplant the old one while the old one exists in the same environment. More to the point, compatibility with Objective-C, C, and C++ was an explicit design goal. So you can just pack up all the bullshit about taking over the world.
Thank you! I was scrolling through the comments and took a damn long time before I found someone else that had the same thought I did. All Swift seems to be is a higher-level abstraction of the same animal ... C If that's the case, C, C++ and Obj-C will still be around for a long time on the platform and Swift will just jump in the bus with them.
Re: (Score:2)
What is Swift written in?
It is built with the LLVM compiler framework included in Xcode 6, and uses the Objective-C runtime...
So... C. Ok, we're done here.
That means nothing of the sort. LLVM is a compiler framework, whose back end contains rather a lot of machine language, and whose front end depends on the language being used. Most language front ends are self-hosted (written in themselves).
Likewise, using the Objective-C runtime doesn't mean anything other than that it was a convenient runtime that already existed, and they know how to interface to it. If you can do that, your sources can be in any language you prefer.
But most importantly, C fans seem
Re: (Score:2)
I prefer to think of C as "portable assembly language".
The problem with that is that it simply isn't. Take a look at the sources for any multiplatform project, and you'll see its chock full of platform-specific precompiler code sections. C is one of the *least* portable programming languages available.
Where it does get similar is that the language provides a lot of features that are frankly too low-level for a programming language. For example, there's the "auto" and "register" keywords. Those are supposed to be for telling the compiler when to put variables i
More approachable? (Score:3, Interesting)
I don't know how this idea started, but only a non-programmer could think Swift is more approachable than Objective-C. Swift is way more complicated and has more fundamentals that must be understood.
let versus var
optionals, including implicit and explicit binding
differences between structs and classes (value versus reference)
generics
different ways of specifying parameters, including named and unnamed parameters
property declarations, including a multitude of shortcuts
The problem is, if you don't learn most of the syntax in all its variety, you'll have a hard time understanding any random code you come across. Learning by example helps make a language approachable.
I disagree (Score:5, Insightful)
I've done Objective-C since before the release of the iOS App Store, and Swift almost full time since Apple released it last year...
Some of the things you mention beginners do not have to use (generics, and struts for example). To keep things simple to start with, they could just use classes instead.
I will agree that optionals might be a bit rough on the beginner - but perhaps not as starting from nothing, the concept of a bucket that holds a value instead of just using the value directly, would not be so foreign...
You also mention different ways to specify params, and shortcuts - but I see those as a major plus. You can just pick a level of detail that makes sense to you and work with that, until you feel comfortable with reducing further the syntax you use.
I think the function syntax is one of the cleanest and easiest styles to understand... I believe a few other languages have this form also, but in swift you just say something like "a function named takes in these params, and outputs those params" So it looks like:
func myFunc (a:String, b:Int) -> (a:String, b:Int)
it's just so balanced that you can have any number of things in or out.
There are a few things I think make Objective-C less approachable.
The separate header files, and the heavy modern use of private categories to define most internal properties confuse people as to where they need to define things.
Simply more verbose syntax all over. I like verbosity myself, I love named parameters... you get that with Swift though with a lot fewer characters typing.
Part of that extra syntax in ObjC is the shorthand to make arrays like @[] and @(value) to make NSNumbers... but in Swift Integer is treated the same as String, both are first class objects that you can do things with so it's more consistent. That in particular is I think a large benefit for newcomers.
Re: (Score:2)
I like syntactical shortcuts too. Apple has added many to Objective-C over the years, and I have welcomed all of them. However, there is still a single style. For any particular feature, there's one syntax that works. Contrast with Swift. Even if you learn only one style and stick with that until you're comfortable, it's hard to learn from others because code can be in so many different styles. If you hit a shortcut you're not familiar with, you hit an obstacle. By definition, a path with obstacles i
Re: (Score:2)
I don't know how this idea started, but only a non-programmer could think Swift is more approachable than Objective-C. Swift is way more complicated and has more fundamentals that must be understood.
let versus var
const char* vs char* vs char const*
NSInteger vs const NSInteger
NSString vs NSMutableString
optionals, including implicit and explicit binding
NSInteger vs NSInteger*
nil vs NULL vs NSNull
differences between structs and classes (value versus reference)
NSInteger vs NSColor
generics
vs not having generics :-)
different ways of specifying parameters, including named and unnamed parameters
vs:
[NSString stringWithFormat: @"%@", value]
[NSString initWithFormat: @"%@" arguments: va_arg]
NSStringFromPoint(pt)
property declarations, including a multitude of shortcuts
vs
@property(readwrite,copy) NSString* foo;
The problem is, if you don't learn most of the syntax in all its variety, you'll have a hard time understanding any random code you come across. Learning by example helps make a language approachable.
The problem is that you are judging a new language's learning difficulty by comparing it to a language you already know.
That said, Swift is not solid enough to live there 100%
Re: (Score:2)
I don't know how this idea started, but only a non-programmer could think Swift is more approachable than Objective-C. Swift is way more complicated and has more fundamentals that must be understood.
let versus var
Neither "var" nor "let" is more approachable to someone not already informed. Programmers know variables, mathematicians are familiar with the "let" convention.
optionals, including implicit and explicit binding
Optionals are actually pretty intuitive when you're not already in the programmer's mindset. Why can't we simply ask whether something is there or not? Many languages force you into all sorts of silly workarounds, including subtyping, flag management, or (lazy man's favourite) exception handler.s
differences between structs and classes (value versus reference)
There's never an easy answer to that one. Values are fa
Re: (Score:2)
Correction to the correction:
unwrapping
I didn't get much sleep.
Swift is not ready to replace ObjC (Score:4, Insightful)
> 8. Swift supports dynamic libraries
The swift runtime is a static library (written in C++11) and linked in every executable, everytime there's an update to swift (runtime) you need to recompile all your code (see Apple's swift blog, first entry). This is why swift cannot be used for system API / libraries, at least until they have a stable runtime that can made a dynamic lib (like Obj-C is). But it being C++, I don't know if that ever gonna happen.
Re: (Score:2)
The swift runtime is a static library (written in C++11)
I had absolutely no idea that the Swift runtime was written in C++11. Can someone please provide a link to this, since the parent is an AC?
Re: (Score:2)
A significant, though perhaps still minor, portion of Cocoa Touch is also written in (Objective-)C++.
Re: (Score:2)
Swift Blog July 11th 2014 entry [apple.com].
The embedded part is actually quite small and it's only there because the language is still evolving (and to allow apps to target the previous versions of OS X and iOS). The main re
I'll start using Swift (Score:3, Insightful)
Replace C? (Score:3)
"Swift will not only supplant Objective-C when it comes to developing apps for the Mac, iPhone, iPad, Apple Watch, and devices to come, but it will also replace C for embedded programming on Apple platforms."
Not if you want to write something that compiles on other platforms. With Android/iOS being based on Linux/BSD it could very well make sense to write the back end of your app in C/C++ and only then branch into a different language as required by the GUI framework and other required proprietary APIs you'll be using.
Re: (Score:2)
"Swift will not only supplant Objective-C when it comes to developing apps for the Mac, iPhone, iPad, Apple Watch, and devices to come, but it will also replace C for embedded programming on Apple platforms."
Not if you want to write something that compiles on other platforms. With Android/iOS being based on Linux/BSD it could very well make sense to write the back end of your app in C/C++ and only then branch into a different language as required by the GUI framework and other required proprietary APIs you'll be using.
We tried this. It turned out to be not much fun. (Thought maybe we weren't doing it right).
Re: (Score:2)
We tried this. It turned out to be not much fun. (Thought maybe we weren't doing it right).
To be fair, my experience with this was taking a Windows/Mac OSX program written by predominately C++ programmers and porting it to iOS and Android. The C++ code was already well debugged.
Threading is usually a big concern. In Objective-C/C/Swift tools like grand-central dispatch make this easy, however in C++ its p-threads. C++11 has threads, but this isn't supported by Android yet.
The native environment give you an API of libraries and a community of open-source projects to fill in the gaps. With C++ you have identify and source your own stack. Poco or boost. etc.
Boost assuredly. It's what has been incorporated into C++11 and makes up the bulk of its new features(e.g. you mentioned threading).
Re: (Score:2)
"Swift will not only supplant Objective-C when it comes to developing apps for the Mac, iPhone, iPad, Apple Watch, and devices to come, but it will also replace C for embedded programming on Apple platforms."
Not if you want to write something that compiles on other platforms. With Android/iOS being based on Linux/BSD it could very well make sense to write the back end of your app in C/C++ and only then branch into a different language as required by the GUI framework and other required proprietary APIs you'll be using.
I take it you've never written cross-platform code for MacOS? There's a lot of things like memory management, for one, that you'd want to use Obj-C for. By the time you've done all the "required proprietary API" changes, you'd have been better off just writing the whole thing in Obj-C. Not only would it save dev time, the end product would be a lot more stable and have better overall performance, but I guess it depends on what trade-offs you're willing to accept.
Re: (Score:2)
I take it you've never written cross-platform code for MacOS? There's a lot of things like memory management, for one, that you'd want to use Obj-C for. By the time you've done all the "required proprietary API" changes, you'd have been better off just writing the whole thing in Obj-C. Not only would it save dev time, the end product would be a lot more stable and have better overall performance, but I guess it depends on what trade-offs you're willing to accept.
Cross platform Obj-C? You mean with GNUStep? I have never used it. Have only written Obj-C in Xcode. As far as memory management, C++ has smart pointers, including one that does reference counting. Why would the performance be better with Obj-C?
Although my experience with Obj-C is more limited I find it more painful to use than C++.
Re: (Score:2)
I take it you've never worked on an app with a well-defined logic layer. Apple writes a lot of C++ themselves, and they're not concerned about portability beyond OS X and iOS.
Good grief. (Score:3)
FYI, I'm an iOS developer who uses a mix of languages, including Ob-C, every day. My coworkers and I met Swift with a mildly positive reaction - it's a decent, if imperfect, effort. It's not the second coming of Christ, but it definitely isn't a bad thing to try to modernize some of Ob-C's age-related shortcomings. The notion that we'd re-write code just to use it is utterly laughable, but we could certainly see ourselves using it to start a new app, or maybe at our next jobs.
The OP, though, sounds like a marketing intern wrote it. To add a little historical perspective: our apps are a riotous mix of C and C++ (for Android portability) and Ob-C. We chose to do it this way, within the last 3 years, so this is not a legacy issue. Both C++ and Ob-C were, at one time, meant as "replacements" for C, and we know how that turned out.
Swift may very well become the preferred language over Ob-C within, say, 5 years, for Apple-specific development. But the breathless "it'll replace C!" rhetoric is just silly. Over the coming decades, C will surely fade, but it will be replaced by other, newer, even more amazing tech, not just Swift.
Mature, third-party libraries... (Score:2)
So, mature, third-party, solid, stable, best-in-class, tried-and-true libraries that are the standard foolproof way to do "X" (choose from many "X"s) will all re-write themselves from C or C++ to Swift, and then keep themselves in sync with the mainline library, right?
C and C++ will continue to be used in iOS apps for the same reasons that so many (of the better...) Android apps color outside of the approved Java lines and use C/C++ using the NDK.
There's some of us who've seen this before... (Score:4, Interesting)
And we know from experience that WHENEVER somebody uses terms like "language <XYZ> is the future", it is inevitably baseless speculation, and often rests on the false belief that some single programming language, or any single technology for that matter, can actually be the "best" one.
Brooks said it best, There is No Silver Bullet [worrydream.com]
You wanna Vegas that claim? (Score:2)
Predictions are like assholes; everybody has one.
Swift or Dylan? (Score:2)
I just can't decide on which loosing horse I should all my money!
Jokes aside, anyone who knows a little bit about the history of Apple should be careful not to put too much efforts in one of their 'projects'. At least develop the core of your applications in C or C++ and use the proprietary technology just for GUI glue code. Unless we're talking about another fart app that requires zero know-how and programming effort anyway.
Swift for the system programming? (Score:3)
People keep bringing up the Swift in context of system programming, but so far I haven't seen any concrete info about features of the language which make it even suitable for the system programming.
The thing is, even C++ was/is used for system programming, but its C++-ness is so castrated that it is hardly can be called C++ anymore.
I personally do not see any reason to replace C with another language, which I can't use to its fullest. On top of it, lots of C extensions are needed to make the system development efficient: code/data section assignment, untyped/unchecked memory access, memory/IO barriers, assembler intrinsic. None of that is part of C standard - all of it are vendor/compiler extensions. While Swift documentation is devoid of the similar features.
P.S. If Apple folks want to push the Swift into the embedded area... Good luck. Even C++ still struggles. Higher-end embedded system require proof of validity and literally all of the solver software is C-only. Most static/dynamic code analyzers - C-only too.
Re: (Score:2)
Re: (Score:2)
Maybe. But VB developers were really inexpensive. If you found a good one, they were crazy productive as well.
Re: (Score:2)
Of course it does. If you're productive, and people are actually using your code, then you're effective.
VB6 has enabled a lot of people to get a lot of useful stuff done. This is widely considered (on Slashdot at least) to be a Bad Thing.
Re: (Score:2)