Hacker News new | ask | show | jobs
by codesternews 3476 days ago
I am iOS developer and I really wanted to say swift is headache and not a good language for Server development. I want to see how it goes but as far I know it is not flexible enough. I mean if you are building a production server you really do not want to think about language issues. Like dictionary is taking 4000ms to compile (yes it is true 4s) and compilation error message which has no link with what actual error or language syntax totally changed now you need to change million of lines of code to new syntax. It might be improved in future but for now I do not think it is time to swift as server language.

I really like the language but for using it on server development nah.

I need to wait for 10 minutes or more to compile my code. I am really frustated. I am solving for 2 days Xcode 8 issues beacause it compile slow and it is really frustating as a developer. It does not matter how I write code in a language but in swift 3 dictionaries are really mess and slow to compile and it's long way to go for swift.

It's just my personal opinion.

4 comments

Set your optimization level to -Onone & then manually set SWIFT_WHOLE_MODULE_OPTIMIZATION in user defined variables to YES. Your build times will improve greatly.

Xcode only lets you do WMO & optimizations on in the normal UX. Really bad that they don't expose this :/

Also to other people thinking about swift: don't. 200-100kloc and your build times become 5-20+ minutes. The conditional compiler is not very good either. And once your at that level of code, xcode spins it's indexer for a long time, autocomplete fails a lot and the debugger just doesn't work that well. Printing an object just spins for over a minute, and often it fails to even print the variable. Also configuring your project into many modules become painful with all the targets you have to manage.

Maybe in 4+ years when the language has matured enough and these issues start going away? And you have a build system that doesn't depend on large multimegabyte xml files that can't be written by a human. But for now, no.

It's good enough for a couple of developers doing contract apps although!

I don't think that's how whole module optimization works. From what I understand it slightly slows down compilation, but you end up with more performant apps. For this reason I think it's only used for Release builds (that's how I have it setup).

https://swift.org/blog/whole-module-optimizations/

can also recommend this approach at the moment: http://khanlou.com/2016/12/guarding-against-long-compiles/

This makes XCode warn you about functions with long compile times.

Wow, just what I needed! I posted a rant a few days ago here where I advocated for just this thing!
Thanks!! Done already all this. On developer forums apple developers said they messed with the Xcode so wating for next Xcode release. That's what I am talking about :( https://forums.developer.apple.com/thread/62737
> I really wanted to say swift is headache and not a good language for Server development.

Followed by a long description about how the ecosystem is young, and not mature enough for server production dev. I don't see how it justify that the language is not good for Server development (it may or may not be, I don't know, but I don't see any point about this in your comment).

Your argument is not against Swift-the-language but Swift-the-environment.

Environments improve over time.

But as author is also talking about the environment and I know it will improve but if you in to this and you have large codebase than waiting 10 minutes (some times it take 20 minutes thanks to Xcode 8.2) for build compilation and with every new Xcode release and swift release things are getting change so fast that most of time it is very hard for production app quality. Also not all dependencies keeping up at that rate.

That said I really love the language but it's my opinion by looking other languages swift is not for server development and will not be successful. But that's my opinion.

How large is the codebase? I think this is usually due to type inference on dictionaries in some cases. Usually explicitly specifying the type fixes the build times.

There's a tool that will tell you how long each part of your program is taking to compile so you can find the source.

Interesting. Do you think Swift isn't as good a language as Objective-C? Or a headache in what way?
No Swift is great language and I did not like Objective-C. The headache in the sense compilation time and also shitty errors come and you do not know what that means.

It's type safe language but all the type safety comes with price and some time the code written is just sucks. Json parsing is one example of this. All the casting and all that really make code horrible.

In swift 3 they made all value types to Any and in iOS communicating between Cocoa frameworks become a really mess as all expect some objc type etc. Implicit conversion is also removed and now you have to cast String to NSString and I really mad about this my code now looks horrible huh....

String bridges to NSString, are you sure you need to cast?
I think String now is part of Any and NSString still is AnyObject. You need to cast, but the cast will always succeed.
Try Freddy, much less casting!