news.ycombinator.com
Swift: Challenges and Opportunity for Language and Compiler Research [pdf]
Excerpt
As for compilation time, you may think it's just a matter of optimisation. But the problem is that until those optimisation arrive, you can't rely too much on type inference (main source of slowdowns), which diminishes a lot the beauty of the code. Now that was for client side. Server side probably adds its share of issues. … Swift 2.2 + Xcode 7 wasn't great, but it was livable. Constraint SourceKit crashes makes Xcode essentially a text editor and not a good one. All indexing, highlighting essentially all IDE functionally lost. This is the worst development experience that I've seen in 20+ years as a developer. … I think the consensus is that we need nothing but bug fixes on the core stuff (Xcode, SourceKit, etc). ... But the compiler crashes and sourcekit instability are just breathtaking (even in 3.0+). I'm surprised I haven't seen this get more attention. I'd (somewhat) expected something like this for the first few releases, but two years in I'm starting to think the team bit off more than they can chew with the type system. ... The latter category is especially nasty, and SourceKit won't inform you of this, except perhaps to crash. Oh, and that dumb bar in Xcode. You can compile all the Swift source in your target successfully but have SourceKit choke on your build configuration. Accidentally introduce a duplicate set of headers in HEADER_SEARCH_PATHS? Degraded performance, and at worse, the compiler crashes everytime you edit text and SourceKit invokes the compiler. In cases like this the SOURCEKIT_LOGGING environment variable is your friend. Have fun combing through those logs to tease out what build option you set is causing your issue. … If these sorts of totally-indecisive deprecations were rare then you could overlook them, as otherwise Swift is a rather nice language. But they're everywhere. Even in trivial examples intended for beginners line after line of code gets the yellow deprecation warnings. "What does deprecated mean" was literally one of the first questions my girl asked me as she started out learning programming, which is ludicrous. You shouldn't be encountering deprecation warnings over and over when targeting a brand new platform using a teaching course barely a year old. … You didn't specify anything that says Swift isn't a "halfway decent programming language." ... It suffers from similar problems to Scala, where it tries to blend OO concepts in with FP concepts. Variance is where this flares up terribly because it doesn't provide any explicit support for covariance or contravariance. You end up with invariance and subtyping in a bunch of places which is not a nice combination. … Simple things like "a + b +...+ n" cause compile times to balloon exponentially, which means for arrays you end up refactoring concatenation of immutable arrays into a mutable array you call appendContentsOf on a bunch of times. SourceKit on the surface sounds great, but in truth it's a simple text parser that doesn't understand type aliases for example. The compiler _really_ struggles with anything beyond very simple generics, first the type inference starts to fail and then it'll refuse to compile until you break the code apart and add type ascriptions. The compile errors are often absolute nonsense, pointing nowhere near the actual errors or are like the Magic 8-ball coming up "ask again later". … As for compilation time, you may think it's just a matter of optimisation. But the problem is that until those optimisation arrive, you can't rely too much on type inference (main source of slowdowns), which diminishes a lot the beauty of the code. Now that was for client side. Server side probably adds its share of issues.
Related Pain Points
Compile time explosion with type inference
7Swift's type inference system causes exponential compile time slowdowns, particularly with string concatenation, array operations, and generic code. Developers are forced to abandon type inference and add explicit type annotations to avoid unacceptable build times, diminishing code elegance.
Limited generics support and type inference failures
7Swift's compiler struggles with complex generics beyond simple cases. Type inference fails on complex generic code, forcing developers to add explicit type ascriptions throughout. The compiler may refuse to compile until code is broken apart and rewritten.
Build configuration issues cause SourceKit crashes
7Accidental misconfigurations in build settings (e.g., duplicate HEADER_SEARCH_PATHS) don't prevent compilation but cause SourceKit to crash on every text edit. Debugging requires manual inspection of SOURCEKIT_LOGGING output.
Poor interoperability with third-party tools and IDEs
6Due to frequent Swift updates, it is difficult to find appropriate tooling for specific tasks. Xcode lacks proper support for Swift with widespread issues in syntax highlighting, autocomplete, refactoring tools, and compilation.
Poor compiler error messages and diagnostics
6Swift compiler errors are often cryptic, unhelpful, and point to incorrect locations in code. The error messages resemble a 'Magic 8-ball' with little actual guidance on what's wrong, making debugging difficult and time-consuming.
Lack of abstract classes complicates inheritance patterns
5Swift lacks abstract classes, requiring developers to decompose into concrete base classes and protocols. This leads to complicated generic signatures, requires significant experimentation, and can cause compiler crashes.
Excessive deprecation warnings in new code
4Swift projects encounter numerous deprecation warnings even in basic, newly-written code and teaching examples. This creates confusion for beginners and clutters the development experience with outdated APIs.