News for hackers. Stuff that matters.
Re:IBM says Swift is ready for the enterprise by nnq on Monday September 26, 2016 @09:20AM (#12581524)
So... what's the "elevator pitch" for Swift?

It has anything interesting over Elixir or Go (well, go's feature is "lack of feature" but you know what I mean) or Scala or Kotlin?

I know that iOS and MacOS desperately needed a modern language, and great for them that they have it now, but does the rest of the world need it?

Re:IBM says Swift is ready for the enterprise by hellofunk on Monday September 26, 2016 @09:28AM (#12581596)
I think the pitch is that despite static typing, it offers a lot of multi-paradigm high-level features while remaining elegant with fairly minimal syntax compared to other native static languages like Rust or C++. It automatically manages memory but without a stop-the-world garbage collector and goes a long way to opening a lot of flexible design options to any developer: it has great support for generic programming, object orientation, and functional programming.

The downsides? Well, I find some of its syntax choices a bit odd and inconsistent; I think the pursuit of elegance could have gone much further. And, while I celebrate its pervasive use of closures/lambdas and functional idioms in my many contexts, it lacks true functional data structures that would be necessary to really write in a proper functional style with confidence that the runtime wouldn't suffer.

Also, the implementation of its high-level features is somewhat magical and hidden. You can't depend on performance when using them until you really study them. So much so, that WWDC had a big talk about how to choose language features depending on the type of performance you need, and none of it was intuitive.

Additionally, at least on the Apple platforms, its Objective-C heritage can be a bit annoying. In particular, you can't mix and match closures with "selectors", which is a real shame and missed opportunity for flexibility and elegance.

Re:IBM says Swift is ready for the enterprise by dcosson on Monday September 26, 2016 @10:34AM (#12582135)
One other downside is XCode. No refactoring support, and lots of errors that give you little help. For instance, if you're trying to implement a protocol which is itself a few layers of nested protocols, XCode will just tell you it doesn't conform and not what method you're missing, so you have to dig through and check every signature of every method carefully.

The swift 2 to 3 migration was absolutely insane, I'd estimate Xcode did maybe 25% of the work automatically and left me with hundreds of different errors to convert manually (and often they were red herrings where the actual error was not where Xcode said it was). And you have to rebuild all dependency frameworks on swift 3 as well since the binaries are incompatible. If you use Swift make sure you have 2-3 whole developer days per year to devote to just migrating to the next version in a medium sized project.

Re:IBM says Swift is ready for the enterprise by emdowling on Monday September 26, 2016 @12:15PM (#12583071)
I would agree with this. The biggest issue with Swift right now is Xcode. Multiple times each day, syntax highlighting and code completion will break, even though the code is perfectly valid. The lack of refactor support after three Xcode releases and major versions of Swift is inexcusable.

Using storyboards is super frustrating due to the load times. It seems no one at Apple tests with more than one storyboard in a project.

I love going back to Ruby dev because VS Code is just such a joy to work in compared with Xcode. Xcode really struggles on my top of the line MBP with 16GB RAM.

I still love the language compared to ObjC but the tooling is abysmal. Every year we hold out hope that Xcode will magically get better but its the iTunes of IDEs at this point.

Re:IBM says Swift is ready for the enterprise by dep_b on Monday September 26, 2016 @12:55PM (#12583452)
Well I don't know any experienced developer that would put more than three populated scenes in a Storyboard. I would only add more if it was something like a navigation setup (navcontroller, menu, etc) where I would simply nest a lot of empty screens and link to the real screens with storyboard references.

You can always use AppCode if you don't like Xcode.

Re:IBM says Swift is ready for the enterprise by Oreb on Monday September 26, 2016 @04:00PM (#12585064)
AppCode has also become increasingly buggy over the last year or so, and is now almost as unusable as Xcode (albeit in different ways).

On my computer, recent versions of AppCode constantly use at least 100% CPU, even when it's in the background doing nothing. I got this a few times in earlier versions as well, but an "Invalidate caches and restart" usually fixed the problem. No such luck with recent versions. It will always use at least 100% when it's running.

I often get 30 seconds of beachball when I switch back to AppCode from some other app, despite having 16GB of RAM and not running any other remotely heavy app. This will happen even if I just leave AppCode for half a minute in order to check something on a web page. It's gotten so bad that I've developed the habit of checking web pages on my iPad instead of on my Mac, in order to avoid temporarily leaving AppCode.

There is a particularly infuriating bug that will sometimes cause AppCode to freeze when I type the opening parenthesis of a function invocation. When this happens, killing, restarting and typing again won't work, AppCode will freeze at the same spot. The only workaround I have found when this happens is to type my function invocation in some other editor and copy and paste to AppCode (often after waiting the usual 30 seconds for AppCode to stop beachballing).

It is not just me – all my coworkers suffer from the same problems. AppCode is by far the most annoying app I use on a daily basis. I hate it nearly – but not quite – as much as Xcode.

Re:IBM says Swift is ready for the enterprise by emdowling on Monday September 26, 2016 @05:27PM (#12585726)
This is my point - I use multiple storyboards to break up the app and use storyboard references where appropriate. But loading up individual storyboards, waiting for them to render (which takes far longer now with @IBDesignable), etc is such a drain in productivity.
Re:IBM says Swift is ready for the enterprise by coldcode on Monday September 26, 2016 @12:09PM (#12583017)
Swift is amazing, Xcode is crap, and I've been using Xcode and its NeXT version for almost 20 years. I work in Xcode every day and every day I want to hurl it. Apparently Apple either doesn't care or is too overwhelmed with building 4 OSs every year. To be effective for building server side apps we need a new dev environment.
Re:IBM says Swift is ready for the enterprise by Razengan on Monday September 26, 2016 @09:59AM (#12581833)
> You can't depend on performance when using them until you really study them. So much so, that WWDC had a big talk about how to choose language features depending on the type of performance you need, and none of it was intuitive.

In which language does optimal performance come for free without really studying it? You have to pay attention to your case and context and use features accordingly, no matter what language you're using..

Re:IBM says Swift is ready for the enterprise by themihai on Monday September 26, 2016 @10:13AM (#12581935)
> It automatically manages memory

I have to stop you there. You shouldn't compare anything to C/C++ or Rust after that. You are better off comparing Swift with Go(i.e. both have automatic memory management, nice syntax, static typing, dynamic feeling etc) or Java(automatic memory management, well established in the enterprise world). If Apple was to design a language to respond to Go or Java it would be Swift and that's it. So the pitch is that you have a nice language which encourages productivity and you can share the knowledge/code between server and client.

Re:IBM says Swift is ready for the enterprise by hellofunk on Monday September 26, 2016 @10:20AM (#12581987)
Well, technically Swift's memory management is the same as what C++ offers via smart pointers, the only difference is that in C++ it is opt-in (and still very popular). Swift is quite unlike Go or Java's memory management; it is not a GC in the sense that they use it.
Re:IBM says Swift is ready for the enterprise by pcwalton on Monday September 26, 2016 @11:54AM (#12582879)
Swift memory management isn't nearly as expressive as C++ when it comes to references (i.e. unmanaged pointers). You can use in/out/inout parameters on functions and that's about it.

I agree with the parent that Swift memory management is basically like Go or Java: everything is GC'd (reference counting being a form of GC).

Re:IBM says Swift is ready for the enterprise by hellofunk on Monday September 26, 2016 @02:15PM (#12584208)
You don't need in/out params to get references; in Swift, anything defined with "class" is always passed by reference.
Re:IBM says Swift is ready for the enterprise by pcwalton on Monday September 26, 2016 @04:25PM (#12585243)
Unmanaged references. Regular old class references aren't unmanaged (they adjust reference counts).
Re:IBM says Swift is ready for the enterprise by themihai on Monday September 26, 2016 @12:34PM (#12583271)
Swift does have a runtime though. In its current form I can't see it replacing C or C++. It may provide more deterministic performance than Go but it's not C. If it were to be designed as C replacement I would expect a roadmap for embedded environments, praise about its mapping to the hardware, how it trashes or at least matches C/C++ on its application domain(i.e. low level/ hardware interface or performance) etc but it's clear that is not the case and its focus is on "apps" first, servers second and maybe a bit of low level.
Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @10:03AM (#12581864)
> but without a stop-the-world garbage collector a

RC is a stop-the-world garbage collector when the reference count reaches 0 in very complex data structures, which trigger a cascade of deletions.

Also it has issues with sharing data between threads leading to cache coherency contention and locks.

Re:IBM says Swift is ready for the enterprise by gpderetta on Monday September 26, 2016 @11:35AM (#12582689)
That's not stop the world. Under RC, when a thread is destroying a complex data structure, other threads are free to keep doing useful work.

RC does otherwise have very bad interactions with threads of course.

edit: clarify

Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @12:26PM (#12583197)
Just like a parallel GC.
Re:IBM says Swift is ready for the enterprise by gpderetta on Monday September 26, 2016 @12:59PM (#12583486)
parallel != stop-the-world
Re:IBM says Swift is ready for the enterprise by hellofunk on Monday September 26, 2016 @10:09AM (#12581904)
Fair enough. The point I was (trying) to make is that Swift doesn't have a traditional GC like Java, or Javascript, etc.
Re:IBM says Swift is ready for the enterprise by supster on Monday September 26, 2016 @09:31AM (#12581624)
1. Inferred static nominal typing with generics

2. 1st class support for Optionals

3. Support for Structs and Classes

4. Native binary & scripting mode

5. Automatic reference counting (instead of garbage collection)

6. Large standard library

7. Large corporate backer (Apple)

8. Open source

9. Good C, C++, & Obj-C interoperability

10. Decently fast (https://medium.com/@qutheory/server-side-swift-vs-the-other-...)

Re:IBM says Swift is ready for the enterprise by stepanhruda on Monday September 26, 2016 @09:38AM (#12581683)
Non C++ interop yet
Re:IBM says Swift is ready for the enterprise by supster on Monday September 26, 2016 @09:39AM (#12581692)
You're right, I believe it's on the road map
Re:IBM says Swift is ready for the enterprise by 0xCMP on Monday September 26, 2016 @09:50AM (#12581774)
But good Objective-C interop for working with old app code and libraries (Which comes from the C support, but with all the special stuff done to talk to Obj-C done for you)
Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @10:00AM (#12581839)
No, but one can make use of Objective-C++ as a way to create Swift wrappers.
Re:IBM says Swift is ready for the enterprise by aikah on Monday September 26, 2016 @09:44AM (#12581724)
Swift is statically typed (Elixir isn't) with a good type system (Go hasn't) and doesn't run in a VM (like Scala or Kotlin). I don't know how good its concurrency is and on how many platforms it is available though. It also looks like the language itself is still not that stable which is in my opinion a no go.
Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @10:05AM (#12581870)
Scala and Kotlin both have projects for AOT compilation to native code.

You can also get it today with any commercial JDK like Excelsior JET.

Re:IBM says Swift is ready for the enterprise by virtualwhys on Monday September 26, 2016 @10:45AM (#12582219)
> Scala and Kotlin both have projects for AOT compilation to native code

Not sure about Kotlin (stable version of the language was only recently released; more likely a stable JS target is higher on the priority list), but Scala Native isn't production ready, will likely be at least a year from now; same goes for Scala Meta, and Dotty's even further out, minimum 2 years away.

Swift has a head start here, and a huge captive audience in legions of iOS developers -- unlikely that Scala will be able to compete on the native front directly. More likely Scala.js + React Native may draw some from the JS developer pool that want to take advantage of static types and seamless client-server interop that can be had via Scala/Scala.js today.

Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @11:03AM (#12582387)
You missed the part that AOT native compilers for JVM languages already exist today, but I accept that people don't want to pay for them.
Re:IBM says Swift is ready for the enterprise by virtualwhys on Monday September 26, 2016 @11:33AM (#12582663)
Sure, was just pointing out that no such native ports exist for Scala or Kotlin that are anywhere near production ready.

In fact, it appears that a Kotlin Native project exists in the sense that a blog post exists that announced a native target is something they're looking into implementing down the road -- hardly a project ;-) Scala Native's been under heavy development for over a year now[1], and even then it's a long way off.

[1] https://github.com/scala-native/scala-native/graphs/contribu...

Re:IBM says Swift is ready for the enterprise by iheartmemcache on Monday September 26, 2016 @10:36AM (#12582153)
Yep, and as a result of this, the JDK ecosystem is healthy as ever. N.b to those who have only written web or phone apps for a living -- GC latency isn't 'bad' in most cases - unpredictable latency is what's bad. Having a deterministic upper-bound is what is important in the enterprise, on your aviation component regulating cabin pressure, on your SWIFT bank transfer.

Also, see the top comment here: https://news.ycombinator.com/item?id=11759762 for a JDK discussion against ref-counting, along with this [now incredibly old] paper https://www.cs.purdue.edu/homes/hosking/690M/urc-oopsla-2003...

(N.b. around the time that paper was published, I was in HFT. We used Azul C4 and it just fine to crush even with management taking their typical 30/3 fees. Though to be fair, this was when the easy pickin's were still there to be plucked. Don't underestimate how well good-ol' free Hotspot is now; we're not talking 1996 Jakarta days with Swing)

Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @10:46AM (#12582231)
One of the reasons I always argue for GC is that I used Native Oberon, and also collect papers related to Xerox PARC and DEC research.

Modern hardware would be a dream to any of those researchers doing systems programming in GC enabled languages.

I only consider the biggest flaws of Java not adopting AOT from the beginning and the lack of value types. Now the JDK ecosystem needs to wait until Java 10, probably around 2020 or later, to get them.

Re:IBM says Swift is ready for the enterprise by TurboHaskal on Monday September 26, 2016 @09:46AM (#12581742)
It is backed by Apple and will become the de facto language for writing iOS (macOS too?) applications, potentially attracting a healthy pool of developers and thus reducing costs which in the end is all that matters in non high integrity software.

Features don't matter much I'm afraid.

Re:IBM says Swift is ready for the enterprise by Someone on Monday September 26, 2016 @11:40AM (#12582733)
For IBM, part of the lure probably is "the enemy of my enemy is my friend".

It's not running on a VM that Oracle or Microsoft control, and not a language Google controls.

Yes, it is Apple's language, but IBM apparently thinks it will become more popular than one they would control on their own, and picking Apple's language then is, for them, the least risky, as Apple isn't a company focusing on servers.

Re:IBM says Swift is ready for the enterprise by pducks32 on Monday September 26, 2016 @02:18PM (#12584240)
Other than Swift being a great language this is certainly at the top of the list. If not on a management level then on a developer POV level. Plus in some way they associate Apple with themselves, they become (in some weird way) the Apple of enterprise.
Re:IBM says Swift is ready for the enterprise by Dancing_Mad on Monday September 26, 2016 @09:31AM (#12581625)
It allows enterprises to use their current iOS and macOS developers to do Web Application and server side applications. For developers it gives them additional ecosystems to use their skills on without having to learn a new language from scratch.
Re:IBM says Swift is ready for the enterprise by Un1corn on Monday September 26, 2016 @10:30AM (#12582097)
>It allows enterprises to use their current iOS and macOS developers to do Web Application and server side applications.

That's what they said about front-end web developers and now we have nodeJS.

Re:IBM says Swift is ready for the enterprise by toomanybeersies on Monday September 26, 2016 @09:52AM (#12581787)
I would suspect that most companies have more non-iOS developers than iOS developers.
Re:IBM says Swift is ready for the enterprise by softawre on Monday September 26, 2016 @09:54AM (#12581798)
Heh, deja-vu man. That's what we said about ASP.net/windows years ago.
Re:IBM says Swift is ready for the enterprise by mdasen on Monday September 26, 2016 @10:15AM (#12581949)
It does have some interesting bits.

1. It doesn't have a GC. While the JVM's GC is decent, it can definitely cause latency spikes.

2. It has value types. Go has this, but Scala and Kotlin mean running on the JVM which means leaving memory locality behind. In fact, Swift allows you to select whether you want an object that contains pointers to things or a struct. Go gives you structs and Scala and Kotlin give you pointer-based objects.

If all you care about is syntax, Swift might not be that interesting to you. However, you get options in terms of how the program runs that the other languages you've mentioned don't give you. You can't decide that you want to create an object in Scala or Kotlin that is contiguous in memory. You can't decide you'd rather not have GC pauses in Go.

In many ways, Swift brought together the kind of niceties that have been available before. Generics aren't something new, value types aren't new, objects aren't new, first-class functions aren't new, ARC isn't new, non-nullable variables aren't new, closures aren't new, type inference isn't new. . . But none of those languages have all of those. Go took a hard stance against generics (I'm not going to go into why). The JVM doesn't really do value types. GC has been the standard for most new languages for a while.

Swift definitely offers new things.

Re:IBM says Swift is ready for the enterprise by pjmlp on Monday September 26, 2016 @10:47AM (#12582251)
> While the JVM's GC is decent, it can definitely cause latency spikes.

Which one?

Java is like C and C++, there are plenty of JDKs to chose from, each it is own set of implementation behaviors, for the different types of customer pocket sizes.

Re:IBM says Swift is ready for the enterprise by premium-concern on Monday September 26, 2016 @12:31PM (#12583243)
Scala has value types, and on native all the current restrictions from the JVM are dropped.

Additionally, you can also explicitly allocate things on the stack.

You can also allocate continuous memory.

Re:IBM says Swift is ready for the enterprise by coldtea on Monday September 26, 2016 @09:56AM (#12581810)
>It has anything interesting over Elixir or Go

Compared to Go it's a whole other level of interesting...

Think of Highway 50 (NV) vs Highway 1 (CA).

Re:IBM says Swift is ready for the enterprise by cozzyd on Monday September 26, 2016 @01:00PM (#12583495)
70 mph vs. 15 mph?
Re:IBM says Swift is ready for the enterprise by geodel on Monday September 26, 2016 @09:30AM (#12581619)
It is backed by Apple and will be main language to develop for iOS/macOS/tvOS/watchOS systems.
Re:IBM says Swift is ready for the enterprise by qaq on Monday September 26, 2016 @09:26AM (#12581580)
It's fairly decent as far as OOP languages go, but I'd say it's appeal as server side language is limited to iOS devs though :).
Re:IBM says Swift is ready for the enterprise by eyelidlessness on Monday September 26, 2016 @11:13AM (#12582483)
I don't think it's fair to call Swift an OOP language. It is certainly multi-paradigm, but provides a lot of facilities for functional programming as well. If you are not working directly with Cocoa, you can do a lot of interesting stuff with structs and protocols.

It appeals to me as a server-side language, and I've never done any iOS work. The reasons it appeals:

- Static types - Good type system - Lots of good support for immutability - Apple is heavily invested in Swift, and very responsive to the community

It has some downsides. I'd evaluate Swift against Clojure and Elixir (which both have good, though quite different, concurrency stories), and maybe Haskell (but that would be tough from a buy-in perspective). But evaluating it against Python (which my team currently uses), it's hard to see a downside; we chose Python for Django and DRF, but we're increasingly not in love with that choice.

Re:IBM says Swift is ready for the enterprise by Aker89 on Monday September 26, 2016 @11:48AM (#12582802)
Okey, so what is appealing to you then? (just curious)
Re:IBM says Swift is ready for the enterprise by qaq on Monday September 26, 2016 @04:24PM (#12585228)
Elixir