top | item 7841715

Chris Lattner on Swift

405 points| tambourine_man | 11 years ago |nondot.org | reply

198 comments

order
[+] Arjuna|11 years ago|reply
Chris demonstrated Swift and Playgrounds at WWDC 2014:

"I can build anything with Swift... from a social media application, all the way up to a high-performance, 3D game using Metal."

https://www.youtube.com/watch?v=nKMAV6owYh4#t=6436

He wrote this chapter (entitled LLVM) in the book, "The Architecture of Open Source Applications":

http://aosabook.org/en/llvm.html

* * *

On the general topic, I wrote this [1] a little earlier in another thread; I'm just impressed with how Apple is becoming a gaming powerhouse.

[1] https://news.ycombinator.com/item?id=7841744

[+] diminish|11 years ago|reply
Did he mention anywhere Swift will be open sourced, the way LLVM has been? If not, why?
[+] vacri|11 years ago|reply
Which languages that can produce a high performance 3D game wouldn't be able to also produce a social media application?
[+] plg|11 years ago|reply
Is the balloons playground he demoed in the keynote available for download?
[+] slaven|11 years ago|reply
It's amazing that Apple managed to go from hatching the idea in mid-2010 to releasing a fully working framework 4 years later, with tight IDE integration, huge amount of testing and compatibility without a single leak (that I've heard of).
[+] jayvanguard|11 years ago|reply
No doubt. Also amazing is that they promoted a compiler architect to eventually lead the whole tools group. This is good news.
[+] gilgoomesh|11 years ago|reply
The existence of a programming language named Swift under internal development at Apple had leaked. What it was for wasn't clear – it certainly wasn't clear that it would replace Objective-C.
[+] chc|11 years ago|reply
Doesn't it use the same frameworks as Objective-C?
[+] smackfu|11 years ago|reply
It's not clear how much code is actually written in Swift so far, so I'm not sure how much testing/compatibility was required.
[+] siavosh|11 years ago|reply
Great to see the credit to Bret Victor and Chris Granger's Light Table. Apple's resources can really help move forward these new ideas of what an IDE can be. If Swift is successful, a whole generation of young developers will use and improve on these ideas. Very exciting to see what happens.
[+] joshdance|11 years ago|reply
I honestly expected Bret Victor to do the demo on Swift after seeing the realtime playground etc.
[+] scotu|11 years ago|reply
He does not have a beard. I'm very skeptic this language will be successful
[+] Uncompetative|11 years ago|reply
I have a beard. Wish me luck with my new language.
[+] cbrauchli|11 years ago|reply
I think the beard test is for OS developers.
[+] gw|11 years ago|reply
It is nice that he mentioned Light Table. I would not be surprised if Swift ends up really benefitting Clojure adoption indirectly. I think one of the big hangups for newcomers is that, if you don't have experience with a Lisp, it's often difficult to understand the benefits of interactive development. If a large amount of new programmers become exposed to it, they'll be more open to other options that provide similar or better interactivity.
[+] ibdknox|11 years ago|reply
The only thing that makes me sad is that because of their focus on secrecy, they're doomed to relearn all that we learned along the way. Having played with the swift playground stuff, just an hour long conversation could've made a big difference.

Such is the way of Apple though.

[+] superzamp|11 years ago|reply
> if you don't have experience with a Lisp, it's often difficult to understand the benefits of interactive development

Also with Javascript and browsers' built in consoles you can have good times developing interactively

[+] jayvanguard|11 years ago|reply
It looks like Rust was a major influence. It has been interesting seeing all these posts claiming Swift borrowed from _their_ language.

Obviously there is a lot of feature influence between languages but it was interesting to see the ones he called out explicitly.

[+] pohl|11 years ago|reply
It's a bit of a Rorschach test, sometimes. People see what's familiar to them.
[+] tomp|11 years ago|reply
Personally, I see nothing from Rust in it (except what Rust took from other languages, like ML).
[+] prezjordan|11 years ago|reply
> I hope that by making programming more approachable and fun, we'll appeal to the next generation of programmers and to help redefine how Computer Science is taught.

I'll be cynical here: can this be done if the language ends up being restricted to apple devices?

[+] bsaul|11 years ago|reply
To me, this is going to be the only thing that matters : dill this language be used for non-apple platform coding. I've been looking for a language just like that for a very long time on the server side for example.
[+] coldtea|11 years ago|reply
>I'll be cynical here: can this be done if the language ends up being restricted to apple devices?

Sure it can. Students and school-children have been taught (and inspired) with proprietary systems and languages for ages.

Sure, it might not get to Windows or Linux users, but it still can reach tens of millions of kids and even universities (e.g Stanford already offers a well known iOS course with Objective-C).

[+] niix|11 years ago|reply
Really excited for Swift. I've tried and failed many times to learn Objective C and felt that the barrier to entry was a bit to high for myself. As a someone who writes JavaScript for a living, Swift is very inviting.
[+] Cookingboy|11 years ago|reply
Not trying to be rude, but if you've tried and actually FAILED to learn Objective-C multiple times, then you will have a much bigger problem with actually learning the Cocoa framework yourself. Objective-C does have a non-standard syntax, but its barrier of entry for actual learning is purely psychological and not technical.
[+] gte910h|11 years ago|reply
Cocoa, the API behind iOS and Mac Objective-C, is the hardest part, and is still there.

I suggest going through some detailed tutorials on building an X, so you get the feel for how views, view controllers, objects and everything all interact.

The new playgrounds look EXCELLENT for doing that! Best of luck

[+] leorocky|11 years ago|reply
Programming languages are like vehicles. If you can drive one, you mostly know how to drive the other. JavaScript has a lot more gotchas than Objective-C. If you feel comfortable with the weird "this", closures, and prototypes, Objective C shouldn't be hard. Pick up a copy of K&R to get familiar with C and then read the Objective-C docs.
[+] jiaweihli|11 years ago|reply
I'm not sure if it's XCode / playground acting up, but array equality is broken for me: `[1, 2, 3] == [1, 2, 3]` returns false. This seems to contradict the core declarations though:

/// Returns true if these arrays contain the same elements.

func ==<T : Equatable>(lhs: T[], rhs: T[]) -> Bool

Works alright for dictionaries. Is there a bug tracker for Swift anywhere to report this?

Edit:

Whoops, copied wrong declaration. ContiguousArrays actually work fine, but require an extra cast. e.g.

ContiguousArray([1, 2, 3]) == ContiguousArray([1, 2, 3])

[+] lcnmrn|11 years ago|reply
var one = [1, 2, 3]

var two = [1, 2, 3]

one == two

That's because Swift checks for safety first (variable declaration).

[+] spike021|11 years ago|reply
Another interesting thing to note is that because Swift really began in roughly mid-2010, Steve Jobs probably had his hand at least slightly in it (obviously not as a programmer).

I guess my point being that there was likely some more specific reason for why it gained momentum later.

[+] thinkpad20|11 years ago|reply
I dunno, it's possible but OTOH it's hard to imagine a guy like Steve Jobs, for whom (as far as I know) coding wasn't a primary concern, and who was dealing with cancer and much bigger fish in the i* products, being any more than tangentially involved in what would have been at the time a fledgling research language project. He was probably aware that it was happening, but I doubt that he played much of a role. Apple is after all a massive company filled with many smart people and who knows how many research projects.
[+] fataliss|11 years ago|reply
I feel like swift is really a good view on the future of programming. And it seems that in the future we have really two different kind of software engineers. As we make programming mainstream and easy, we will see some new people able to use langages like swift and dev good apps without having the slightest idea of what is happening underneath. We used to have at least a common background between software engineers but I think it gonna slowly disappear. Is it good or bad? I can't make up my mind yet, but I'm really considering more and more to go back to lower level langages as I feel like the upper levels are going to be crowded by young generations.
[+] JoeAltmaier|11 years ago|reply
"Underneath" just means "the level below where I'm writing". This has pretty much always been true, the way systems are layered. You write install scripts? Apps? Libraries? rendering engines? Drivers? OS? Firmware? Chip layout? You probably don't really know what goes on 'underneath' your layer.
[+] laichzeit0|11 years ago|reply
Off the top of my head the only times not knowing what's going on at the layer below has been a problem:

1. The layer below has a bug that manifests at the top layer. You're not sure if your code is broke or if the stuff your code is built on is broke. I see this a lot in the Java world where people use frameworks / libraries they're sometimes not even aware of they're using and it has a bug.

2. You run into performance problems because of the things you're using at the layer below you. C++ STL containers is a good example. It's pretty much black-magic, have you ever looked at the implementation? I also see this a lot in the Java enterprise world. One of the selling points of Java is that it's monkey-coder friendly. Except when it breaks and the monkey doesn't know how things work under the hood.

Other than that, you should be fine not knowing the layer below you.

[+] steele|11 years ago|reply
I can't afford to ignore it as it matures, but with my dev setup right now, I just can't afford it. Hoping to see this work well in Linux and Windows.
[+] oliyoung|11 years ago|reply
XCode6 runs alongside XCode5, you can safely play with Playground and build apps in the simulator, and even install iOS8 on a dev device and deploy there, without affecting your toolchain
[+] thehme|11 years ago|reply
Swift "greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list." I have been wondering if in fact this language will be Open Source, since it is said to have taken from other programming languages, some of which are Open Source, yet the decision to make it Open Source has not been made? Lock down.
[+] rsynnott|11 years ago|reply
In general, a _language_ is not open source; its _implementation_ is.
[+] thibautx|11 years ago|reply
Extremely excited about this language's versatility. Also great to see the work of my school's Alumni and professors going into production. This is the third time I've come across the LLVM compiler in industry use (albeit nothing to the scale of iOS' language) - anecdotally during my internship search this last semester. Will be very interesting to take Professor Adve's compiler course soon.
[+] herinkc|11 years ago|reply
Apple really took a big step. Waiting to see amazing stuffs done with Swift.
[+] LeicaLatte|11 years ago|reply
Looking forwards, here's a dream roadmap if this WWDC is any indication.

playgrounds for iPad, interface builder for iPad and finally Xcode.

[+] airjd|11 years ago|reply
I like js, but not swift.