Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

firewood

macrumors G3
Original poster
Jul 29, 2003
8,144
1,389
Silicon Valley
Apple introduced a new programming language today at WWDC. Although Swift uses a similar run-time model to Objective C, the syntax is completely different.

Swift looks cleaner, safer, faster and probably easier to learn than Objective C and C. Especially with the built-in JIT/interpreter and Playground.

PDF documents and an iBook on Swift programming are already available from the Apple Developer web site. Get 'em while they're fresh.

To bad about all those obsolete books on Objective C...
 
I'm at work and can't try the new Xcode yet, but I can still use Objective-C in my current app I'm working on right? From the slides and other information it looks like you can use C, Objective-C and Swift to make Mac/iOS programs now.

Apple will obviously be switching gears away from Objective-C in the future, but I'm not stuck needing to implement things in Swift now.
 
im considering learning a programming language. Would this be a completely new coding language that i would have to learn separately or?
 
Does anyone know if you can use Swift outside of Xcode 6? I want to learn the language but it looks like all I can do right now is read the book that they released today.
 
Does anyone know if you can use Swift outside of Xcode 6? I want to learn the language but it looks like all I can do right now is read the book that they released today.

I'm 99.999999% its Xcode 6 only.
 
This is not for the same Swift as the one Apple released today!

Oh great, yet another overloaded name.

I wonder how many different programming languages named "swift" there are. There seem to be at least two before Apple's announcement today:

1. The Swift parallel scripting language. Code sample p3.swift:
Code:
type file;

app (file o) simulation (int sim_steps, int sim_range, int sim_values)
{
  simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@filename(o);
}

app (file o) analyze (file s[])
{
  stats @filenames(s) stdout=@filename(o);
}

int nsim   = @toInt(@arg("nsim","10"));
int steps  = @toInt(@arg("steps","1"));
int range  = @toInt(@arg("range","100"));
int values = @toInt(@arg("values","5"));

file sims[];

foreach i in [0:nsim-1] {
  file simout <single_file_mapper; file=@strcat("output/sim_",i,".out")>;
  simout = simulation(steps,range,values);
  sims[i] = simout;
}

file stats<"output/average.out">;
stats = analyze(sims);
Taken from:
http://ec2-54-196-24-118.compute-1.amazonaws.com/tutorials/cloud/tutorial.html

2. The Swift web language. Code sample hello.jif:
Code:
package hello;
 
import webil.ui.*;
 
public class Hello {
 
    final label{*<-*} cl = new label{Client->; Client<-};

    Text[cl, cl]{Client->; Client<-} message;
    final Panel[cl, cl]{Client->; Client<-} mainPanel;
 
    public Hello{Client->; Client<-}()
    {
        message = new Text("Hello World");
        mainPanel = RootPanel.getRootPanel(Client);

        if(mainPanel != null) {
            mainPanel.addChild(cl, cl, message);
        }
    }
 
    public static void main{Client->; Client<-}()
    {
        final Hello h = new Hello();
    }
}


They should have named it Blue Tit, which would at least be memorable, funny, and unique. Plus, we could all make "Do you mean an African or Eurasian blue tit?" jokes.
 
One thing I noticed was that they mentioned they wanted Swift apps, so does that mean that an app will be either Swift or ObjC?

Right now, you can mix, C, C++, ObjC in one app... is Swift going to be different in that you can mix it with ObjC?

If you can't mix, that'll mean you'll see a whole bunch of apps needed to be re-written and if Apple pushes Swift like Retina and iOS7, you'll see a bunch of apps gone and new ones coming in like never before.

Funny, the BNR book just came out a few months ago.. I almost ordered one.

Anyone know if the iTunes book comes in a .pdf version instead of the ePub only?
 
One thing I noticed was that they mentioned they wanted Swift apps, so does that mean that an app will be either Swift or ObjC?

Right now, you can mix, C, C++, ObjC in one app... is Swift going to be different in that you can mix it with ObjC?

If you can't mix, that'll mean you'll see a whole bunch of apps needed to be re-written and if Apple pushes Swift like Retina and iOS7, you'll see a bunch of apps gone and new ones coming in like never before.

If by "they" you mean Craig Federighi, he also mentioned that "your Swift code can fit right alongside your Objective-C and your C code, in the same application". You can see this at around the 01:46:54 mark of the Keynote video.
 
Swift can use C and Objective C functions, but not C++ (you need to wrap those in C code). As far as I know, you can only use Swift code in Objective C, and maybe C.

So if you have C++ or Objective C++, you'll need to wrap your code.
 
Swift can use C and Objective C functions, but not C++ (you need to wrap those in C code). As far as I know, you can only use Swift code in Objective C, and maybe C.

So if you have C++ or Objective C++, you'll need to wrap your code.

And C code is currently a little frontier to get working ;)
 
Lets be honest I think Apple eventually wants to get away from ObjC and Swift is the future. They won't get rid of ObjC right away, but once a certain number of developers (and core OS systems) switch over, I think they give the warning, the later drop the hammer.
 
Last edited:
Lets be honest I think Apple eventually wants to get away from ObjC and Swift is the future. They won't get rid of ObjC right away, but once a certain amour of developers (And core OS systems) switch over, I think they give the warning, the later drop the hammer.

I expect that all development going forward will be Swift.

Possibly we'll see Apple go through another transition, like from Carbon to Cocoa, where slowly but surely the old code will go away and be replaced with new code.

I mean, is Apple even done killing Carbon, quite yet, or was the newest version of Logic the final nail in Carbon's coffin (I think that's the most recent app that Apple transitioned from Carbon to Cocoa, right?)
 
Although Objective C may see some continued but rapidly declining use due to its huge existing code base (source code to around 1 million apps, plus all the stuff on github/cocoapods, frameworks/libraries, etc.), between 6 months to a year from now, all those books on Objective C will likely be in the discount/remainder and $1 bins, as anyone who doesn't know Objective C, won't be interested in it. Students and programmers will eventually be able to write all their Mac and iOS (and if we get lucky, linux) code faster in Swift.

I'm hoping some educators and teachers (e.g. not just expert programmers) will write some intro to Swift books.

But we are currently in limbo, as Swift is buggy and unfinished, and likely will be until maybe a release or two after iOS 8 ships.
 
From the Keynote my interpretation is that most of the tutorials are kind of oriented toward people that already know how to code, and much of the references seem to be to Objective-C.
It sounds like it still makes sense to first learn Objective-C to be a proficient coder and then move into Swift?
 
It sounds like it still makes sense to first learn Objective-C to be a proficient coder and then move into Swift?

For the next 3 to 6 months, yes.

After that, up to maybe a year from now, it will be easier to start directly with Swift, and just ignore Objective C, unless you get a job working on old code or libraries. All the intro books and tutorials on Swift will take a few months to write and publish, but I'm guessing that they will be a lot better than the books on Objective C.

So it depends on when you want to start.
 
Nah, I'm gonna stick with my BNR objective C book and finish it through. Can't hurt me to get some experience writing some programs in Obj C.

There isn't even a gaurantee that Swift will take over that quickly. It's still pretty new, right?
 
Look into these interesting takes and comments about both languages:

From http://daringfireball.net :

"
Aaron Hillegass: ‘iOS Developers Need to Know Objective-C’ ★
Aaron Hillegass, who I think is universally regarded as the preeminent teacher of Cocoa:
http://www.bignerdranch.com/blog/ios-developers-need-to-know-objective-c/


When Apple announced Swift, I heard a few people say “Hurray! Now I can be an iOS developer without learning Objective-C!” I have three messages for these people:

If you want to be an iOS developer, you will still need to know Objective-C.
Objective-C is easier to learn than Swift.
Once you know Objective-C, it will be easy to learn Swift.
Before I proceed, let me preface this with a confession of love for Swift. The syntax is lovely. The Swift compiler will catch so many errors for us; I’m certain that when everyone is coding in Swift the reliability of apps will improve considerably. The enum construct is gorgeous. Swift is a major step forward for the entire iOS and Mac OS X ecosystem. But…

Points 1 and 3 I agree with. Point 2, I’m not so sure about. But the real question is time. I don’t think anyone would dispute that a serious Mac or iOS developer needs to know Objective-C today. But what about a year from now? Two years? Five? At some point, the answer to “Do I need to learn Objective-C?” will be “No.” I don’t know when that will be.

I’m bullish on Swift’s uptake not because I think it will appeal to new developers (although eventually I think that will help too), but because I think it appeals to the huge base of developers who already know Objective-C and Apple’s frameworks.
"
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.