6 ms·
How's swift doing as a language? Is it being adopted by developers in a way Apple was hoping?
by neals 5y ago
How's swift doing as a language? Is it being adopted by developers in a way Apple was hoping?
- chunkyguy 5y ago> How's swift doing as a language? It's okay. It's just a programming language like million others. Gets the job done. > Is it being adopted by developers in a way Apple was hoping? Apple does not negotiate, when they make up their mind you have to either adopt or die.
- spyremeown 5y agoNo idea, but the compiler engineers are wizards.
- mrtksn 5y agoNot too much seems to be happening outside of Apple ecosystem but it should because it's brilliant. I don't want to write in any other language.
- lovelyviking 5y ago> it's brilliant can you share what you find 'brilliant' about it?
- mrtksn 5y agoI'm not an expert on programming languages and for me they are the format that I obey to express myself to the computer to make it do things, Therefore I won't be able to tell you what are the strong points and advantages of Swift over other alternatives. What I can tell you though, is that the language is easy to read thanks to the choices they made in the way the syntax is and the language has enough abstraction tools to let me keep the parts of the code that I'm not actively working on away. For example, I like to use the property wrappers and extensions to put away the code that I'm done working on. I also like that its strongly typed but also gives me enough wiggle room with generics. I like the concept of protocols to vaguely define the basics of some kind of data structure and be able to pass around different flavours of it as if I'm on a weakly typed language where functions can take whatever you throw at them. Another thing that I like about swift is that the toolset Apple provides. I used to do JavaScript as my main language but I got sick and tired of the amount of effort to keep the stack together. Endless number of tools that have many alternatives that do the same thing in a slightly different way, hours and days spent in configuring them is something that I don't want to go through anymore. With Swift and the tools that Apple provide(various frameworks and xCode) starting something new to thinker on is as simple as creating a new Word document. It reminds me of the PHP workflows a bit, where you type your code in a text fil, put it in a folder and see the results immediately. Essentially, I like the comfort of using Swift.
- cableshaft 5y agoProperty Wrappers seem pretty neat, I wasn't aware of that new feature. Thanks for mentioning it. https://www.swiftbysundell.com/articles/property-wrappers-in-swift/ https://www.swiftbysundell.com/articles/property-wrappers-in...
- Jtsummers 5y agoBecause it's a bit of a pet peeve of mine, what you term "strong" and "weak" are more typically called "static" and "dynamic" typing. They do not correspond to "strong" and "weak" as a general rule. Python, for instance, is "strongly" typed (try printing the result of `2+"3"` in its REPL) but also dynamically typed. Neither "strong" nor "weak" typing is well-defined, but the most consistent differentiator is about implicit conversions or casting. Like in Perl you would get "5" as a result of printing out that previous expression.
- mrtksn 5y agoThanks for the elaboration.
- Someone 5y ago“Endless number of tools that have many alternatives that do the same thing in a slightly different way” I think that is a risk that almost invariably comes with being open and popular. I saw the same thing with C# vs Java. In Java, you don’t have a logging API, you have a meta-logging API into which you can plug multiple logging libraries. Similarly, there used to be (maybe still are) zillion of viable options for parsing XML, json, different build systems, etc. That brings flexibility, but at the price of having to spend time picking the best tool and anxiety about the grass at the other side, maybe, being greener. Often, eventually, the dust settles and a clear winner emerges, but that’s not a given, and doesn’t help you when you have to make choices before the dust has settled. I don’t follow JavaScript closely, but I think it definitely still is in the “before the dust has settled” phase.
- interpol_p 5y agoNot the OP but someone who also finds Swift brilliant I really enjoy the value types — real structs with copy-on-write behaviour (internally). So there's a lot of freedom to model your application with a single source of truth that can be updated in a transactional way, diffed, unified, intersected, without worrying about any leftover state causing bugs Protocols and protocol extensions are very powerful. Allowing you to write a generic interface and then add explicit functionality to anything which adopts that interface in a very clear way In combination with pattern-matching enums which can store uniquely typed data with their cases, it makes it very easy to model complex systems in a readable, maintainable way The combination of all these things, plus powerful generics and a very thoughtfully designed set of foundation APIs, makes it very pleasurable to write and read Swift code The new async/await functionality also seems like it was considered for a long time. It manages to stop you from doing stupid things with threading at compile time by being conservative about how you can use structures concurrently
- secretsatan 5y agoI switched to almost pure swift for a new app after having worked with obj-c a couple of years ago. TBH, when I first encountered swift I hated it, mostly because I felt it was always nagging me about optionals coming from rather fast and loose obj-c code. I eventually embraced it and the new App greatly benefitted, hardly any bugs out in the wild compared to our other apps, we mostly just get crashes from Apple code. Code is reeadable and easy to understand (although there is still some terrible code in the app from when I was still getting my head around it, but it works fine). It has some frameworks and protocols I've started to use extensively, the codable protocol is especially useful for web interface, combine is coming on in leaps and bounds. I still don't trust SwiftUI, even Apple's demo projects don't always implement things correctly and don't display properly if you use the wrong device in the wrong orientation. So I still use IB (New swift developers don't like it, it is a pain and hard to use for apps that run on all devices in multiple orientations, but for what it is, I've used worse in my career)
- michaelbrave 5y agoMixed - it's my personal favorite language to work with but it's like it's torn between two sides. First it's finally working on most systems, Windows & Linux and even a few old versions of MacOS, probably some more niche systems too but those are the ones I know for sure. Vapor is still very good for back-end work and I've heard a lot of success stories for lowering costs due to less cycles being used so a lower power consumption. But even with all that Apple seems to be pushing their own direction with SwiftUI, their support for other operating systems is minimal, support for editors other than Xcode, and having separate frameworks like Metal aren't helping either. In short I want to use swift for everything, as a Rust or C++ replacement, and I don't think I'm alone in this, but it will never have the momentum within Apple to actually get out of the Apple stratosphere enough to be it's own thing. This is probably exactly what they want, but it's a shame.
- hedgehog 5y agoI actually initially tried Rust because perversely it had wider macOS support than Swift. Swift started dropping Mojave support as soon as Catalina shipped. Swift is great as long as what you're doing fits neatly into Apple's current product priorities otherwise you're on your own.
- RandallBrown 5y agoI would bet that near 100% of iOS and macOS developers are using swift in some way so I think it's been very successful in their eyes. As for other platforms? There's work being done, but it's still not terribly useful since so many of the foundational frameworks are iOS and macOS only. (I'm unaware of any major projects doing server side swift for instance.)
- edge17 5y agoA lot of major iOS apps still use ObjC
- rimliu 5y agoBut how many of them are ObjC only at this point.
- RandallBrown 5y agoDefinitely, but how many actually use ZERO Swift? Saying you were Obj-C only made some sense a few years ago but I can't imagine many places are doing it any more.
- iainmerrick 5y agoAs a language, it’s quite nice but slow. Runtime speed is so-so, compilation speed is awful. I really wish it were actually swift! Feels very similar to Kotlin on the whole. It’s definitely being adopted by Mac and iOS developers for apps (although the only real alternative is Objective-C). And there are a few build tools and the like using Swift -- many with installation instructions for Linux! -- although I think on a very small scale compared to C/C++, Rust, Go, Java and Node. If anyone’s seriously using Swift on the server, I’d be surprised (but interested to hear about it).
- jamil7 5y ago> compilation speed is awful This really needs to be addressed, it's one of the few real bummers about the language which I otherwise love and use everyday. I'm also concerned the way more and more language features (mostly for library and framework authors) are getting piled on, it can't help compilation speed.
- iainmerrick 5y agoStrongly agreed. Swift isn't alone, the Kotlin compiler is very slow too (and yoked to Gradle, which is itself very slow). Rust as well. Maybe the Go authors are onto something after all. When Go first came out, I thought their emphasis on compilation speed was just an overreaction to C++, because a) C compiles plenty fast, b) C++ is only slow if you overuse templates, c) other languages compile faster than C++, right? and d) Moore's law! But a) hardly anyone uses C now, b) everyone overuses C++ templates, c) other languages compile way slower than C++, d) compilers got slower faster than computers got faster. Even now, Xcode can feel very slick and fast in a tightly-written C/C++/Obj-C project.
- bartvk 5y agoIt's been adopted like crazy. I can't imagine new projects being started in Objective-C. Certainly, I'd never join such a project, for sure. I think the rapid adoption is because you can basically just inherit any Objective-C class in Swift, and then add functionality. And that's just one way of mixing Swift into an existing code base, there are others.
- PostThisTooFast 5y agoI like Swift, and it's the only thing worth considering for Apple development. Sadly, Google continues spewing language-of-the-week and hasn't even standardized on Kotlin... the language of its own primary platform. It keeps sharting out languages like Dart, Go, whatever. Swift is open-source. If you're not going to use C++ or Javascript, just use Swift and save us all a big pain in the ass. "You're posting too fast. Please slow down. Thanks." HEY, WHY DON'T YOU PISS OFF, HACKER NEWS? Why do you let users invoke a comment editor if they're "posting too fast," and only tell them when THEY'RE DONE? You DELIBERATELY WASTE USERS' TIME, assholes. WHY? ANSWER THE QUESTION: WHY?