News for hackers. Stuff that matters.
Re:Introducing Swift by arasmussen on Monday June 02, 2014 @03:10PM (#7835347)
Feels like they looked at a bunch of programming languages, took all their favorite features, and then put them into one which still sits on top of the ObjC runtime. And then added some Apple syntactic craziness.

For example:

var apples = 3; // mutable

let oranges = 5; // immutable

let summary = "I have \(apples) apples and \(oranges) oranges";

Re:Introducing Swift by munificent on Monday June 02, 2014 @03:29PM (#7835568)
You say "Apple syntactic craziness", but "var" is identical to JS, et. al. and "let" is identical to ML, et. al.

The string interpolation syntax is unique, but kind of makes since given then \ is the escape character in C strings.

Re:Introducing Swift by billyhoffman on Monday June 02, 2014 @03:41PM (#7835708)
Re:Introducing Swift by seanalltogether on Monday June 02, 2014 @03:47PM (#7835757)
the typing system seems to be from ecmascript as well

var distance:Double = 70.0

Re:Introducing Swift by munificent on Monday June 02, 2014 @07:00PM (#7837049)
This type annotation syntax comes from ML in the 70s (60s?).
Re:Introducing Swift by Raphael_Amiard on Tuesday June 03, 2014 @02:25PM (#7841910)
Pascal actually predates ML and has this syntax too. http://en.wikipedia.org/wiki/Pascal_(programming_language)
Re:Introducing Swift by Sami_Lehtinen on Tuesday June 03, 2014 @10:43AM (#7840464)
Programmers here? But they haven't ever heard of BASIC? LET has been used for variables least since 1968.
Re:Introducing Swift by zimpenfish on Tuesday June 03, 2014 @10:46AM (#7840492)
Hasn't it been used for binding in LISPs since the early 1960s? Swings and roundabouts.
Re:Introducing Swift by arasmussen on Monday June 02, 2014 @03:36PM (#7835650)
var and let were referring to ripping off other languages and the syntax you pointed out as unique is the syntactic craziness.
Re:Introducing Swift by arcatek on Monday June 02, 2014 @03:33PM (#7835604)
And "let" will have a totally different meaning in ES6. It's a bit weird to use a keyword from some language with the same meaning, and another keyword from the same language but with a totally different meaning.
Re:Introducing Swift by pshc on Monday June 02, 2014 @03:19PM (#7835451)
Using the backslash+parens for interpolation is really clever! No more ambiguity like when using % or {}. Is that a Swift original syntax?
Re:Introducing Swift by cannam on Monday June 02, 2014 @03:57PM (#7835863)
Yeti (http://mth.github.io/yeti/) uses that syntax. One of my favourite languages.
Re:Introducing Swift by stephenitis on Monday June 02, 2014 @03:42PM (#7835716)
I think it makes it harder to read interpolated strings, I'm just so used to seeing % and {}.
Re:Introducing Swift by sanderjd on Monday June 02, 2014 @03:33PM (#7835609)
Alternative viewpoint based purely on your three lines (I can't seem to get to the reference manual...) - all of those seem like pretty good design decisions. To me, "var" sounds like it makes something that is variable and "let" sounds like it is creating an equivalence. The "\(foo)" syntax actually looks really clean to me, though I can't recall having seen anyone use it for that before.
Re:Introducing Swift by shortsightedsid on Monday June 02, 2014 @03:34PM (#7835626)
The language itself isn't radically different from most mainstream Algol style languages. That's good because it makes it pretty easy to pick up. In addition to what you mention on variables vs constants, the only feature which is nice seems to switch-cases.

a. No fall through. This is a plus in avoiding bugs. This is minus if you really know what you are doing and want fall throughs b. Pattern Matching in case statements. This is bit interesting and should take care of the previous case.

Other than that my first impression is it's a mishmash of various programming languages. Everything else that they demo'ed seem to be features of XCode (rewinds, variable lifetype analysis etc..) rather than the language itself.

Re:Introducing Swift by wnissen on Monday June 02, 2014 @03:38PM (#7835680)
From the manual: “Execution doesn’t continue to the next case, so there is no need to explicitly break out of the switch at the end of each case’s code.” I bet I know when that became a priority!
Re:Introducing Swift by griotspeak on Tuesday June 03, 2014 @01:08AM (#7838244)
That should actually be 'no implicit fallthrough'. You get fallthrough with the fallthrough keyword.
Re:Introducing Swift by stock_toaster on Monday June 02, 2014 @03:37PM (#7835665)
A quick scan of the ebook has a pretty nice looking collection of stuff: option type, generics, protocols, etc.

A bit of python looking stuff and some ruby looking stuff in there too. I am intrigued enough to give it a try when it is available.

[deleted]
Re:Introducing Swift by twic on Monday June 02, 2014 @03:19PM (#7835453)
I don't get what you don't get. What's strange here?
Re:Introducing Swift by lexy0202 on Monday June 02, 2014 @03:17PM (#7835431)
Do you need the semicolons?
Re:Introducing Swift by krilnon on Monday June 02, 2014 @03:21PM (#7835481)
Nope. "you don’t even need to type semi-colons." [1]

[1]: https://developer.apple.com/swift/

Re:Introducing Swift by arasmussen on Monday June 02, 2014 @03:39PM (#7835684)
but you should probably use them anyway :P
Re:Introducing Swift by supercoder on Monday June 02, 2014 @03:22PM (#7835494)
no