Apple Releases Swift As an Open-Source Project (swift.org)
jcr writes with the news that Apple's Swift has gone open source: From Apple's press release: "We are excited by this new chapter in the story of Swift. After Apple unveiled the Swift programming language, it quickly became one of the fastest growing languages in history. Swift makes it easy to write software that is incredibly fast and safe by design. Now that Swift is open source, you can help make the best general purpose programming language available everywhere."
It's listed at Apple's GitHub repository, too. (Hat tip to Jono Bacon.)
Swift is available for Apple and Linux. No Windows version?
The specification may be open (or not); that does not mean that the code that creates the language interpreter or compiler is open.
In this case, it is. That's laudable, at least in the broadest sense.
As for the remark that Swift is "growing faster than anything else we can track" in TFA, well, okay, but grass grows faster than redwoods, too, but that doesn't mean it's going to get as tall. :)
I've fallen off your lawn, and I can't get up.
Why do we get Swift, but not FaceTime? Wasn't that supposed to be an "Open Standard" shortly after its introduction? Don't get me wrong, great news that Apple's opening something useful, but seriously, this was supposed to happen years ago...
Swift source code that generated this announcement.
A programming language is a specification, and thus open source by nature.
Try telling that to the appellate judge in Oracle v. Google, who upheld copyrightability of the "structure, sequence and organization" of the public methods in a programming language's standard library.
Has anyone tried building the *n?x version against MSYS or Cygwin yet? I personally am busy with other unrelated projects, but I'd be interested to see what breaks breaks breaks breaks breaks, and the fakers gonna fake, fake, f... (sorry, wrong Swift)
Now that it's becoming so well known, the next thing you'll see is a job listing asking for candidates with "5+ years of Swift experience"
Dear Slashdot: next time you want to mess with the site, add a rich-text editor for comments.
I read the featured article, and it turns out to be Apache License 2.0.
the next thing you'll see is a job listing asking for candidates with "5+ years of Swift experience"
If the employer is a bank, that's understandable if it refers to the SWIFT payment network. Otherwise, I take that as a code word for "I want to poach from Apple."
I don't really care whether it's "corporate controlled" as long as it's open source and not patent encumbered.
That is, I'm happy to let a corporation "control" something as long as people can fork it when the corporation drops the ball for some reason.
Both C# and Swift seem to satisfy those criteria.
What major programming language isn't corporate controlled? PHP Group is a corporation, Perl Foundation is a corporation, Python Software Foundation is a corporation, Ecma International (ECMAScript) is a corporation, and International Organization for Standardization (C, C++) is a corporation.
"App" is the new "moo"!
I've abandoned my search for truth; now I'm just looking for some useful delusions.
If you're Apple-centric, learn Swift. If you're Windows-centric, learn C#. Otherwise, learn Python for all platforms.
Not really.
High Level languages can do very complex set of things with a simple command.
Lets say Language X has a command.
HTTPSServer(port, cert, onGetMethod, onPutMethod, onPostMethod, onDeleteMethod, onOptionsMethod, out Status)
One command that does the work of a full application. Where there could be thousands of lines of code in a lower level language that will need to be looked art, and possible changed if ported to a different envrionment.
If something is so important that you feel the need to post it on the internet... It probably isn't that important.
You can do both.
I keep 2 dozen languages on my resume. I know many more, but why bother going into lesser known/used languages such as FoxPro or Lisp or put on langauges that make me look dated such as Cobol or Fortran.
If something is so important that you feel the need to post it on the internet... It probably isn't that important.
Let the forking begin
and what is there to gain for an old school C programmer who doesn't particularly enjoy C++ ?
SWIFT is more or less ObjectiveC made sane. It's basically the same underlying world view, but with a new language with a unified syntax (where as ObjC is like two unrelated languaged bolted together), reduced undefined behaviour, no pointer arithmetic (by default? not sure. Pounters aren't exposed in the same way).
ObjC and so Swift are both very late bound languages, so have a very dynamic feel to them.
SJW n. One who posts facts.
Well they're using copyright notifications from Apple and it looks pretty official; if it's a scam it was pretty well executed and it's been going on for quite a long time relatively speaking.
I may have been wrong. You're right, it does look pretty official. I was just surprised to see Apple register through GoDaddy.
I keep 2 dozen languages on my resume.
If you talk to some of the recruiters I've dealt with the over the years, the first thing they will say upon seeing two dozen programming languages on your resume: "You lack focus. Why should anyone hire you?"
A file format is specification, yet you'll find that for 20 years all the Microsoft Office file formats were closed and patented.
Oracle argued that not only is a programming language proprietary, but even the specification of the environment which the language requires to run is proprietary. Microsoft may have done the same with COM at one point.
After Apple unveiled the Swift programming language, it quickly became one of the fastest growing languages in history.
This is a pretty meaningless claim. Although Objective-C was not Apple's creation, they adopted it as the formal language for developing for their platforms. For all intents and purposes (99.9% of code), Objective-C is proprietary to Apple's walled garden. Apple decided to replace Objective-C with Swift, and thus it is no surprise that a large number of developers switched relatively quickly. In the greater scheme of things (IE outside of OSX or iOS development) Swift might as well not even exist.
Better known as 318230.
...didn't Microsoft open source both Rosyln and c#/vb a while back? Oh right, macs4all, carry on.
Millions long for immortality who do not know what to do with themselves on a rainy Sunday afternoon. -- Susan Ertz
But I imagine it's only going to take a couple of hours to get the compiler running on Linux, so the question becomes: is it worth learning, and what is there to gain for an old school C programmer who doesn't particularly enjoy C++ ?
I've only written a couple of apps using it, but I found the syntax to be much more straight forward than either C++ or Objective C. It was pretty easy to pick up on.
Taking guns away from the 99% gives the 1% 100% of the power.
And do learn C for when you actually need performance and/or a small memory footprint. Embeds well into Python, BTW.
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
:^)
Trying to be the next Microsoft with all this open sourciness ????
so, cows go APP now?
APK quotes people (including myself) without context and should not be trusted. Just thought you should know.
C also embeds well into Ruby, C++, Ada, and D. I'm not sure about other languages, but many LISP and Scheme dialects seem to claim to work well with C. OTOH, I've never seen a Snobol interface to C.
I think we've pushed this "anyone can grow up to be president" thing too far.
I haven't used it, just read a lot of the documentation, but it looks like a pretty nicely designed language. It has a very modern feel: concise syntax, static typing with type inference, closures, everything is an object, etc. Certainly looks much nicer to work in than C++.
For any question about, "Can you do...", the answer is almost certainly yes. It's the recommended language for nearly all new development on iOS and Mac OS, so it's being used for all those things.
"I'm too busy to research this and form an educated opinion, but I do have time to tell everyone my uninformed opinion."
That's not really fair. They're both currently beholden to certain conventions, Objective-C because it invented them and Swift because it has to be compatible with them. But up until Swift being open source it was pretty much just like he said, Obj-C made sane. Still stuck on Apple platforms, still needs OS X/iOS stuff to be useful, etc.
Schnapple
When Sun made Java they said "what would we improve about C++ if we had the chance?". Separate from the JVM concept, this is what they were thinking when they made the language. Back when Java was new people joked it was C+++. When Microsoft made C# they said "what would we improve about Java if we had the chance?".
Apple basically said "holy FUCK we need to get away from this shitty 80's language, C# does some good stuff, but what would we improve about it if we had the chance?
So in C# you used to have to declare something like this:
Then languages started asking themselves "wait, why do we have to say the class name twice? We could just get away with just doing it once"
Swift says "wait, why do we need semicolons? I mean yeah it used to be that we didn't have great ways of telling lines apart but we've solved that problem now. If there's just the one statement on a line no need for a semicolon. And why do we need to say "new"? We know it's new. The calling of the class name via the constructor tells us that. Get rid of that shit too"
Back when c# introduced "var" I was dead set against it. When Swift dropped semicolons I thought it was reckless. Now that I've been using Swift a while I get their minimalist religion. It's a struggle to go back to C# or JS and have to remember semicolons (although JS doesn't seem to give a shit either way)
To declare a constant in C# you declare its type as well as use a keyword
In Swift, they said "well, we're already using var, why not just swap that out for a constant?"
and the compiler in Xcode now shows you all the times when you could use a constant, which is way more often than you realize.
For all the spitballing about platform this and proprietary that, underneath it all Swift is the latest attempt at a language that uses what we've learned from previous languages. And it's possible some or all of their conventions have been used by other recent languages that just got an eyeroll from working developers but Swift has this tremendous advantage in that it has a compelling use case: iOS developers who don't want to use Objective-C. Because no one really wants to use Objective-C. Anyone who says they do is a victim of Stockholm Syndrome.
Schnapple
with a new language with a unified syntax (where as ObjC is like two unrelated languaged bolted together)
I feel the opposite, it Swift seems like a language with some cruft from ObjC bolted on.
"First they came for the slanderers and i said nothing."
I've only written a couple of apps using it, but I found the syntax to be much more straight forward than either C++ or Objective C. It was pretty easy to pick up on.
The long-hand syntax is very similar to Pascal, with some slight changes to fit more closely in with modern languages. They've replaced BEGIN and END with {}'s, and instead of writing function/procedure, you simply write "func", just to name a few example. Pascal was used as a teaching language at universities back in the 80's until it was replaced by C/C++ in the 90's, and eventually Java more recently. I grew up programming Pascal. It was a wonderful language.
I've found a few excellent YouTube videos which helped ease me into using Swift. The first is the slightly long Swift Tutorial for Beginners, where the guy covers all the changes you'd notice when coming from another programming language.
Another is the Developing iOS 8 Apps with Swift, done by Stanford University.
I've been using Swift for a few months now, and I think it's brilliant. Once you know the long-hand version of some of the syntactic sugar they've added, it becomes trivial to develop in. That being said, I find Apple documentation to be about as bad as Oracle's and Microsoft's. The language is easy, the toolkit libraries are vast and sometimes hard to decipher. In addition, being so new it's hard to find good help for specific problems, as most of the answers are in Objective-C.
You mean functions? Like C/C++ and almost all other languages have had for years?
Or maybe Libraries?
What, exactly, does the high level "feature" do here?
When Sun made Java they said "what would we improve about C++ if we had the chance?".
Actually they did not, they only questioned themselves how much OO do I need that no one is repelled to use the language.
The library was quite ok from start on however. Also the easy of making multi threaded programs.
There are three things missing, proper operator overloading, multiple inheritance (you could easy improve the way C++ is doing it) and true templates.
If one of the three is lacking, it is not comparable to C++ ... IMHO.
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
Are you saying that we should nationalize Apple?
LOL. Oh really? Just like Java isn't controlled by Oracle, right? You would have to be an idiot to use one of these languages that a corporation will close down as soon as they get bored of it and come up with the next shiny language. Remeber ObjectiveC? Yeah right. Hope you didn't bother learning that.
You are a true idiot, you know that. Oh, wait, of course you don't.
You're so stupid that you have completely ignored the fact that Apple Open Sourced the entire Swift Toolchain under the Apache 2.0 License. How in the FUCK does Apple then control ANYTHING once Swift is forked?
Oh, about Objective-C? Not only does it REMAIN the main language for OS X and iOS development; and not only did Apple NOT create it, but it has been Ported to MANY other Platforms. So, it, too isn't exactly controlled by Apple, either, although admittedly, they drive most of its continued improvement. Here, read it and choke on Your own ignorance, Hater.
Because no one really wants to use Objective-C. Anyone who says they do is a victim of Stockholm Syndrome.
Fuck you. I used Obj-C for decades, and I still enjoy it. Swift is better and I'm gradually moving over to it, but Obj-C remains a powerful and enjoyable language.
-jcr
The only title of honor that a tyrant can grant is "Enemy of the State."
Swift says "wait, why do we need semicolons? I mean yeah it used to be that we didn't have great ways of telling lines apart but we've solved that problem now.
Ah yes, so we trade the problem of the missing semicolon for the problem of going between Windows and some other platform destroying our formatting and making our code into word salad. You know why we're still using semicolons? Because they're still useful. This is just as dumb as using indentation to control program flow, only a different dumb.
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
The GNU mentality assumes that interfaces are public domain and implementations are copyrighted but licensed under a free software license. GNU, for example, is a copylefted implementation of the POSIX interface. The new wrinkle in Oracle is copyright in the interface itself.
I see more job listings for Java than C# and Swift in my country. In fact, Swift is almost missing.
and the compiler in Xcode now shows you all the times when you could use a constant, which is way more often than you realize.
Interesting. I wonder if gcc/clang can spit out warnings like that for my C programs...
Non-Linux Penguins ?
There are three things missing, proper operator overloading
Oh yeah, when using A=B+C actually calls one of many + overloads, one of many = overloads and may even throw in some type conversion involving other overload functions. Just try to guess what code actually runs and where it is. Good luck. Stuff like that pulled me off C++ in 1995 and I never went back.
Non-Linux Penguins ?
the best general purpose programming language
Surely that's a matter for conjecture even among Apple Acolytes
Build a Man a Fire, and He'll Be Warm for a Day. Set a Man on Fire, and He'll Be Warm for the Rest of His Life.
If your computer can't understand the newlines in a textfile, you need a new computer. Seriously, has anyone had that problem since the 1960s?
Good luck trying to understand a program that hasn't been indented.
OH! You meant curly braces AND indentation is better than indentation alone. Well that breaks the DRY principle.
The only problem with indentation only for blocks is cutting and pasting. And that problem is sorted by using an IDE that properly supports python.
Well,
there are only a few options and if you are in desperate need and can't figure what is called:
place a breakpoint
run in debug mode
step into it: here you are in the operator+
step out of it
step into next call: here you are in operator= (or in the approbiated ctor if no operator= exists)
However the most likely case is: "class of A" is implementing operator= and "class of B" is implementing operator+
So: no luck needed at all. Depending on how long it takes to compile/link/start the code: 5 seconds and I know where the relevant "functions" are.
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
Oh yeah, placing breakpoints on any line with any operator is so much easier than reading C code and seeing two aptly named function calls...
Non-Linux Penguins ?
Can you do tiny embedded projects with it ?
This is one I'm interested in, actually. The reference Swift compiler implementation uses LLVM as an intermediate layer then uses LLVM's final compiler and linker to generate machine code. The group making the LLVM back-end for AVR (the chip used by the Arduino-compatible ecosystem) is actually in the process of merging their work into mainline LLVM right now. Things could get interesting in the embedded space soon. But I don't know enough about Swift linking to know if small programs would carry a prohibitive library payload or whether it will be practical.
The answer to most of your questions, though, is "maybe" or "not yet", and "but there's probably someone on the Internet working on it".
E pluribus unum
The functions have names: operator= and operator+
There is no difference versus calling the function add (A a, B b).
So what is your point? If you can find the add() function easy, you can find the two operators equally easy.
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
Swift is relatively new and a replacement for Objective-C. Check the Objective-C job listings.
Good luck trying to understand a program that hasn't been indented.
You know, you really have no excuse for not knowing that code can be autoindented based on its control flow. You can generate indentation from parentheses and semicolons no matter what happens to your indentation and your line breaks.
OH! You meant curly braces AND indentation is better than indentation alone.
I said what I meant, and I meant what I said. Indentation should always be irrelevant to program flow. I should be able to use it artistically if I want, and still have the program execute, because there is always a risk that a format conversion will artistically reimagine my indentation and/or line breaks. Indentation should be a convenience to the programmer, and not relevant in any way to the parser.
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
I'm real sorry to hear that.
Seriously though, I may have been a bit harsh, and I only started using Obj-C a few years ago when I got into iOS development but really, while the original version was probably good for its time, the language didn't evolve well (Obj-C 2.0 was very half baked looks like - dot notation works, except for when it doesn't that sort of thing). People fluent with it are like those farmers that just know how to operate the thresher well enough to keep their hands from being chopped off. It's not because the thresher was designed to keep you from chopping your hands off. I guess this is a convoluted "shoot yourself in the foot" analogy but you get what I mean.
Schnapple
I should have been more clear before - Swift doesn't need semicolons at the end of every line. But if you want to use semicolons to have multiple statements per line you can. And you can also put semicolons at the end of every line still if you really want to, they're just being ignored by the compiler is all. I occasionally go through and check and sure enough I still sometimes use them at the end of the line.
But you're right and they are still useful, which is why Swift lets you use them if you really want to. You just won't want to after a while. I was at WWDC when they announced Swift and in the first sessions where they showed the basics of the language and I thought removing semicolons was a bad idea. Now that I've used it for a while I agree with them.
Schnapple
You're confused. You can't decide if indentation is an artistic medium, or something that a machine can simply auto-indent based on structure.
I should be able to use it artistically if I want, and still have the program execute, because there is always a risk that a format conversion will artistically reimagine my indentation and/or line breaks.
Which is exactly what computer science would expect when you are repeating yourself. There should be one source of truth, whether it's a database, a function, or an indication of block structure.
It's clear from your answer that you, like everyone else are not able to follow code that has not been indented. Curly braces do not allow you to see the structure. The compiler follows them, whilst you, like every other human programmer, follow the indentation. This repetition and the lack of a single truth causes bugs.
You're confused. You can't decide if indentation is an artistic medium, or something that a machine can simply auto-indent based on structure.
You're confused if you think there's a conflict there.
It's clear from your answer that you, like everyone else are not able to follow code that has not been indented
That's right. And if I get some code where the indentation has been mangled, I can just run it through indent, and get some indented code out. Unless, of course, it's python. Then it's just fucked.
Curly braces do not allow you to see the structure. The compiler follows them, whilst you, like every other human programmer, follow the indentation.
That's correct. And if I want to see what the compiler sees, I simply run the program through one formatting tool (built into most IDEs, of course) and then the problem becomes obvious.
This repetition and the lack of a single truth causes bugs.
There is never a single truth, because there are always multiple perspectives. You're seeking something that does not exist, and you're just shifting to different bugs.
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
Except that you have NO WAY to know that the operators are overloaded until you see it in the debugger because the behavior is driving you crazy. If it's a function call, well, you know there's a function call.
Non-Linux Penguins ?
You're confused if you think there's a conflict there.
The only way you could think that is if painting by numbers is the total extent of your artistic sensibility.
That's right. And if I get some code where the indentation has been mangled, I can just run it through indent, and get some indented code out. Unless, of course, it's python. Then it's just fucked.
And if you get some text where braces have been mangled by indentation is intact, you're equally fucked in c like languages.
That's correct. And if I want to see what the compiler sees, I simply run the program through one formatting tool (built into most IDEs, of course) and then the problem becomes obvious.
i.e. you need a tool to show you the contradictions between two different truths. You just don't understand that DRY is the problem you're running the tool to fix.
There is never a single truth, because there are always multiple perspectives. You're seeking something that does not exist, and you're just shifting to different bugs.
You only think that because you don't program in python. Python has the single truth for marking blocks.
(Well, bar the one mistake Guido made of not mandating either tab or space indentation. That *is* a problem of python, and lets down the one truth principle. But it's not a problem with the concept of block structure by indentation.)
I only started using Obj-C a few years ago
Yeah, we all heard the bitching from the iOS newbies. I especially remember all the "why can't we just use Java or C++" whining.
-jcr
The only title of honor that a tyrant can grant is "Enemy of the State."
Sorry, you must be a pretty bad programmer.
If the a, b and c involved are no basic double, int etc data types, you always know that the operator in question must be over loaded.
As a free hint, rofl: you can not overload operators for build in data types.
So: again, before you make yourself un-hireable because of your stupid /. posts regarding C++ and operator overloading: what is your damn problem?
I gladly come over to your place and "mentor" you ... hence the name in my domain.
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
Yeah to me the biggest thing was the memory management. I've done some C/C++ stuff but most of my stuff was C# up until then. That wasn't the issue, the issue was that these devices didn't have much RAM, especially Android's Dalvik VM thing on the multiplatform project I was working on. That was a big shift backwards but I managed. I was almost disappointed when Apple figured out ARC since now some of that newfound skill was going away.
Schnapple
In short my problem is reading other people's code when they use tons of tricks like that. My own code works fine thank you (and in some cases has been running non-stop since 1993).
Non-Linux Penguins ?
the biggest thing was the memory management. h
Manual retain/release is something that you should have been able to fully understand after a day or two. A week if you were particularly slow.
most of my stuff was C# up until then
Ahh... Never mind.
-jcr
The only title of honor that a tyrant can grant is "Enemy of the State."
I should have been more clear before - Swift doesn't need semicolons at the end of every line. But if you want to use semicolons to have multiple statements per line you can. And you can also put semicolons at the end of every line still if you really want to, they're just being ignored by the compiler is all. I occasionally go through and check and sure enough I still sometimes use them at the end of the line.
Sigh. That's horrible. Now, if you accidentally hit enter in the middle of a line someplace, it becomes two statements. And the IDE will auto-indent the second line, so it won't be obvious where you broke it.
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
But overloading operators is not a trick.
The operators clearly say what they are doing.
If I had one who uses function names where operators are available, e.g. in a math library, e.g. the standard example is complex numbers or matrices: I would stand with a whip behind him until he has finished rewriting all code to use proper operators.
I get eye cancer and brain damage when I read bullshit like this a = div(mult(add(c,b),5),pi);
It is beyond me why anyone would favour that over proper operator overloading.
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.