5 ms·
Is this used outside the Apple eco-system much? I admit I haven't looked at Swift in 2 years or more. I find the omission of features like namespaces really st
by PopsiclePete 9y ago
Is this used outside the Apple eco-system much? I admit I haven't looked at Swift in 2 years or more.
I find the omission of features like namespaces really strange. I realize that namespaces don't jive with how Obj-C and Obj-C frameworks see the world and that Swift and Obj-C need to play together, but dealing with global namespace pollution and collisions in 2018 just seems...sad? They're hobbling the language in various ways due to NS*/Cocoa framework stuff.
Another weird omission is lack of any kind of concurrency story. Right now, this just seems like Apple's "me-too" version of Java/C#, but what does it actually bring to the table that would make it a worth-while investment if I'm not an iOS developer?
- kainosnoema 9y agoMost Swift code is divided nicely up into modules, which are compiled together and have their own namespace. https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html#//apple_ref/doc/uid/TP40014097-CH41-ID4 https://developer.apple.com/library/content/documentation/Sw...
- thefounder 9y agoFor some reasons most of the swift code I've seen doesn't use any namespace/prefix when it calls various functions from different "modules". It's used just like C "include"
- plorkyeran 9y agoYou only have to qualify what module something is from if it would otherwise be ambiguous.
- eunoia 9y ago> Another weird omission is lack of any kind of concurrency story Grand Central Dispatch (GCD or libdispatch) is generally the concurrency story on Darwin platforms. There has been an ongoing effort to port it to Linux. Not sure how complete that is but I linked the Github below. Swift on Linux still has a lot of rough edges in general. https://developer.apple.com/documentation/dispatch https://developer.apple.com/documentation/dispatch https://github.com/apple/swift-corelibs-libdispatch https://github.com/apple/swift-corelibs-libdispatch
- Cyberdog 9y agoIt's quite complete. Cross-platform Server-Side Swift systems like Kitura use it to do things like multi-threaded HTTP serving. I imagine if you tried hard enough you could find edge cases that work on macOS but not on Linux, but the Linux support is complete enough for everyday production work.
- eunoia 9y agoHey that's fantastic. It's admittedly been a while (6-12 months) since I've tried to run any non trivial Swift code on Linux.
- aplummer 9y agoA good read on the future of Swift concurrency is this from Chris Lattner, https://gist.github.com/lattner/31ed37682ef1576b16bca1432ea9f782 https://gist.github.com/lattner/31ed37682ef1576b16bca1432ea9.... I think currently still slated for Swift 5
- bsaul 9y agoThis is going to be very interesting to watch. They decided to add concurrency after having built an extraordinary complex language. Something people like rob pike thought would be very hard to do (and as both a go and a swift coder, i must say i tend to think he's probably got a point).
- gilgoomesh 9y agoThe concurrency model was planned before the first betas but has been delayed. The devs always knew how they wanted concurrency to work.
- bsaul 9y agoI didn't know that, but i'm not surprised because chris lattner clearly knows what he's doing. I'm still curious to see how it ends up integrating in a language that's been evolving a lot since its design. Saying that they managed to keep concurrency orthogonal to the rest of the language means Rob Pike was "wrong" (or at least what i understood from his point). However, after reading the conversations around the async proposal, it seems to me on the contrary that it is very tightly related to other parts (such as error throwing mechanism, GCD library and syntax in general). We'll see. I wish i didn't have the feeling swift core team is understaffed, because at least for iOS development it is really a joy to program with.
- mikeash 9y agoAn enum with no cases works pretty well as a namespace.
- PopsiclePete 9y agoI mean, sure, there are work-arounds I guess. Still weird to rely on work-arounds like this. Also, there are at least 4 different workarounds to this, so imagine working on a large code base where everyone has their preferred approach is...fun. Or it would have been fun in '98 or so, nowadays, for a brand new language - it's just sad.
- mikeash 9y agoI can think of three: enum, class, and struct. What’s the fourth? And what’s the big deal if you encounter some code that uses a different one?
- bsaul 9y agoWhy can't we have just one way of declaring and naming namespaces using something called... namespaces ? There are probably goos reasons for doing it this way, but it always feels weird having to declare all your namespace's types inside one of its member.
- mikeash 9y agoIf you allow nesting things inside types, then those act as namespaces, so you’ll always have multiple ways even if one of those ways is explicitly called “namespace.” I agree the language should have it, but it doesn’t seem like a particularly big deal.
- dahauns 9y agoUrgh. Why do stuff like this on a newly designed language? I mean, that sounds like javascript from ten years ago, and I didn't think anyone would like to go back there.
- chris_7 9y agoSwift has module-level namespaces and recommends lots of little modules.
- bsaul 9y agoin practice "lots of little modules" means something like 10 before your app start time starts to increase dangerously.
- briandear 9y agoThis is from 2016 -- Swift and the toolchain has gotten dramatically faster since then, but this is a comparison of server-side swift frameworks with Rails/Laravel/Spring/Nancy/etc: https://medium.com/@qutheory/server-side-swift-vs-the-other-guys-1-input-ec48d7be37b7 https://medium.com/@qutheory/server-side-swift-vs-the-other-... ...and part 2 here: https://medium.com/@qutheory/server-side-swift-vs-the-other-guys-2-speed-ca65b2f79505 https://medium.com/@qutheory/server-side-swift-vs-the-other-... And here's summer 2017 benchmarking/comparing server side Swift frameworks vs. Node: https://medium.com/@rymcol/updated-benchmarks-for-the-top-server-side-swift-frameworks-vs-node-js-9da4a0491eca https://medium.com/@rymcol/updated-benchmarks-for-the-top-se... Swift is a great language. Hello World in Java: public class HelloWorld { public static void main(String[] args) { // Prints "Hello, World" to the terminal window. System.out.println("Hello, World"); } } Hello World in Swift: print("Hello World") Obviously Hello World is trivial, however that comparison is indicative of the elegance -- it has power similar to C with ease of use similar to scripting languages.
- apple4ever 9y agoSwift is a terrible language. While the Hello World example seems to show its simplicity, when you actually need to write useful code it’s the opposite of simple. Unnecessary things like var, func, and the terribly named let clutter up the code. Then there is the backwards variable decoration. Oh and the random use of punctuation which makes reading confusing. In the end, Swift is terrible. If you are developing on MacOS, stick with Objective-C. It’s a much better language.
- hungerstrike 9y ago> what does it actually bring to the table that would make it a worth-while investment if I'm not an iOS developer? If you're not a Mac or iOS developer, then it doesn't bring anything right now. IMO, nobody is going to use this cross platform. Some people are trying to make it happen, but I doubt very much that it's going to be popular.
- Cyberdog 9y ago> If you're not a Mac or iOS developer, then it doesn't bring anything right now. Well… in the sense that it is Yet Another Programming Language, you're right in some regard. Nonetheless… > IMO, nobody is going to use this cross platform. Some people are trying to make it happen, but I doubt very much that it's going to be popular. Those "some people" include IBM, who are behind the Kitura framework and are also porting Swift to their heavy PowerPC iron. They seem to be trying to make it into sort of a next-generation Java without the terribleness. Yeah, it still maybe won't catch on as broadly as Java did, but it already has some enterprisey support outside of Apple. We'll see.
- hungerstrike 9y ago> Those "some people" include IBM... Never heard of them or used any of their software products. What other popular software have they brought to market?