News for hackers. Stuff that matters.
Re:The Decade of Swift by ardit33 on Monday December 30, 2019 @05:38PM (#21917317)
I hate to say this, but Swift is to Objective-c, what Scala is to Java....

It was very exiting and promising at first, but it became bogged down due to its sheer run-away complexity and over-academic approach to programming....

To an outsider, or iOS new comer, Swift looks much better than Objective-c, (due to Objective-c weird syntax), but to many insiders, Swift seems like a huge missed opportunity...

The use of Swift, outside Apple's ecosystem is going to be limited.

Re:The Decade of Swift by chc on Monday December 30, 2019 @06:08PM (#21917526)
I don't think there's any world where Swift is popular outside Apple's ecosystem. It's not anything wrong with the language that's the problem, it's that the primary reason you'd use Swift over similar languages like Rust or Nim is its integration into Apple's ecosystem. It has some unique features outside of that, but not enough to make up for how deep in the wilderness you'd be running Swift on non-Apple platforms. Rust, for example, is probably more complex then Swift — but I'd still choose it over Swift for cross-platform development because the language has a strong cross-platform story.
Re:The Decade of Swift by skohan on Monday December 30, 2019 @06:34PM (#21917667)
> I don't think there's any world where Swift is popular outside Apple's ecosystem.

I wouldn't go quite that far. I agree that Swift's cross-platform story is lacking, but as someone who follows the language closely, the story is improving all the time.

I see it as largely a chicken-and-egg problem: i.e. there's not enough activity outside the Apple ecosystem to improve the situation quickly, but I don't think it's impossible for it to get there.

For instance, it's already possible to use Swift in AWS Lambda, and some support for Azure's alternative offering, as well as Google's work on Swift for Tensorflow. All of these cases involve running Swift code in a very controlled environment, like a container, and this is very tenable even in Swift's current state. So even if it might be a bit of a pain to get Swift up and running on whatever exotic linux distro you run on your workstation, there are already starting to be some "easy" use-cases for Swift outside of Apple platforms. As the scope of these one-off use-cases grows, I think it's likely there will be increased demand to improve the cross-platform story in general.

Personally this is appealing to me, because while I agree that Rust is miles ahead in terms of cross-platform support, I find Swift so much more productive and pleasant to work with that I welcome more opportunities to use it.

Re:The Decade of Swift by pavlov on Monday December 30, 2019 @05:51PM (#21917407)
For a language whose nearly exclusive use case is writing Cocoa applications, it’s odd how Swift ignored most of what had made Obj-C so good for GUI apps. Instead they just doubled down on everything that C++ was and Obj-C actively had tried to avoid.
Re:The Decade of Swift by jzelinskie on Monday December 30, 2019 @06:06PM (#21917516)
Would you mind expanding on these feature sets a bit more?

Because I just started playing with SwiftUI/Combine without ever using ObjC/UIKit, I don't know what parts of ObjC shined.

Re:The Decade of Swift by saagarjha on Monday December 30, 2019 @06:11PM (#21917539)
Objective-C was a good fit for dynamic, object-oriented GUI frameworks like Cocoa because that’s how it itself was structured. SwiftUI and Combine are simply a different way of structuring UI code that fits a lot better with Swift’s strengths.
Re:The Decade of Swift by solarkraft on Tuesday December 31, 2019 @10:44AM (#21921729)
Could you expand on that? How do the structures differ?
Re:The Decade of Swift by jcelerier on Tuesday December 31, 2019 @03:27AM (#21919701)
That is the first time in my life I hear objc and good in the same sentence. Every UI developer I know who has worked in it actively despised it.
Re:The Decade of Swift by saagarjha on Monday December 30, 2019 @05:45PM (#21917367)
I find Swift to be significantly more usable and less academic than Scala, and I like it much more as a result. Sure, it takes a number of cues from Scala, but it takes care to not fall into the same traps.
Re:The Decade of Swift by melling on Monday December 30, 2019 @05:49PM (#21917393)
Nah, Swift is an easy language.

I have a Cookbook here:

http://www.h4labs.com/dev/ios/swift_cookbook.html

I’m in the process of putting it on Github.

https://github.com/melling/SwiftCookBook

SwiftUI probably means that millions of apps will eventually move to Swift, making Swift a top 10 language.

https://www.tiobe.com/tiobe-index/

Re:The Decade of Swift by RandallBrown on Monday December 30, 2019 @06:32PM (#21917651)
Swift is already a top 10 language according to TIOBE.
Re:The Decade of Swift by 6700417 on Monday December 30, 2019 @07:17PM (#21917908)
TIOBE’s methodology and rankings seem very dubious to me. When was the last time you met someone who primarily programs in C? (I was one of those people for 14 years, but that was a while ago).

Red Monk seems much closer to reality: https://redmonk.com/sogrady/2019/07/18/language-rankings-6-1...

Re:The Decade of Swift by saagarjha on Monday December 30, 2019 @07:34PM (#21918013)
TIOBE is probably not worth looking too much at, but a number of embedded engineers use C almost exclusively. They’re just not all that visible :)
Re:The Decade of Swift by panpanna on Tuesday December 31, 2019 @03:01AM (#21919623)
> When was the last time you met someone who primarily programs in C?

I am sorry to say, you live in a bubble.

Re:The Decade of Swift by 6700417 on Tuesday December 31, 2019 @03:27AM (#21919699)
Re:The Decade of Swift by lykr0n on Monday December 30, 2019 @08:11PM (#21918194)
There are worlds of software developers outside of the Startup sphere.
Re:The Decade of Swift by 6700417 on Monday December 30, 2019 @09:58PM (#21918628)
I’ve never worked at a startup. I know very few people who have been involved in the startup world. I have exclusively used C and C++ in my professional work (with a tiny bit of python for scripting).

Yet I haven’t know anybody who primarily or even occasionally used C in their work for over a decade. I know they exist but the majority of C programmers moved on to C++ a long time ago.

There are areas like kernel and driver development where C is still in widespread use but these jobs represent a tiny fraction of developers.

Any language popularity metric that ranks C as the second most popular language is massively flawed.

Re:The Decade of Swift by codr7 on Monday December 30, 2019 @11:36PM (#21918980)
Except the entire world runs on top of C and will continue to do so for quite some time, it's not all about new or user facing projects.

Linux is pretty popular.

Re:The Decade of Swift by 6700417 on Monday December 30, 2019 @11:49PM (#21919039)
The world running on top of C and Linux being popular have nothing to do with this. Have you looked at what TIOBE claims to measure? They very specifically say it’s not about the number of lines of existing code. It’s supposed to be a measure of the popularity of the language.

From their site (https://www.tiobe.com/tiobe-index/):

“The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. Popular search engines such as Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. It is important to note that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.”

Re:The Decade of Swift by pjmlp on Tuesday December 31, 2019 @05:35AM (#21920117)
C compiled with compilers and standard library written in C++.

My world runs on top of C++.

C is only relevant on constrained embedded hardware and FOSS UNIX clones.

Re:The Decade of Swift by skohan on Monday December 30, 2019 @06:04PM (#21917497)
Can you go into any specifics? Personally I've found Swift to be incredibly easy to read and write, and that it largely delivers in terms of rolling out complexity through progressive disclosure. Most of the complexity is only there if you need it in my experience.
Re:The Decade of Swift by ken on Monday December 30, 2019 @11:34PM (#21918975)
I keep hearing about this concept of "progressive disclosure", but I can't say I've seen it in Swift. Even the simplest functions I want to write, I tug on a little thread of an idea that I have, and pretty soon I'm pulling out this giant tangle that's got 3/4 of the Swift type system dangling off of it.

What you're saying may be technically true. My issue is with the "if you need it" part. Unfortunately, I don't get to choose what I think I need. The compiler does.

For example, every beginning Swift programmer runs into "Protocol can only be used as a generic constraint because it has Self or associatedType requirements" [1]. You start by thinking, I'm going to write a simple little type!, and then 30 seconds later you're digging through the least-documented parts of the Swift manual trying to figure out if there's a simple fix for this. (There isn't.) It's not like Objective-C where you write an -isEqualTo:(id) method and call it a day.

This happens all over the place. Swift lambdas are weirder than Objective-C blocks. Swift errors are weirder than Objective-C exceptions. Swift strings are weirder than Objective-C strings. Ultimately, there is always a reason for the complexity (often: performance), but the upshot is that for any Swift feature I've wanted to use, I always had to learn a lot of extra details before I was able to use it.

I feel there are a lot of other languages which are both easier to read and write, and do a much better job at progressive disclosure.

[1]: https://www.youtube.com/watch?v=XWoNjiSPqI8&t=53s

Re:The Decade of Swift by skohan on Tuesday December 31, 2019 @03:21AM (#21919682)
Interesting. I guess in my opinion, there is a difference between "swift has some pain points" and "swift is inherently over-complex". I have run into the associated types issue (which is improved a bit by the addition of existential by the way) but my reaction was more that this is a particular design pattern to avoid, rather than that the language is null and void.

Given that you've made the comparison to Objective-C, are you sure you're not just running up against the learning curve of a new language? There are cases where Swift is a bit stricter, and therefore it's harder to type code which will compile on the first try, but in many of those cases it's because the strictness is allowing you to avoid entire categories of runtime bugs, which would give a non-specific error in Objective-C given the dynamic nature of the language.

Re:The Decade of Swift by developer2 on Tuesday December 31, 2019 @04:27AM (#21919904)
Has Swift improved their text handling? Last time I looked, it took way too many lines of code and temporary variables just to extract a substring range from a string. Their convoluted idea that a string can't be directly sliced with integer indexes–by bytes, let alone by Unicode code points or graphemes–was so frustrating I swore I would never look in Swift's general direction again. It was such a joke just to try to extract x UTF-8 characters starting from position y. I liked the overall feel of the language, but the fact I ran into such a horrible wall trying to perform the most basic of string manipulations was unforgivable.

Swift came out at a time where UTF-8 was already the standard. They talked a lot of talk about grapheme clusters being the most accurate representation, and then failed to deliver a coherent API to back it up. Any chance that has changed?

Re:The Decade of Swift by skohan on Tuesday December 31, 2019 @03:11PM (#21924307)
It's gotten a bit better, but Swift is still probably not the tool you want to use if you need to do a lot of string manipulation. Swift's string implementation has some interesting properties in terms of memory efficiency and performance, but it still requires fairly the verbose use of string indexes when working with strings rather than simple int offsets. There are good reasons for this, but it's not terribly ergonomic to work with.

FWIW it would probably be fairly easy to implement some String extensions which would give you the kind of API it sounds like you are looking for.

Re:The Decade of Swift by shmerl on Monday December 30, 2019 @05:44PM (#21917353)
I think Rust supersedes it in most aspects, especially in not being Apple driven.
Re:The Decade of Swift by skohan on Monday December 30, 2019 @06:02PM (#21917481)
I would kill for a language with Swift's productivity and usibility and Rust's tooling and ecosystem.
Re:The Decade of Swift by zozbot234 on Tuesday December 31, 2019 @01:12AM (#21919304)
Rust can be quite usable and productive if you know the right shortcuts. The tradeoff is somewhat lowered performance (and Rust makes sure that you're aware of where you're choosing that tradeoff) but that's just the way it goes. It's not like Swift is any different.
Re:The Decade of Swift by skohan on Tuesday December 31, 2019 @03:43AM (#21919756)
I think Rust is a fine language, but it's undeniable that it involves more tedium than other languages to use.

If there is some tradeoff between safety, performance, and usability, Rust has prioritized safety and performance, where swift has chosen safety and usability. And that's perfectly fine. I am glad that Rust exists for those use-cases where the performance is important, but there are also cases where it's more important to be able to write a lot of code quickly with less friction.

It doesn't devalue Rust to admit that there are places where it is not the optimal choice.

Re:The Decade of Swift by zozbot234 on Tuesday December 31, 2019 @03:51AM (#21919782)
> more tedium than other languages

Perhaps you haven't programmed in Java. Or even C++, for that matter (modern "Core C++" programming can be quite tedious at times).

I'd say the jury is still out when it comes to Rust vs. "higher level languages", yes, even Swift. The point of my comment is that the "friction" you're pointing to need not be an inherent property of something like Rust, any more than it is in C++. It remains to be seen if the 'tradeoff' you mention is a binding one.

Re:The Decade of Swift by skohan on Tuesday December 31, 2019 @04:43AM (#21919952)
> Perhaps you haven't programmed in Java. Or even C++, for that matter

I never said Rust was the most tedious language, and I would hope it has learned something from those decades old languages.

I agree that Rust has some usability issues which can be improved upon without sacrificing safety and performance, but I think that trade off will always be there at some level.

For example, Swift’s copy-on-write makes it very easy to reason about value types, but comes at the cost of performance since there will be a lot of copies which aren’t strictly necessary. You can get essentially the same behavior in Rust by cloning everything, but it takes a lot more typing and adds visual noise to your code, because Rust has made the default to be more parsimonious with memory usage.

At some level trade offs have to be made. No one language can be all thing a to all people.

Re:The Decade of Swift by pjmlp on Tuesday December 31, 2019 @05:42AM (#21920139)
Thing is, yes it might cost performance, but does it matter?

It all boils down to, does it deliver what the customer of an application written in Swift is asking for?

Re:The Decade of Swift by skohan on Tuesday December 31, 2019 @06:09AM (#21920245)
Yeah that is exactly my point. In many cases all the extra work you put into writing Rust code for the additional performance is just that: extra. It doesn’t add any meaningful value to the final product, and it comes at the opportunity cost of that time you could have spent adding or improving features in a more productive language.
Re:The Decade of Swift by pjmlp on Tuesday December 31, 2019 @07:58AM (#21920706)
Yeah, while Rust is paving the way for affine type systems among mainstream languages, and it already influenced design decisions on other system programming languages, including Swift (memory ownership manifest), it isn't the first on my list for UI or distributed computing applications.
Re:The Decade of Swift by skohan on Tuesday December 31, 2019 @10:17AM (#21921500)
Yeah to me Rust almost feels like the prototype for the next great programming language. There are a lot of great ideas there, but there are also a lot of awkward edges. Like what it accomplishes from a technical perspective is super impressive, but it would be great if somebody could synthesize all of those concepts behind a cleaner front-end which really nails the ergonomics.
Re:The Decade of Swift by steveklabnik on Tuesday December 31, 2019 @11:09AM (#21921991)
A few people have tossed around the idea of “what if Rust but drop the commitment to zero cost abstractions.” That’s probably our principle that causes the most ergonomic hit.

Of course, Rust won’t start taking that path, but if I were to start a new language today, that’s what it would look like.

Re:The Decade of Swift by skohan on Tuesday December 31, 2019 @02:39PM (#21923985)
Interesting. There was a really good talk at the last CPPCon by Chandler Carruth about how there is really no such thing as a zero-cost abstraction. The main point being, while you might be able to optimize against a runtime performance cost for abstractions, the cost will almost always be shifted to compile time, or to the cognitive burden on the developer.

It really makes me think there must be something like the first law of thermodynamics for logical complexity.

Re:The Decade of Swift by steveklabnik on Tuesday December 31, 2019 @06:21PM (#21925492)
Yeah, I haven’t watched the talk, but as you’d expect, Chandler has his head on straight. This is a common misconception: zero cost refers to runtime only. There’s always cost. Some people have started saying “zero overhead” instead to make it more clear, but it takes a while to change entrenched terminology.
Re:The Decade of Swift by panpanna on Tuesday December 31, 2019 @03:03AM (#21919626)
Go?

Kotlin?

Re:The Decade of Swift by lokedhs on Tuesday December 31, 2019 @03:57AM (#21919800)
Kotlin Native is nice, but its compile times are absolutely horrible. I guess some of this comes from Gradle, which is another mess in itself, but when it takes over half a minute to compile Hello World, there is a problem.
Re:The Decade of Swift by skohan on Tuesday December 31, 2019 @03:33AM (#21919723)
Go is a nice language for some use-cases, but a bit too light on abstractions for my needs.

When I tried Kotlin a couple years ago, it seemed to be marginally behind Swift in terms of the power of the type system and some of the cool things you can do in Swift, and I'm not wild about targeting JVM, but I understand that situation has been evolving so maybe I should give it a second look at some point.

Re:The Decade of Swift by jbverschoor on Monday December 30, 2019 @06:03PM (#21917487)
So we’ll refuse go, typescript and react?

Apple has the best engineering talent of all tech companies.

Re:The Decade of Swift by saagarjha on Monday December 30, 2019 @06:06PM (#21917511)
I think the parent cared more about it being driven by a specific company’s interests than Apple’s in particular, because this makes it somewhat difficult to use on other platforms. And I’d argue that Apple’s engineering talent, while good, is not “the best”.
Re:The Decade of Swift by shmerl on Monday December 30, 2019 @06:23PM (#21917606)
Hard to say if it's the best, but likely the worst attitude of the management on top when it comes to collaboration and general progress (which languages should enable).
Re:The Decade of Swift by jbverschoor on Monday December 30, 2019 @06:45PM (#21917741)
Oh def. Apple has been too slow and/or conservative about opensource.
Re:The Decade of Swift by enitihas on Monday December 30, 2019 @06:06PM (#21917509)
Off course, that's why they keep having security issue after security issue (macOS root exploit to iPhone issue reported by project zero).