5 ms·
Swift lines of code take about 10x more time to compile compared to obj-c too. I wished for obj-c when our project started passing the ~70 kloc mark.
by mahyarm 10y ago
Swift lines of code take about 10x more time to compile compared to obj-c too. I wished for obj-c when our project started passing the ~70 kloc mark.
- melling 10y agoI don't think it's 10x slower but it's definitely slower. If you have lots of "complicated" type inferencing the compiler does have problems: https://spin.atomicobject.com/2016/04/26/swift-long-compile-time/ https://spin.atomicobject.com/2016/04/26/swift-long-compile-... https://thatthinginswift.com/debug-long-compile-times-swift/ https://thatthinginswift.com/debug-long-compile-times-swift/
- favorited 10y agoRemember that the Swift compiler is way smarter than Objective-C's. Given how dynamic the language is compared to Swift, Objective-C can make very few decisions at compile-time (inlining, static binding, de-virtualization, strict type checking, etc.). It can definitely get faster than it is now, but it is always going to be doing much more work than an Objective-C compiler.
- mahyarm 10y agoMost of the compile time issues comes from type inference (exponential algo!), a really simple file based incremental compilation logic system and generic / struct specialization. If you could make a version of swift that turns off those two features and improves incremental compilation then it would probably be pretty good. Compile speeds go into the seconds when you try simple things like append 10 array variables with a + operator because of type inference!! Swift if a nice language otherwise. Most iOS devs & tooling are small teams creating projects that are around 30-50 kloc of code total. It works ok then, but when you get to 100kloc sizes, all of that fancy stuff is a relative waste in comparison to compile speed and xcode's indexer crashing and dying all the time. Backend server projects usually have codebases that are far larger than clients after a while, so I worry about using it in the backend like that.
- tspike 10y agoSome anecdata: I'm working on a 100k+ LOC Swift project and I can confirm, compilation is a dog and much of my day is spent getting myself back on track after waiting for compiles to finish. That said, I'm in love with the language and I'd rather wait for a compile to finish than have a server blow up because of a null pointer exception. After working on a large Python backend, it's been really nice having a compiler to watch my back.
- mahyarm 10y agoYou can get a lot of those same benefits with golang or java, but not have to suffer through bad tooling, slow compile speeds and get a GC.