7 ms·
Swift is really an underrated language mainly due to the Apple baggage. It hits the sweet spot between Rust and C++ due to it's sane design choices like structu
by FlyingSnake 3y ago
Swift is really an underrated language mainly due to the Apple baggage.
It hits the sweet spot between Rust and C++ due to it's sane design choices like structured concurrency or simple things like tagged enums, Result<T,E> etc.
I wish it gains more popularity outside Apple land and is discussed more like Zig or Rust.
- slekker 3y agoWasn't the performance and tooling poor in Linux and Windows? Has something changed there?
- saagarjha 3y agoThings are changing slowly.
- machinekob 3y agoLinux is very much ok at least x64 vscode is working faster than Mac version but ofc. It is not Xcode
- sgt 3y agoHaving written a bit of Swift code on macOS and a bit for iOS, I agree. This language has a very nice flow to it which should appeal to developers. It's hard to explain, but somehow the language is a joy to work in (Xcode also helps with that experience, of course). If I could use a minimized Swift on embedded, I'd be very happy. Right now I'm just doing C for ESP32 and that sort of thing.
- FlyingSnake 3y agoIf you can like it despite using Xcode, then it means the language is really good.
- WanderPanda 3y agoYeah I was wondering the same! I fondly remember coding swift almost 10 years ago but large part of it was the good integration with Xcode I believe. Seems like they have an OSS LSP so probably that experience translates to other IDEs nowadays
- FlyingSnake 3y ago> Coding swift almost 10 years ago. Umm… Swift was released 9 years ago
- southwesterly 3y agoWhich is ‘almost’ 10 years ago?
- sgt 3y agoI haven't had much problems with Xcode either, coding Swift. It feels (most of the time) very light weight and specialized. Cool UI as well.
- the_gipsy 3y agoThat's never gonna happen.
- graemep 3y agoIt looks like a nice language but my concern would be Apple might decide not to support it on other platforms at some point. Just too dependant in a single company.
- Razengan 3y agoIt’s literally open source bruh.
- pjmlp 3y agoA language is an ecosystem, not only a CLI compiler.
- jocaal 3y agoIt scares me how many people don't realize this. A language is only as good as the things it allows you to build. Swift can be a great language from a PLT perspective, but it is pretty much only good at making apple UI's. Anything else and you are making some important compromises you might not be aware of.
- filleduchaos 3y agoThere are lots of other things Swift is good at. What important compromises are being made that aren't "libraries may not exist", which is true of any of the equally niche languages that get a lot more love because they aren't associated with Apple? Even the severely limited ecosystem is mitigated by the language having excellent C and decent-enough C++ interop.
- pjmlp 3y agoThat theory works well in vacum, not when there are languages with similar features and mature ecosystems to chose from. Microsoft is discovering how hard it is to take .NET outside Windows, the fierce competition of UNIX first programming language ecosystems, and Apple is not doing with Swift half as much as Microsoft is trying to.
- BoxOfRain 3y agoYeah I played around with it a bit and I really like it, but I've never really had a reason to use it professionally since I'm mostly targetting Linux and as you say it's definitely seen as being a bit exclusive to Apple land. Can't complain though my current daily driver is Scala and that's also a fantastic language to work with.
- hardwaresofton 3y agoCould you give some examples on where you feel Swift shines compared to Rust? I quite like Rust and it’s associated tooling and type system.
- filleduchaos 3y agoIn my experience it has a solid 90+% of the semantic expressiveness - ADTs, advanced pattern matching, if statements and similar being expressions, traits (split into "protocols" and "extensions" in Swift), automatic reference counting, a well-defined ownership model (albeit not quite as strict as Rust's), constructs to prevent data races, etc. It lacks things like explicit control over lifetimes, and also defaults to copy-on-write rather than to move semantics - that isn't unsafe, but it does lead to beginners writing programs that compile fine but behave in a way that's surprising to them. It also doesn't expose threads directly (similar to Go only having goroutines), but the concurrency model is quite nice to use. The language is obviously opinionated about its async runtime (Grand Central Dispatch, which is also available on Windows and Linux) so you don't have to wrangle with that yourself though of course it loses the power and flexibility of bringing your own. On the flip side, Swift provides a lot of syntactic sugar that makes it feel faster/smoother to engage with than Rust. For example, enum literals don't have to specify the enum's name wherever their type can be inferred by the compiler. So e.g. when you are pattern matching on an enum value, the match arm `MyEnum::Red => {}` in Rust would just be `case .Red:` in Swift. It isn't much on its own, but each tiny QoL thing like this adds up.
- jwells89 3y agoSwift’s syntax I think also makes it more approachable for people coming from other languages. Rust by contrast is rather intimidating looking for anybody without a background in C++.
- hardwaresofton 3y agoThanks for the feedback here -- this definitely make sense. Interested in the copy-on-write vs move semantics... I'm so used to it now that I almost prefer the harder/more manual control/checking that Rust provides, but I definitely see the ergonomics of going another way. I find Rust a bit easier for me to read, quite preference-driven as I prefer snake_case to camelCase but that's a tiny thing. And weirdly enough I think I actually prefer `MyEnum::Red => {}`, but maybe that's just stockholm syndrome. Excited to give Swift a try sometime soon.
- Redoubts 3y agoHonestly I wish I could use it more for boring back end business logic, too.
- pharaohgeek 3y agoCouldn't agree more! I find it to be a very elegant language and a real treat to program in. I do mostly Java for work, and wish Swift had the open source ecosystem that Java has. There are so many support libraries and frameworks in the Java world that make it easy to develop complex applications. I wish Swift could say the same.
- deleted 3y ago[deleted]