1824 points · by psuter · 11y ago · 432 comments
- VERY happy to see the open sourcing of much of the Foundation libraries (which includes strings, dates, networking primitives, concurrency/task queues, I/O, etc). It'll provide a very strong start and make working with Swift immediately productive.
- Holy crap, there's a package manager. This has been sorely needed since about day one of Swift development, glad to see that it's been a priority as part of the effort to open source!
The Core Foundation stuff (included in swift-corelib-foundation) has been open for a while: http://www.opensource.apple.com/source/CF/
"These libraries are part of the work towards the future Swift 3 release. They are not yet ready for production use, and in fact are still in the earliest stages of development"
While not first-party, https://github.com/Carthage/Carthage
Swift's appears to possibly be limited to Swift, so Carthage will still be useful to integrate with Objective-C frameworks.
Are new versions backwards compatible?
Frankly, I welcome it after years of feeling like the only Python 3 user on Earth.
For the next few years, I expect Apple will wield a great deal more power over the Swift user community than the Benevolent Dictator For Life has wielded over his supposed minions. I hope we'll get a better language this way, and that these changes won't simply break third-party products to make changes that mostly benefit Apple.
Rich, powerful giant gives power to fork to the little people. Will it be like C#? Like Java? Eventually like Python? Should be interesting....
First ever commit found here https://github.com/apple/swift/commit/afc81c1855bf711315b8e5...
EDIT: License/Header in each of files were apparently retroactively added.
Edit: Also jckarter the creator of the Clay programming language is in there too!
Interesting that they started with git, instead of even a very small section of working code first
Edit yeah. that's basically how they are handling it but with the exception that they are using a public jira instance for language bugs, radar for xcode and nda bound bugs and a mailing list for general discussion.
I guess the "good side" is that the lawyers of other companies probably like when the code made by their programmers keeps being copyrighted by the company. But it is still an Apache license, so they can't demand too much from the users of the code.
Still, are there any negative aspects? Any imaginable danger?
Can the standard library have problems with (once in the future) having different copyright holders for its different parts?
The way it works is this: Apple is making Swift available to you (and others) under Apache 2.0. You send in some changes, which you make available to Apple (and others) under Apache 2.0. Everyone is on equal footing, and Apple can't relicense it to someone else on terms of their choosing that involve, for example, neutering the patent grant's self-destruct clause.
This was the default way that open source worked for years, before people started cargo-culting the (totally unnecessary) CLA process into their projects.
What it means from a practical standpoint, though, is that the project is easier to contribute to, what with the impedance imposed by a CLA process being, you know, non-existent.
It's so they can re-license in the future. There are some projects with so many authors that it is impossible to re-license because you need sign-off by every single person, even if it makes sense to re-license.
Your typical corporate IP lawyer might feel queasy about the collective copyright aspect, but so much of the open source world works this way now... they can suffer in their jocks.
One important question they'll ask is: "Who can enforce the copyright and licence?" (Which is when the subtle difference between joint and collective copyright matters.)
Non-trivial contributions are made under the terms of the Apache 2.0 Licence, so regardless of who owns the copyright, everyone operates under those same terms.
One common rationalisation for copyright assignment is ease of relicensing, should it be necessary. That's much less important when operating under the terms of a permissive license.
The answer is only the owner of an exclusive right of copyright has standing to sue. So any of these open source projects that have no copyright assignments would have trouble suing. But in practice, who cares. Unless you want to sue people, it literally doesn't matter.
The only folks who often care about suing are those who are trying to enforce certain types of share-alike licenses (GPL, etc) because they are ideological.
If you are using Apache or BSD, you probably aren't suing folks because you are fine with them commercializing it or doing whatever with it (and if you are using these liceneses and aren't okay with that, you may want to reevaluate your life choices)
This is a bad attitude if you want buy-in from large organizations. If you're not worried about that, no problem, but if buy-in is your goal (and I'm sure it's Apple's goal here) you can't just tell potential contributors to "suffer in their jocks."
A previous HN thread about the swift-compiler-crashes project: https://news.ycombinator.com/item?id=9020206
One tweet and the bug is fixed within a couple of hours. Wow!
Found that issue while working on the Pythonic.swift project: https://github.com/practicalswift/Pythonic.swift (btw, contributors welcome! Know Python? If so, a very good way to jump into Swift programming is by contributing to Pythonic.swift: a Swift implementation of selected parts of Python standard library)
It was perfect for the Galaga-like level in my game. I only need to define a few control points to create a robust flight path for the enemy drones. The cool thing about the Catmull-Rom algorithm is that the spline passes through the control points.
Languages like Go, Rust, and now Swift are not only great from almost every aspect over the last generation languages like C, C++, Java, but a lot noobs or scripting language developers are also converting to more low level languages. So the barrier to pick up a lower level language and become productive in it has really diminished.
Go has had a head start and introduced minimal simplicity. It's a great/powerful language and almost everybody can pick it up quickly within a few days. I wouldn't listen to people who dismiss the language for its lack of "features" and have never written more than "hello world" in it.
Swift is "important" because of Apple & iOS. It has a much steeper learning curve than Go and naturally it takes a few weeks of dedication to get comfortable with it. However, once you overcome the introductory challenge then you'll start to appreciate the language and its capabilities.
Already the job market for both languages are really high with higher than average salaries. So learning/mastering both Go and Swift is the best decision you can make.
In my area we use Go for some systems but found it scales badly from an engineering point of view to larger more complicated systems, compared to languages like Java and Scala. The JVM has much more mature tooling and libraries too.
For mobile applications it will be a while until Swift is stable on Android, so some of the cross platform languages would be a good choice. React Native, Unity, Unreal for example.
[1] https://twitter.com/mxcl/status/608682016205344768
[2] https://www.linkedin.com/in/maxhowell
[3] https://github.com/apple/swift-package-manager/graphs/contri...
[1] I couldn't think of a better way to put this, but it's not quite the right term, since you don't need any education in statistics to understand how irrational these reactions are.
I've also open-sourced the SIL Inspector that I demonstrated (https://github.com/alblue/SILInspector) and written up a post on InfoQ covering the important points of this release
https://github.com/apple/swift-package-manager/graphs/contri...
You'd never know that was the reason. You'd just be notified that you weren't called back for another interview and asked to please check back for more positions in a few months.
Both Cocoapods and Carthage should eventually be phased out with an official package manager.
FaceTime has been the subject of multiple patent lawsuits, which is what has prevented it from being opened.
See: http://www.bbc.com/news/technology-20236114 and http://www.techzone360.com/topics/techzone/articles/2014/09/...
That meant that if the goal was for interoperability, Apple had to either provide server capacity for a bunch of other people's traffic, or they would have had to come up with a way to federate the system.
Federation certainly could have been done, but that's a lot of sudden extra growth in scope compared to just taking what they had and releasing it.
[1] https://www.reddit.com/r/apple/comments/1xuzif/what_ever_hap...
Side note: Julia is great. Very easy to learn, blazing fast, powerful, general-purpose, works everywhere and even integrates well with C/Python/Fortran. As for the IDE, there is Juno based on LightTable, there is Sublime-Julia for Sublime Text, as well as Julia support for Atom.
Which raises the question: Why was the compiler for Swift written in C++? I know writing a compiler in C/C++ is probably an instinctual reaction at this point, but um ... what's the advantage of C++? especially if the language will become self-hosting?
Also if it's actually planned to make Swift self-hosting, the language you write the initial compiler in matters even less. If you're throwing it away anyway at the first opportunity, who cares about a few imperfections?
It's been open source for a while and there is a very good ecosystem that exists already for it. Plus the language itself is a pleasure to use.
I guess that says it all.
Correct spelling is certainly good, but the interesting phenomenon is getting a PR merged in a high-profile project - however slight the change - as a badge of cool.
https://github.com/apple/swift/pulls?utf8=%E2%9C%93&q=is%3Ap...
I never though of this as being resume line item grubbing behavior, now I can't decide whether to stop doing this or start putting it on my resume :)
>I think we should use GPL v3 instead.
I used to hold scientists and programmers to a different standard than most normal people, because it seemed like a certain level of advanced understanding was necessary to build anything functional in those fields. But I've since realized that special ability does not carry over into all areas of life.
It feels like seeing a ghost. I'm embarrassed to be registered with GitHub, and also to be human.
This is a dangerous and wrong idea.
I think you need to reevaluate the standards to which you hold people you know nothing about. GitHub is a free platform that anyone can post on, regardless of academic pedigree. Further, having specialized knowledge and being a troll are not mutually exclusive qualities. The humor of early hacker culture may have been more witty but it was nonetheless a means for programmers to take themselves less seriously [1].
> It feels like seeing a ghost. I'm embarrassed to be registered with GitHub, and also to be human.
Maybe that's a sign you should get over yourself.
Now, seeing this on github, I can only spend a few minutes clicking on the gif-poster's names and taking a glance at their code to see if they are actually mentally retarded or 14, and leave mystified and horrified.
I won't disagree that the stuff people have posted in that issue isn't funny. But honestly, I'd rather see that kind of thing than live in a world where people feel the need to treat everything (or even all technical things) seriously. There's enough darkness in the world without imposing more on ourselves.
I really enjoy Github as a technology platform. As a social network, not so much.
Proprietary languages, even ones backed by a behemoth like Microsoft or Apple, could never really dominate the most important platform when facing off against open competitors (even open competitors with no real money or power to speak of).
I'd love to have a higher level like Swift that can be easily ported between platforms and connected to whatever development language/environment that is commonly used on that platform.
I'm hoping that open sourcing Swift will allow something like this to happen. It seems like Microsoft is already making moves toward making Swift interoperable with .NET as a way of making it easier iOS developers to release Windows phone apps, so I'm optimistic.
Particularly in combination with Web Assembly. I wouldn't be surprised if there is already an LLVM bitcode > WASL compiler in progress.
Not in the short term. C++ is a very pragmatic language for implementing compilers, since it has good performance characteristics and allows higher-level programming idioms than C.
That said, we do expect Swift to a better language than C++ in a number of ways, so why don't we implement the compiler itself in Swift? There are a couple of reasons that bootstrapping is not a good idea, at least in the short term:
This complicates bringup of the compiler, because you have to move both the compiled language and the compiler at the same time as the language evolves. We want the language evolution and direction to be driven by general purpose programming challenges, not by the specific needs of compiler hackers. The urge to "scratch our own itch" might be too great. That said, we are writing the runtime library in Swift itself. We may also decide to rewrite the compiler in Swift sometime in the distant future when the language settles down. At that point, it may be a good opportunity to revisit previous (internal to the compiler) design decisions, and we do expect and hope Swift to be a great language for doing many things, including implementing compilers."
By using C++ they could ramp up the compiler much faster and rely all improvements done to LLVM.
Eventually if the language succeeds in the market at large, they can decide to bootstrap it.
Although I am a fan of bootstrapping, I also see a good value to expend development resources elsewhere until a language reaches wider adoption.
Saying it was "quite a pain" is the understatement of the year.
And of course it is not possible to write a Swift compiler in Swift before the language exists.
So no, not odd at all. Quite logical actually.
No, but you can do a self-hosting port after you have a first rudimentary compiler. Many compilers have been built like this. Some did it early in language development with a purpouse built one-off bootstrapping compiler, some did it after the language was somewhat stable (eg Go).
ObWP: https://en.wikipedia.org/wiki/Bootstrapping_%28compilers%29
From a language design point of view, the things needed to get a language to the point where it could successfully and efficiently compile itself would skew or re-order priorities in a much different fashion than if they were to focus on building and iterating on an applications and systems language.
tl;dr: LLVM and Clang and their assorted toolsets do quite a bit of valuable work; reinventing that to serve the language they're building is a feedback loop is a downside that also removes some upside from the equation, too.
Aside from the value of maintaining LLVM as a shared codebase, the concern was that writing a compiler in Swift could bias early language design tradeoffs towards decisions that would make it easier to write a compiler at the expense of the larger universe of potential applications.
That being said, C++ is probably a better choice, because dynamic dispatch sucks and there's better platform support.
Yes other languages have LLVM bindings, but they aren't as comprehensive as actually linking to the LLVM C++ API.
Source: Have written a (toy-ish) compiler with LLVM
Welcome to Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c). Type :help for assistance.
1> help
opening import file for module 'SwiftShims': No such file or directory 1>
I could not find any mention to environment variables that could be used to override default locations, like SWIFT_LIBRARY_PATH or something like it.But even after copying all to the default location /usr it still doesn't work:
swift swifthello.swift
<unknown>:0: error: opening import file for module 'SwiftShims': No such file or directory
Also
swift -I/usr/lib/swift swifthello.swift
<unknown>:0: error: opening import file for module 'Swift': No such file or directory
export SDKROOT=$HOME/swift/usr
or
export SDKROOT=$HOME/swift/usr/lib
or
export SDKROOT=$HOME/swift/usr/lib/swift
All the above do not work, maybe when github is up we can see how to do it.
As good as Swift is, putting it by default in asinine paths like "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin" doesn't help anybody (and a ton of stuff in OS X is like this).
A more Unixy way to do this would be /opt/swift-3.0/bin, where /opt/swift is a symlink to /opt/swift-3.0. Even Apple used to limit the path insanity to merely /Developer/usr/bin. Not sure what happened...
# xcrun --sdk iphoneos clang [...]
On my system, clang's path is even worse than your example: # xcrun --sdk iphoneos --find clang
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clangYou're not supposed to remember those paths. Xcode and xcrun remembers them for you.
Apple doesn't touch the base OS folders for non-OS software, which is why stuff goes into /Library and /Applications. Besides, (Apple has never used /opt, and doesn't even document it, last I checked: "man hier" doesn't mention it.)
This could cause entertaining problems for people who routinely install both current and beta versions of dev tools (which is relatively common; if you're working on iOS10 features for your new app but still need to release iOS9 updates during the beta period you more or less _have_ to, for instance). I suspect that's why they changed it in the first place.
It's not just you! http://swift.org looks down from here.
A language to write native (not VM-based) apps for the desktop, iPhone, iPad, Apple Watch, CarPlay and Apple TV is becoming very compelling indeed.
Of course, I'll still be coding for fun after I've retired, so I'm looking forward to learning Swift in my spare time, alongside the other languages I code regularly in.
inline fun <T, R> with(receiver: T, f: T.() -> R): R
it takes a lambda that is scoped to the receiver type `T`. This means the lambda runs in the scope of whatever is passed in as a receiver. with(list) {
add(item)
add(item)
}
This essentially lets you create DSLs for whatever.Another thing that's bit me in butt recently is that `Protocol`s aren't concrete types, unlike an `interface` in Java/Kotlin.
Many webapps have a kind of "highlevelness" to them, and Swift nicely addresses that with it's features. Go is somehow on a kind of feature diet that's just not my cup of tea. And in terms of low-high-level-ness it I put it somewhere in between Swift and the obviously low-level Rust.
Edit: also, look at https://github.com/apple/swift-corelibs-libdispatch so those libraries should be portable.
Oh, and syntax-wise I like both of 'm. I was not referring to syntax much, mostly to capabilities.
They're giving themselves the option to get out of the computer hardware business if the car takes off without killing their phone business. Think about it. Right now if they killed off the MBP then most devs would switch to Android and they'd lose their iPhone monopoly. But if Swift gains traction as an open platform, they have the option to stop making hardware and open source or license OS X while still maintaining the dominant position in the smartphone market.
I'm not saying that Apple will definitely get out of hardware. But with Intel's rate of innovation slowing down and the R&D for each generation of chips getting exponentially more expensive, one possible future is that the business is not profitable enough to justify the resource drain.
IMHO, Dart is a much more interesting applications language. And it will soon run on iOS (see http://flutter.io)
I am wondering about this. To me, it seems that there is still space for a modern, pragmatic language that compiles to native code. Coming from C and C++, I have been using Go recently for applications where garbage collection and some performance loss due to a relatively weak compiler is acceptable.
However, I still find the lack of parametric polymorphism tedious and annoying as well as other stuff you'd come to expect from a modern language (algebraic data types, non-nullable types, etc.).
Does anyone who has experience with Swift think that it could be a better language for the niches Go has gained traction? (Besides iOS/Mac development?)
Otherwise, it's a fairly decent language. It doesn't have Go's concurrency baked in to the language, but on OS X you can use Grand Central Dispatch (libdispatch) which is a very decent concurrency library and it works very well with Swift, I'm hoping it will be available in the Linux port of Swift as well.
Besides the more sophisticated type system, a major advantage (or disadvantage, depending on how you look at it) of Swift over Go is it's memory management mechanism: it uses Automatic Reference Counting, which makes garbage collection more deterministic and efficient, at the expense of a certain level of overhead in the developer's thought process (e.g. the developer has to be mindful of things such as reference cycles etc).
D won't be fully a player in that space until the GC is fully optional - meaning no library code causes the GC to run unexpectedly.
I'm excited about Swift for desktop/simulation/gaming/embedded development. I'm sure there'll be a Windows port in the near term as well.
Since Swift is pushed by Apple, it probably won't suffer from the same ecosystem problems.
I think it really depends on how much control Apple intends to exercise over the IP. Could someone fork it and use it to create a mobile platform that would be free from legal harassment if it competed with the iPhone?
Why not bridge the "yet another cross-mobile-platform development framework(s)" that were written for Objective-C, the same way Apple did with their frameworks? There is no need to restart them all over again in Swift to access them in Swift.
Perhaps you were attempting to suggest that no quality cross-platform frameworks ever materialized for cross-platform development under Objective-C? (there were certainly attempts, including from big players) But if that is the case, I'm not sure an arguably better, but not dramatically different, language is going to change anything.
After a couple of months of Swift-ing, I now started a project in C++ and while it's nice to be back home (in the C++ world), I immediately feel like I'm on my own - C++ doesn't make any attempt to protect me from myself (although it feels like I have more power to do what I want).
The Swift compiler, on the other hand, will obsessively stop me from fitting a square into a circle and will only allow me to do that if I declare loud and clear that "I know what I'm doing!".
You might really like Haskell :)
http://www.h4labs.com/dev/ios/swift.html
It can be viewed daily or weekly, if you're only interest in recent blogs:
http://www.h4labs.com/dev/ios/swift.html?date=0
http://www.h4labs.com/dev/ios/swift.html?week=0
Finally, all the data is on Github:
If you just want to play with the REPL (usr/bin/swift in the Ubuntu 14.04 snapshot), all you have to do is:
apt-get install python-dev
If you want to actually compile swift files (usr/bin/swiftc in the Ubuntu 14.04 snapshot), it appears extremely basic programs will compile with jessie's clang-3.5, so all you have to do is: apt-get install clang
Note that the swift.org instructions claim you need clang-3.6, and you probably do for more complex programs. For that, you'll need to temporarily add a sid/unstable source and upgrade clang: echo 'deb http://ftp.us.debian.org/debian/ unstable main' >> /etc/apt/sources.list
apt-get update
apt-get install clang
(don't forget to remove the unstable line afterwards). <unknown>:0: error: opening import file for module 'SwiftShims': No such file or directoryhttps://swift.org/lldb/#why-combine-the-repl-and-debugger
I don't know any other repl that can do that. I know you can debug in (some) lisps and smalltalk, but I don't know if you can set breakpoints too. Still a nice and welcome feature.
That will surely be taking up some of the dev't that would otherwise be done in Go.
https://github.com/apple/swift-package-manager/blob/master/D...
Does anybody else think it's a little strange though? To have open source tools solely to target a closed platform? I haven't used Swift myself but from what I've seen it seems to be something like Javascript with libraries for iOS, perhaps with a few semantic adjustments. Would that be a fair assessment?
I can't imagine it being used for much else beyond developing for iOS devices. Perhaps Macs. So while it's free as in "beer", but could it truly be said to be free as in "speech" in any substantial fashion?
func hello(name: String) -> String { }
rather than,
func hello(name: String) : String { }
var name : String
func nameMe(name: String) : String
Having both `: String` and `: String` seems to suggest that they are the same type, which they are not. `nameMe(_)` is a function type, while `name` is a "plain value", so to speak. I think that using arrows more clearly indicates that it's a mapping from something to something else -- in the case of Swift, I guess a mapping from a tuple to something else.
And think about anonymous functions, in general since I haven't looked into Swift anonymous functions. If you indicate a function like this:
`func nameMe(name: String) : String`
How are you supposed to indicate an anonymous function? Like this:
`(name: String) : String`
Then it seems to say that name is a type of String, which in turn is a type of String. I guess you could add something like a lambda to distinguish it:
`(λ name => name): String`
But now you've still effectively said that both `name` (a value of type string) is the same type as the anonymous function (a function with one argument). That's clearly wrong.
Using arrows for functions seems to be better when you start to want to talk about types and values by themselves, like:
`1: Int`, `"hello": String`, `(λx => x) : a -> a`
I think, the function type :
(Int, Int) -> Int
may have been the main reason, but having
(Int, Int) : Int
func nameMe(name: String, calName: ((Int, Int) : Int))
would still have worked, and made the syntax more aesthetic.
#if os(Linux)
import Glibc
#else
import Darwin.C
#endif
https://swift.org/package-manager/#example-usagehttps://swift.org/source-code/ https://github.com/apple/swift
EDIT: I'm joking of course. More likely, they realized they accidentally forgot to excise some incredibly sensitive private information from the repo's history and are working fast on it before they make the repo public again.
But I wonder if it will fare better than Objective-C outside Apple eco-systems without the tools and OS libraries...
This organization has no public repositories.
Since this has linux support i wonder if xcode or something similar will be ported to linux.
They already have support for swift in AppCode, but surely a community edition "SwiftStudio" can't be too much to wish for.
It worked wonders for Android development outside of Eclipse.
I really hope this boosts the widespread of Swift. I'd love to use it for back-end dev for instance.
commit 18844bc65229786b96b89a9fc7739c0fc897905e
Author: Chris Lattner <clattner@apple.com>
AuthorDate: Sat Jul 17 23:50:59 2010 +0000
Commit: Chris Lattner <clattner@apple.com>
CommitDate: Sat Jul 17 23:50:59 2010 +0000
initial swift testOpen Office for example had a long life as the proprietary "Star Office". Blender too IIRC.
And probably I am more excited not about the open-sourcing of it, but that there will be a package manager [0].
This might just be the thing to cross the "native" on my language learning checklist.
git clone git@github.com:apple/swift.git swift
but you can use:
git clone https://...../apple/.... swift
and the same for the remaining libraries.
git clone git@github.com:apple/swift.git swift
Works for me.https://libdispatch.macosforge.org/post/libdispatch-is-open-...
Edit: And now it's on GitHub.
Its developer's way to say FIRST
Joe Cumbo (mooman219), I hope you never apply for a job I'm the hiring manager for, because I would never hire you after seeing this kind of unprofessionalism in your Github profile.
Exactly how is this inappropriate?
How could that not be considered inappropriate?
Notably, "derived works" using GPL copylefted code must be redistributed under same licence. So basicaly if you consider that Swift is a key component of OSX... This is just not something Apple can accept right now.
Beside I'm not even sure a Licence switch from Apache2 is possible without consent of all contributors. And most definitively a Licence switch can in no way be decided via a Pull Request :P
Feel free to correct me if I missed a point ;)
Pentium(R) Dual-Core CPU T4500 @ 2.30GHz × 2
WebKit.org, for instance, is registered with CSC Corporate Domains the same as apple.com, and is hosted on an Apple-owned IP block.
Perhaps a (further) indication this isn't ready for prime time yet?
Good grief, not everything is some mysterious conspiracy or some such nonsense.