VSCode Swift 1.0
forums.swift.org
forums.swift.org
This means that, unless I'm missing something, you can't open your existing project in VSCode like you could with AppCode.
Overall, I'm unhappy with the tooling around Swift. The compiler is slow, the formatters and linters are worse than in the javascript-ecosystem, and since AppCode is sunset, there's only a single supported IDE which I dislike. I frequently run into issues where the compiler won't give me a useful error message until I simplify my code, and the SwiftUI previews don't seem to work at all.
[1]: https://github.com/swift-server/vscode-swift/issues/128#issu...
I've never met anyone who actually does this. JetBrains is even discontinuing AppCode, which as far as I know was the only real alternative IDE (and it had a lot of holes in its functionality).
Xcode lacks decent refactoring tools but otherwise it's a perfectly fine IDE, and has some really powerful debugging abilities. Don't get me wrong, I don't think Apple is giving it the attention it deserves, but in my experience most people hate it just because it isn't IntelliJ or VSCode.
Another thing thats highly annoying is that compile errors don't get properly cleared on builds, so if there are multiple errors, it might just be that one of them is a real error, but the others are stale.
Lately I've been working with Swift Packages, and now restarting Xcode many times a day is part of my workflow - otherwise compile errors persist.
Ive been in iOS for a decade now, so mostly I don't get hung up one these issues, I know how to clean the "derived data" folder, I know how to jiggle it "just so" to get it to do what I want. But still its frustrating that the most important tool in my job is doomed to be moderately broken forever.
It might be a "grass is greener" scenario, but whenever I hop to IntelliJ, I don't encounter any of these kinds of problems.
Oh, and BTW, if you want to check Xcode out for yourself and have trouble downloading it, its not you - Xcode is like 20GB big. I guess you need lots of space for the world's most broken syntax highlighting algorithm...
Oh wow, I opened it about once to compile something, had this issue and had to clear a bunch of caches. I thought I was holding it wrong. Signing to get an ios-on-mac app to run was also a hellish experience; I think I ended up using the iPad emulator to preview the thing.
It felt a lot like they don't want you to develop things and I guess that fits with their general perceived disdain for general purpose computing (download the big-corp SaaS app from the App Store and shut up).
Here’s my reasons:
- Xcode has many failure cases for refactoring or is slow at finding symbols across extensions. Jetbrains handled it effortlessly. God forbid something crosses a target boundary.
- Xcode is really terrible for multi language projects. If you’re sticking to ObjC and Swift, it’s fine, but the C++ support is really poor. If you need to throw in Python or anything else, good luck. Jetbrains handle multi language super well.
- extensibility is a big deal. Xcode isn’t extensible (well only in a very limited way) and there’s many plug-ins that I either use or create for myself to speed up my work.
If Xcode supported LSPs, it would honestly change the equation greatly. But today myself, and several other devs I know, edit outside Xcode and build via the command line tools instead.
C++ official support in OS frameworks relates to IO and Driver Kit, LLVM and Metal Shading Language.
Whatever works for Objective-C also works for C.
What you leave behind though are any of the interactive bits like live previews, storyboards, all the core data utilities.
* refactoring functions/methods: adding and removing parameters, renaming parameters, etc.
* safe-deleting symbols
* advanced search tools. Not just "find selected symbol in workspace", but "find places where this variable is being written to"
Also, the refactoring tools that Xcode does include are very unreliable. Even simple renaming will often fail, even on small projects, or will mistakenly rename unrelated symbols.
It was always a struggle for JetBrains to keep up with Apple dropping new stuff with no notice though, and I can’t remember when I last tried AppCode
If by many, you mean less than 1%, then yes. :)
Swift on server has been usable for a while now too.
I think the next big bottleneck on popularity will be tooling, and a solid VS Code extension is a small step forward in addressing that issue.
As someone who’s been using Swift for years on iOS/macOS, I’d love to use it for desktop development on Windows and Linux. I think the language is well suited for that purpose, and it strikes a nice balance between safety, speed, features, ease of writing, and clean syntax which isn’t matched by too many other languages.
The traditional cross platform approach is to write it in JS and use the native UI framework API, which works but its not native anywhere and you have to write JS.
So instead of doing that, you can start with Apple platforms and port to the other platform where porting would mean just UI and device specific API implementation as the Swift can be portable. You wouldn't be trying to build native UI with Swift but you would use the Swift code as a service which handles everything except the UI where the UI implementation will communicate with your Swift code.
The advantages are:
1) Working with Swift, which is pleasant to work with.
2) Apple's all platforms are on the same architecture and as a result, running your code for mobile on your dev machine works at full speed. This means, even the cheapest Apple Silicon device provides great performance on your workflow. No more sluggish emulators.
3) Preserve the data structures across all platforms and these data structures are not JS data structures. You have integers for example :). Categories of bugs and work to make things fit vanish.
The several times I've tried to do anything with it, I just gave up and found an alternative. My guess is that if you've been using Apple tools for years, then it makes sense, but to me it's indecipherable. The menu options don't seem to match with the GUI, resource views don't seem to match the files, random panels appear with unnecessary information, resources are needed for unclear reasons and more.
It's all very Apple, but in the worst way possible. It's like the IDE version of AppleScript - seemingly useable but based on a logic which totally escapes me.
It’s just “dnf install swift” and you’re all set.
I would love to see more Swift adoption, I know at one point IBM was investing in it for server-side programming, but I think they’ve abandoned that.
It seems to be a nice sweet spot of relatively easy to code, expressive, powerful, memory safe, and performant.
I’d love to see like a gccSwift the way there’a a gccRust coming together. I think that would be really cool.
It also opens up the potential for development on non-Apple equipment if the CI can handle builds.
You can’t develop for iOS as their frameworks are as of now (this is changing, they’re rewriting Foundation) tied to macOS, so this doesn’t change much
* Smarter refactoring like "extract protocol"
* Detection of unused imports and dead code
Both things the original Visual Studio had over a decade ago.
I think the new generics system is finally making the language more usable for the typical scenarios I like to tackle with it. What still baffles me is that it's impossible to create protocols that have stuff like @Published in them. Massively decreases / complicates / uglifies reusability opportunities in ViewModels.
Link 2: It has release notes with no new information.
Link 3: Available here:
https://marketplace.visualstudio.com/items?itemName=sswg.swi...
One of the opinions is that it values expressiveness, and having multiple ways to do things that means you can choose a nice way to express each line, rather than always being forced to write it the same way.
This is a trade-off. To use `guard` as an example, sometimes it may be clearer to use a guard, and sometimes it may not. Swift has chosen to provide both options, at the cost of users needing to learn both.
I think it developed a negative reputation for the fact that the first few iterations did have a lot of breaking changes and added a lot of features. This made sense to me, the first version was somewhat of an MVP and it needed plenty of work still, but the language is relatively mature now and has stabilised significantly in recent years.
The compiler isn't generally that slow overall, but there are performance edge cases where complex type-checking can take far longer than other things. If you're having problems with speed, I'd recommend profiling your build, it's possible there are a handful of functions that are taking most of the build time.
There are at least two major problems with this kind of PL design approach: 1.) when you work on a large codebase from multiple contributors, all the possible combinations of the available syntax and standard library calls will eventually get used, making your brain frustrate quickly when reading code written by others, and 2.) when you interview for a new job, all the possible combinations of the available syntax and standard library calls will eventually be asked about by interviewers, making you look and feel like an incompetent programmer.
I have to agree with the OP - Swift seems to be an unreasonably bloated PL. Unless one plans to work only with Swift all the time, learning all there is to learn about Swift on the way, it might be easier to just use Rust or Go.
I wouldn't agree, I feel Swift has significantly more surface area than Rust.
But even syntax and standard libraries aside, I think that Rust is significantly more "explicit", "consistent" and "predictable" than Swift. I consider those to be very important qualities in a PL. Maybe that's why Rust was easier to learn and memorize than Swift (with the exception of the Rust borrow checker and lifetime annotations that indeed have to be well understood to be even usable).
But it might be just me.
Where I do think Swift has a lot of noise though is @attributes. There’s just so many attributes to learn, especially if you happen to do SwiftUI or ObjC interop. Though rust has the same issue , it’s just there’s no ubiquitous UI lib like SwiftUI. I imagine it would have the same if it did.
How does one do that? I hit this problem a lot. (I’ve since learned to use lots of explicit casts to make it less bad.)
OTHER_SWIFT_FLAGS = -Xfrontend -debug-time-expression-type-checking -Xfrontend -debug-time-function-bodies
There's also this great WWDC session on build parallelization:
More languages need a guard. It’s a really great control flow operator to flatten your code. Rust added `let else` last year that does the same and it does wonders to clean up code.
There are things I dislike about Swift , like lack of explicit namespace organization (rust mod or c++ namespace keywords, and the enum trick does not count) as well as the ability to drop extensions anywhere (which leads to a lot of stream of consciousness programming). However I don’t think I’d really consider it ugly.
What languages are you coming from and what else do you not like about Swift?
The SwiftUI integration doesn’t materially change the language much. It’s based on passing in blocks as parameters and has been a norm for obj-c as well (effectively how everyone does completion handlers).
But I think that’s why language beauty is in the eye of the beholder. To me, Swift allows flatter/cleaner code while defensively programming with lower branching and higher ergonomics. That’s beauty. That’s why guard is so nice. But I can see how it might be off putting if you’re coming from other PL paradigms.
I think a lot of it comes down to whether people want simple syntax vs simple code. C for example is simple syntax but rarely ever simple code , Swift and rust are more complex syntax but much simpler code.
Might just be what you're used to, but I find languages without named parameters annoying, particularly when I'm reading code I'm not my own. They do a lot to disambiguate and make reading unfamiliar code much smoother.
I recognize you prefer smaller languages but I’d like to make a case for guards usefulness.
Guard is great because it’s a combined early return and assignment. Imho if you have a language with optionals, it’s a required pattern to have, or you end up with lots of conditional unwraps and nested blocks, or lots of placeholder variables that you might accidentally use in your code later causing safety or memory access issues .
Take the following code
if let foo = Some(optional) {yourLogicHere} else {return}
That’s one level of nesting.
Swift is nice enough to elide the Some matching so you’d just have
if let foo = optional {yourLogicHere} else {return}
Still one level of nesting but a little cleaner.
Now if you have a language based around safety, like Rust or Swift, a lot of functions return optionals. So you’ll keep nesting code in your checks for safety
Now take a guard.
guard let foo = optional else { return }
yourLogicHere
That’s one level of unnesting removed , and that compounds.
Better yet, you can chain them
guard let foo = optional, let spam = foo.lookup() else {return}
The equivalent in C like languages would be
type foo; if (!getOptional(&foo) return;
Now either you early return in the case of the optional failing or you nest. Nesting gets repetitive and deep.
Or you unnest like I have and have that foo sticking around un-initialized, potentially causing issues of use later.
Guard simultaneously removes both conundrums and makes your code both neater and safer.
It might seem like a quality of life feature to some, to me however it's an essential feature of swift and one of the better ones.