Live data from Hacker News

The Decade of Swift

swiftbysundell.com

11–20 of 145 posts

Re: The Decade of Swift

#11
> That’s why Swift’s expressive and very lightweight syntax

And a few paragraphs later:

  extension Array {
    func sorted(
        by keyPath: KeyPath
    ) -> Self {
        sorted { $0[keyPath: keyPath] 
I can't say this is lightweight any longer.

My greatest gripe with Swift comes not from Swift itself but from its standard library. When most new languages start with their own standard libraries that are usually interfaces towards C APIs or POSIX, Swift's Foundation is half of MacOS and then some.

I recently needed to read some data from a file in Swift, and it took me quite some time to realise there was no fopen equivalent. Read/write files is a function on String? And getting a file handle is an excercise in figuring out proper dir names and user enums? [1]

There are a few other weird things in the language itself like guards which IMO are an entirely unnecessary construct that can be as easily solved with regular ifs. Or Optionals that have no way of working with them except unwrapping them (either with ! or via guards).

SwiftUI, however, is a very interesting approach, and I hope there are more frameworks (especially UI frameworks) like this.

[1] https://twitter.com/dmitriid/status/1201441652507844608

Re: The Decade of Swift

#12
Swift has come a long way. I remember first trying it and XCode acting like it couldn't figure anything out in Swift, and you could almost never bring up an autocomplete or search for references or jump to definitions or any nice feature in an IDE that worked just fine with Objective-C. I decided to give it another shot years later, and I'm working on a simple game in Swift right now, and it's been a much, much smoother experience.

Although admittedly there's still some bizarre behavior. Like this morning while iterating over a simple for loop, XCode decided it was just going to stay on the final item in the collection and keep looping until my memory ran out, over and over again, and I couldn't find anyone talking about this online, but eventually decided to do a "Clean Build Folder" and then Build, and that fixed it (but why did it happen in the first place? So odd!).

And it still doesn't always think a class I wrote or renamed is valid when referencing it in another class, but a rebuild or quitting and restarting tends to fix that.

Still, I'm liking it a lot, and having a lot of fun with Swift now. SpriteKit is great for making games, except for the lack of cross-platform capability, but if the game somehow manages to take off, I can write some wrapper classes to have the same behavior as most of the SpriteKit classes I use and port it easily enough.

Re: The Decade of Swift

#13
post #2

Can someone sell me on Swift over dart or kotlin? They seem to be direct competitors. Since we're talking about the future of programming, can someone sell me on Swift instead of ocaml, SML, or F#? I don't see a good reason to pick it outside of targeting Apple devices.

> dart or kotlin? ... ocaml, SML, or F#

+ scala, go, rust, elixir/erlang

Yeah its so much time to learn all this stuff. Its a good reason they probably will all fade, better stick to js/python/java/C#/C++ like everyone else and wait.

Re: The Decade of Swift

#14
post #10

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 Sw…

I think Rust supersedes it in most aspects, especially in not being Apple driven.

Re: The Decade of Swift

#15
post #2

Can someone sell me on Swift over dart or kotlin? They seem to be direct competitors. Since we're talking about the future of programming, can someone sell me on Swift instead of ocaml, SML, or F#? I don't see a good reason to pick it outside of targeting Apple devices.

> Since we're talking about the future of programming, can someone sell me on Swift instead of ocaml, SML, or F#?

I don't think the industry is likely to adopt functional languages. What people in the industry seem to want are safer programs with better null handling (e.g. optionals), friendly handling of async programming (e.g. futures/promises/async await), map/filter/reduce, immutable data types, and similar features that make programs safer and easier to write. Yet, the industry does not want to give up the object-oriented paradigm or the ability to do non-functional-programming stuff.

I think the future of programming languages is going to be hybrid languages rather than functional languages, simply because they are easier to adopt. In some cases, existing languages are absorbing those new features, so many companies are benefitting from them without switching languages.

Of the alternatives you mentioned, F# is the closest to being a hybrid language because of its integration with the .NET platform. Similar languages include Scala, JavaScript, Java since Java 8, Swift, Kotlin, etc. Python now has some of this stuff too.

On the other hand, Go is notable for rejecting functional features and it is also growing in popularity.

Re: The Decade of Swift

#16
post #10

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 Sw…

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

#18
post #7

With Chris Lattner's move to Google and the state of Java it would interesting to see Google embrace Swift and add official support for it to Android.

This seems very unlikely to me.

They would need it to interoperate with their existing stack. They chose Kotlin where they reasonably could have chosen Swift and then worked to extend it to work with their existing stack.

Judging by what I would argue has been a lukewarm reception to Swift for Tensorflow, I think it would a very hard sell to convince people within Google to support Swift as a first-class language in the rest of their ecosystem.

They could for example start by adopting Swift for server-side programming for Google cloud and they seem to be putting no effort into that, at least public-facing effort.

Re: The Decade of Swift

#19
I can't really imagine Swift ever breaking out of Apple's walled garden. It's a pretty big garden, but the language concedes so much to Objective-C compatibility, it is hard to see any role for it where Objective-C never got a foothold.

Where am I wrong?

Re: The Decade of Swift

#20
post #10

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 Sw…

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/

Post reply on HN