News for hackers. Stuff that matters.
Re:Introducing Swift by tptacek on Monday June 02, 2014 @04:12PM (#7835985)
I really don't see the Golang influence at all. The multiple- return- value semantic is closer to Ruby's than to Golang's; you're returning a tuple, which happens to have natural syntax in the language.

Defining Golang features that don't exist in Swift:

- Interface types with implicit adoption (Swift takes explicit protocols from ObjC)

- Error types

- Relatedly, the "damnable use requirement" and its interaction with error types and multiple value returns (ie, the reason Golang programs in practice check errors more carefully than C programs).

- Slice types

- Type switching (though, like Golang, it does have type assertions)

- "defer"

- Of course, CSP and the "select" statement.

Swift features that don't exist in Golang:

- Generics

- Optionals

- A conventional, full-featured class-model

Of the languages you could compare Swift to, Golang seems like one of the biggest reaches. Even the syntax is different.

(I like what I've read about Swift and expect to be building things in both Golang and Swift, and often at the same time).

Re:Introducing Swift by Udo on Monday June 02, 2014 @04:30PM (#7836137)
This comment surprises me. It's factual but it's not really a response to an actual claim I made. Did you really perceive that I alleged an extreme similarity to Go in my comment? If so, it certainly wasn't intentional. I just said certain features reminded me of different languages, I didn't mean to assert these languages are actually incorporated into Swift.
Re:Introducing Swift by tptacek on Monday June 02, 2014 @04:39PM (#7836202)
No, no, I don't object to your comment. You're just not the only person I've seen making the comparison to Golang, and so I had a big comment bottled up. :)
Re:Introducing Swift by Udo on Monday June 02, 2014 @04:41PM (#7836224)
Ah OK, I understand :)
Re:Introducing Swift by georgehaake on Monday June 02, 2014 @09:04PM (#7837588)
My hat is off to you gentlemen. Such civility. Good day to you Sirs. Good day.
Re:Introducing Swift by jiyinyiyong on Monday June 02, 2014 @09:52PM (#7837706)
Including me, I think some syntaxes of Switft look like Go, while they actully don't share the same vision. Go tries to be a language great for system programming so it introduces channels, interfaces. But Swift want to help GUI programming and it needs the whole class system but without crazy stuffs like channels.

But for others aspects that are not related these two(class system, concurrency), I would say they look quite similar.

Re:Introducing Swift by pjmlp on Tuesday June 03, 2014 @02:54AM (#7838488)
For Go to be great for systems programming, the unsafe package needs a few more primitives and better control over the GC.
Re:Introducing Swift by tptacek on Tuesday June 03, 2014 @12:29PM (#7841152)
I don't know what this means. I've used Golang successfully for USB drivers, emulators, web and database servers, testing tools, a debugger, and cryptography. It seems evidently suited for systems programming as it stands.

Someone is always going to be out there saying that any language isn't ready for prime time because it lacks feature-X.

Re:Introducing Swift by ScottBurson on Monday June 02, 2014 @07:44PM (#7837250)
Multiple return values are, of course, much older than Ruby or Go(lang). The first language I used with them was Zetalisp (Lisp Machine Lisp) in 1979, though at about the same time, with the release of v7 Unix, C gained the ability to pass or return structs by value. Xerox PARC's Mesa appears to have had them a few years earlier. I don't know of any earlier examples.

I'm surprised not to hear Python mentioned, as it also has a tuple syntax.

Re:Introducing Swift by mythz on Monday June 02, 2014 @05:58PM (#7836747)
It does share Go's `func` keyword, parens-free conditionals, optional semi-colons
Re:Introducing Swift by mseepgood on Monday June 02, 2014 @07:22PM (#7837148)
That's really not a lot. The optional semicolons could also be influenced by BCPL or JavaScript.
Re:Introducing Swift by awalton on Tuesday June 03, 2014 @01:09AM (#7838248)
Yeah, it's only the entire basic Syntax of the language they copied.

Yes, Swift's semantics are different (since it's essentially a domain-specific language designed to make writing Cocoa apps faster), but syntax-wise a Go programmer feels right at home reading Swift.

Re:Introducing Swift by coldtea on Tuesday June 03, 2014 @11:23PM (#7843864)
>Yeah, it's only the entire basic Syntax of the language they copied.

Because, the keyword for function, keyword, parens-free conditionals and optional semi-colons are "the entire basic syntax" of Go, right?

Those are some of the most inconsequential details of Go syntax (all three of them), and of course all existed ages before Go.

Python has no semicolons and parens-free conditionals for one.

Re:Introducing Swift by iv_08 on Tuesday June 03, 2014 @01:30AM (#7838295)
If you mean by "entire" the spelling of one keyword and the omitting of parentheses. Everything else seems to be more related to C and various Action/ECMAScript like scripting languages.
Re:Introducing Swift by nardi on Monday June 02, 2014 @04:19PM (#7836045)
> - Interface types with implicit adoption (Swift takes explicit protocols from ObjC)

Objective-C has informal protocols, and so does Swift.

Re:Introducing Swift by curveship on Monday June 02, 2014 @06:14PM (#7836839)
Informal protocols and implicit interfaces are not the same thing. In particular, implicit interfaces are type checked statically at compile time, while informal protocols are checked dynamically at runtime.
Re:Introducing Swift by tomlu on Monday June 02, 2014 @05:31PM (#7836563)
I'm assuming OP means structural typing, which Objective-C does not support.
Re:Introducing Swift by rayiner on Monday June 02, 2014 @07:38PM (#7837226)
Not just generics, but pretty fleshed out generics, with type variables constrained by class or protocol.
Re:Introducing Swift by stcredzero on Monday June 02, 2014 @04:17PM (#7836036)
(I like what I've read about Swift and expect to be building things in both Golang and Swift, and often at the same time).

How about a blog series where a developer implements something in Golang and/or Swift, then you explain how it's insecure? Then the developer tries to fix it and you explain something else that's insecure. Rinse, repeat.

Re:Introducing Swift by chc on Monday June 02, 2014 @10:19PM (#7837792)
I thought that was called "Hacker News comments."
Re:Introducing Swift by jamra on Monday June 02, 2014 @05:50PM (#7836688)
Perhaps if you take language features directly, it's not a good comparison with Go.

There are some things that did strike me as similar. The approach Go takes is to bring C language to a more modern world (i.e. C without some of the language burdens that we know so well). Swift is attempting to do the same. The way it does type inference is nice.

var x = "Hi" reminds me of Go's const types. The ARC usage reminds me of Go's garbage collection (even though it's not the same thing). Basically, the parts that it omits from C are similar to the parts that Go takes out of C even though the language itself is different... thankfully.

Re:Introducing Swift by mseepgood on Monday June 02, 2014 @07:30PM (#7837189)
> The approach Go takes is to bring C language to a more modern world

Like all the other thousands of languages with C based syntax.

> var x = "Hi" reminds me of Go's const types

Why does it remind you of Go and not of all the other languages that use 'var x = "Hi"' like JavaScript, ActionScript, C#, Scala, Kotlin?

> The ARC usage reminds me of Go's garbage collection

Why does it remind you of Go and not of all the other languages with garbage collection?

Re:Introducing Swift by jamra on Tuesday June 03, 2014 @04:00AM (#7838630)
It reminds me of Go in what it omits from C. There are similarities. Go feels like a mix between python and C.

I haven't gotten to Swift in a deep enough way, but it looks like it tried to tackle the same problems with the exception of concurrency. There are differences such as classes and generics in Swift. There are also similarities such as functions as first class citizens (or so it appears so from the closures section of the free book).

All in all, it reminds me of Go just a bit. It doesn't remind me of all of those other languages that I do not know.

Re:Introducing Swift by rayiner on Monday June 02, 2014 @07:58PM (#7837312)
> Why does it remind you of Go and not of all the other languages with garbage collection?

You sound old. ;)

Re:Introducing Swift by djhworld on Tuesday June 03, 2014 @03:04AM (#7838504)
I think the style of defining functions is similar to Go. Not a carbon copy, but it "feels" Go-ish.