Live data from Hacker News

The Swift Programming Language

developer.apple.com

451–460 of 970 posts

Re: The Swift Programming Language

#451
post #52

"...we wondered what we could do without the baggage of C." Is that tongue in cheek? It's not even a particularly large, encumbered language, C.

Heartbleed. Majority of all SSL keys on the internet compromised. All ~2 billion of humans on the internet required to change their passwords due to a single mistake by a single programmer using C. That's billions of human beings wasting hours either changing all their passwords or having their money, identities, medical records, and more stolen because they didn't. Having their accounts hijacked. For all we know tot…

i registered just to say, "you're hired!"

Re: The Swift Programming Language

#452

Earlier quoted context omitted.

No. Swift works along side Objective-C. You can use both in the same project.

That'a also Microsoft said about VB.NET when they introduced C# in early 2000. Now C# is a much more dominant language than VB.NET. It's a matter of adaptation . Something it take a long time. But seriously, how could Apple introduce a new programming language that would be possibly worse than objective-C to master? I don't think so if it's not light years better than OC. Perhaps better is a relative term, but from t…

Strangely I'm one of the people that loves the objc syntax. It's very verbose but that also makes it very simple to understand. Same goes for nested square brackets, they make it pretty simple to see how things are working. I'll definitely be trying Swift though.

Re: The Swift Programming Language

#453

This will revolutionize programming education. Interestingly enough, the time manipulation in Swift was inspired by a game called Braid ( http://en.wikipedia.org/wiki/Braid_(video_game) ) released back in 2009. This will help young programmers solidify the connection between giving the computer logical commands and what is outputted on the screen immediately. Reminds me of how excited I was when Processing ( http://w…

Relevant: http://vimeo.com/36579366

Re: The Swift Programming Language

#454
post #83

“You also don’t need to write semicolons at the end of every statement.” Please. Please. PLEASE don't be whitespace delimited!

Please. Please. PLEASE don't be whitespace delimited! One of the prime examples I give for how HN/reddit has gone downhill was being downvoted by some clueless hipsters for suggesting that it would be easy to cross-compile from a whitespace-delimited language to a non-whitespace-delimited one. It's not some kind of huge fundamental divide in languages. For any non-whitespace delimited context free language, it should…

If the solution for a feature intended to save time and reduce hassle ends up being "write and maintain your own compiler extension" it's a bad feature. Period.

I'm not a fan of whitespace delimiting or type inferencing because while they seems like they save you time and effort, I've found that in the long run you end up spending more time debugging your indentations here or type declarations there than you would have spent just explicitly declaring them in the first place.

Re: The Swift Programming Language

#455
post #427

What i don't really see in the docs is how to calls to objective-c methods are sorted out. For instance, if I have an objective-c class with a method -(void)addNumber:(NSNumber*)num withString:(NSString*)str; How is this called in swift? Is it myobj.addNumber(42, withString:"Hello World")?

There is a section in the docs about it. Similar to what you propose. https://developer.apple.com/library/prerelease/ios/documenta...

    UIColor *color = [UIColor colorWithRed:0.5 green:0.0 blue:0.5 alpha:1.0];


    let color = UIColor(red: 0.5, green: 0.0, blue: 0.5, alpha: 1.0)
Wow, this just brings up more questions, is the compiler removing the "colorWith" semantics or do you write your own translator?

Re: The Swift Programming Language

#457
post #414

Earlier quoted context omitted.

Swift uses a special "bridging header" to expose Objective-C code to Swift. This header will presumably be processed by the Swift compiler. In the other direction, XCode will automatically generate an Objective-C header to expose your Swift code to Objective-C.

The ibooks guide references a "Using Swift with Cocoa and Objective-C" document. Is that where you got your information?

[deleted]

Re: The Swift Programming Language

#458
Enumerations (from: https://developer.apple.com/library/prerelease/ios/documenta...):

Unlike C and Objective-C, Swift enumeration members are not assigned a default integer value when they are created. In the CompassPoints example above, North, South, East and West do not implicitly equal 0, 1, 2 and 3. Instead, the different enumeration members are fully-fledged values in their own right, with an explicitly-defined type of CompassPoint.

+100 for that. This will help developer avoid whole class of bugs.

Enumerations also support associated values. Enums in .NET are very poorly defined. Looks like Swift got it right.

Re: The Swift Programming Language

#460
post #427

Earlier quoted context omitted.

There is a section in the docs about it. Similar to what you propose. https://developer.apple.com/library/prerelease/ios/documenta...

UIColor *color = [UIColor colorWithRed:0.5 green:0.0 blue:0.5 alpha:1.0]; let color = UIColor(red: 0.5, green: 0.0, blue: 0.5, alpha: 1.0) Wow, this just brings up more questions, is the compiler removing the "colorWith" semantics or do you write your own translator?

I suspect they wrote a new init function specifically for Swift (as an extension), but I could be wrong.
Post reply on HN