5 ms·
Swift has some land mine issues where the compiler can hit snags handling certain snippets of code (e.g casting to/from Any/AnyObject, method overloading based
by mythz 12y ago
Swift has some land mine issues where the compiler can hit snags handling certain snippets of code (e.g casting to/from Any/AnyObject, method overloading based on constraints, etc) which if you have enough of them will segfault the compiler with something along the lines of "expression too complicated, break it down".
I've had to rewrite my approach a few times because of this to avoid certain coding techniques, but once I've rewritten to avoid them, Swift can happily compile my 7-8k LOC code-base in ~6s.
- epaga 12y agoIs there a list somewhere of Swift compiler issues to avoid? Seems like "avoiding certain coding techniques" is what is currently necessary until Apple gets back on top of things... One other example FWIW: having a largish array of Int arrays causes the compiler to either go into an endless loop or simply take too long, UNLESS the type of the array is specified. var data = [[1,2,3],[4,5,6], ... ] // > 20 elements -> compiler hangs as opposed to: var data:[[Int]] = [[1,2,3],[4,5,6], ... ] // compiles quickly
- mythz 12y agoFinding Swift really buggy atm - where XCode, Swift Compiler and SourceCode service routinely crashes multiple times a day for me. A lot of my time is spent sympathizing with the compiler and getting hit with hard fought lessons on what things to avoid - basically don't step too far outside the Swift Programming Guide. Apple's also glacially slow at responding to bug reports - I'm keenly waiting on the next Q/A release of XCode/Swift. There's a whole repo dedicated to Swift compiler crashes being maintained at: https://github.com/practicalswift/swift-compiler-crashes https://github.com/practicalswift/swift-compiler-crashes
- 00098001918291 12y agoIf only this had been a language that was dogfooded to the rest of the company, we might not be dealing with these beta-like issues.
- interpol_p 12y agoI think it was - the first app written in Swift was Apple's WWDC app. Released before they announced Swift. Though it wasn't a hugely complex app.
- brudgers 12y agoDogfooding usually implies that the technology is used in mainline business operations. It needs to be more than building a demo, it needs to provide sustenance.
- orta 12y agoThis isn't strictly true, if you not the wording around this it is quite cautious, "written with swift". There are only 4 swift objects in the app.
- CmonDev 12y agoAre you saying you are OK with compiler performance affecting the design (and possibly quality) of your code??
- seabee 12y agoNobody says you have to OK with something you mitigated against. I remember on several occasions fighting Visual C++ over code it bombed out on. Having a precompiled header scheme to make up for poor performance. Yes it sucks, but you don't do these things because you think it's acceptable, it's because the alternative is more painful.
- martingordon 12y agoI don't think I'm doing anything too fancy, but who knows? I probably have too many conversions to Objective-C objects that I used to workaround beta compiler issues that are probably fixed by now, but I haven't found a lot of guidance on what to avoid (I'm declaring types pretty much everywhere) and since the compiler isn't crashing, the list of compiler crashes doesn't really help. It's a shame because Swift is a neat language. But because Xcode doesn't support incremental compilation for Swift, a single character change causes the entire project to rebuild. Couple that with LLDB crashing because I'm including Objective-C frameworks (via Cocoapods), and the whole experience becomes absolutely terrible.