Live data from Hacker News

Swift Programming Language Evolution

github.com

161–170 of 181 posts

Re: Swift Programming Language Evolution

#161

To me, the most interesting empirical result of the Swift language evolution so far is the lack of urgency on language-level concurrency. If they think they can be competitive for years (at the very least vs. Objective-C) with only platform-level concurrency support, it makes me wonder whether concurrency is generally better provided by the platform instead of the language for most needs. Conventional wisdom would ha…

Here is my proposal for syntax support for the existing callback+libdispatch patterns: https://gist.github.com/oleganza/7342ed829bddd86f740a#async-...

The idea is to flatten the syntax without change of the runtime model in the same spirit they did error handling: feels like exceptions, but without ugly stack manipulations.

Re: Swift Programming Language Evolution

#162
post #27

I've never understood the fascination with Swift. What's wrong with Objective C?

[nil someMessage] Though some consider this a feature, YMMV.

Too many times have I forgotten to initialize some member and just had things silently fail in strange ways. Swift checks for uninitialized "let" variables or non-optional "var"s

Re: Swift Programming Language Evolution

#163
post #157

Earlier quoted context omitted.

Starting with OS X Yosemite, you can use JavaScript for writing Mac apps and scripts. https://developer.apple.com/library/mac/releasenotes/Interap...

Using JS for automation is a great start. I don't think they have a way to build a JS app that leverages the full capabilities of either Mac or iOS yet.

You can write full OS X apps in JavaScript:

http://tylergaw.com/articles/building-osx-apps-with-js

JavaScript bridging works on iOS too!

Re: Swift Programming Language Evolution

#164
post #8

Earlier quoted context omitted.

My favorite thing about Swift is that is seems to get out of the way - and when it gets in the way it's usually with a nifty language feature (like the { $0 + $1 } closure syntax). I'm very excited for the future - between Go and Swift we now have two compiled fast languages that are almost as expressive as their slower dynamic/interpreted cousins. As an aside, I like that Apple is betting the farm on ARC. I wish I c…

>I wish I could have been a fly on the wall when they were discussing ARC versus GC. Apple shipped a tracing GC (RC is a form of GC) for a while, but couldn't get it to work reliably or with adequate performance. ARC was a bit of a "Hail Mary" and is problematic in its own right, but certainly better than the GC it replaced. Marcel

> ARC was a bit of a "Hail Mary" and is problematic in its own right

I'm just curious with your experience what you are pointing to as problematic. Other than potential extra release calls in tight loops, the main downside I saw was it made the use of C structs way less appealing---at the same time, I wouldn't want to with manually memory managed C structs in GCD blocks.

Re: Swift Programming Language Evolution

#165
post #158

Earlier quoted context omitted.

But, that wouldn't make any sense to include UI components in a programming language. And I think the interest level is already "spiked".

Okay. I was under the (perhaps not true) impression that the vast majority of swift apps were iphone apps, with the apple specific UI bindings. Such that one of the first questions on a new platform (Linux, Android, etc) would be "how do I create the UI?". It sounds like instead, the cross platform appeal is that back end or background services can now be written on non-apple platforms?

That's correct. UIKit isn't like, baked into Swift. Whatever platform you're writing for would need to provide to you UI components and then some.

Re: Swift Programming Language Evolution

#166

To me, the most interesting empirical result of the Swift language evolution so far is the lack of urgency on language-level concurrency. If they think they can be competitive for years (at the very least vs. Objective-C) with only platform-level concurrency support, it makes me wonder whether concurrency is generally better provided by the platform instead of the language for most needs. Conventional wisdom would ha…

Go (which I think you're alluding to) has language-level concurrency because its syntax is extremely rigid. Swift's syntax is flexible enough that this isn't needed. Specifically: * Support for annotations; the compiler/runtime can be informed about safety and marshaling concerns. * Anonymous function bodies. You can implement Go's "go func() { ... }()" pattern yourself, and a concurrency runtime can implement it. Ru…

I like this particular example of how easy it can be to make Swift act like it has language-level concurrency features: https://github.com/beeth0ven/BNQueue/blob/master/BNQueue/BNQ...

Some enum and extension magic easily lets you write things like:

  Queue.UserInitiated.execute {
    let url = NSURL(string: "http://image.jpg")!
    let data = NSData(contentsOfURL: url)!
    let image = UIImage(data: data)

    Queue.Main.execute {
      imageView.image = image
    }
  }

Re: Swift Programming Language Evolution

#167

Earlier quoted context omitted.

Go (which I think you're alluding to) has language-level concurrency because its syntax is extremely rigid. Swift's syntax is flexible enough that this isn't needed. Specifically: * Support for annotations; the compiler/runtime can be informed about safety and marshaling concerns. * Anonymous function bodies. You can implement Go's "go func() { ... }()" pattern yourself, and a concurrency runtime can implement it. Ru…

I like this particular example of how easy it can be to make Swift act like it has language-level concurrency features: https://github.com/beeth0ven/BNQueue/blob/master/BNQueue/BNQ... Some enum and extension magic easily lets you write things like: Queue.UserInitiated.execute { let url = NSURL(string: "http://image.jpg")! let data = NSData(contentsOfURL: url)! let image = UIImage(data: data) Queue.Main.execute { imag…

That's awesome. Blocks were always my favourite part of Ruby, and I think it's really cool that it has been adopted into Swift and (to a lesser extent) Rust.

Re: Swift Programming Language Evolution

#168

To me, the most interesting empirical result of the Swift language evolution so far is the lack of urgency on language-level concurrency. If they think they can be competitive for years (at the very least vs. Objective-C) with only platform-level concurrency support, it makes me wonder whether concurrency is generally better provided by the platform instead of the language for most needs. Conventional wisdom would ha…

I'm not sure if Swift really needs language-level concurrency support. As it stands, you can wrap any C library which provides some sort of concurrency and make it feel like native functionality because of Swift's syntactic sugar such as trailing closures. For example, I'm a huge fan of the library Venice[0] which provides CSP by wrapping libmill (single-threaded like libuv, uses setjmp/longjmp instead of callbacks u…

Yes, if Swift team could continue from Zewo and Venice, it will save lot of resources to build from ground up.

Re: Swift Programming Language Evolution

#169

Earlier quoted context omitted.

This is one of the most uninformed posts I have read in a while. As someone who has been developing in Objective C for the last 6 years, and been through the transition of MRC to ARC, none of what is stated in this post is accurate.

Actually, all of it is accurate. Since you're spouting off your credentials as the only evidence for why what I wrote is wrong [not sure how that works], here are mine: - programmed in Objective-C for ~30 years - implemented my own pre-processor and runtime (pre NeXT) - programmed in the NeXT ecosystem professionally since 1991 - additionally, worked in Objective-C outside the NeXT/Apple ecosystem for many years - wo…

I'm guessing LeoNatan has an issue with:

> it's at best a subtle difference and for most code you won't be able to tell the difference.

Which is a pretty dubious claim. I removed a lot of retain/release/autorelease calls when I moved to ARC. Perhaps I'm missing the OP's point...

Re: Swift Programming Language Evolution

#170
post #51
post #27

I've never understood the fascination with Swift. What's wrong with Objective C?

Objective-C has no safe collections for non-object values. If you want an array of ints, for example, you either get to use a C array with lots of manual management and potential for error, or you use an NSArray of NSNumbers and pay for a bunch of overhead. It has very poor support for custom value types. Objective-C structs basically can't contain object pointers, so they're limited to simple things like CGRect. The…

We can even use string interpolation

    let x = "\(number)"
Post reply on HN