Live data from Hacker News

Building a Production Server Swift App

realm.io

81–90 of 91 posts

Re: Building a Production Server Swift App

#81
post #22

Is there a reason to use Swift over Rust?

As always, it depends.

For the use-case here, on a server, I think the answer is currently no. We're writing our back-end in Rust, but tried Swift first (fewer languages in the stack!), but there were just too many gotchas.

Personally, given the option, I prefer Rust over Swift. I've written a decent, if not huge, amount of both (notable, I wrote an Avro-to-Swift code generator in Rust), but written more Rust, so take this with a grain of salt.

I've found that Swift's generics have some edge cases that cause problems; there's some rough edges around build that are better in Rust; dependencies are much easier in Rust; and I like Rust's traits over Swift's protocols. That said, protocols in Swift are very cool and flexible, and I think Swift-the-language is very well designed. And of course, for macOS UI or iOS development, I'd go with Swift for the obvious reasons.

Re: Building a Production Server Swift App

#82
post #54
post #51

Earlier quoted context omitted.

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 eith…

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!

Re: Building a Production Server Swift App

#83

Earlier quoted context omitted.

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 i…

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.

Re: Building a Production Server Swift App

#84

Earlier quoted context omitted.

Am I missing a joke here? Interface builder, xibs and storyboards are very useful tools for even extremely large projects. Makes building and maintaining the UI extremely easy. The idea that because a tool is easy to use is somehow indicative of the skill of the person using the tool, is completely bogus. Interface builder has a lot of advanced features for setting up complicated UI. You could quite easily argue the…

I'll chime in, having done IOS apps for many years now...I have fully given up on Interface Builder and Storyboards. I build all my UI in code and find it works MUCH better and I spend much less time fighting with the UI. I used to spend half my time fighting with interface builder to get the layout right. Move one element that something else is constrained too...f' your everything. Oh, and setting up constraints in…

Your inability to set up constraints in IB is just that: your inability. I get very complex things done including animations in IB.

The time gained by not having to restart the app every time you tweak the UI is immense.

I generally use storyboards to set up navigation, but depending on the project I'll do the majority in code (lots of similar screens) or do every screen by hand with some common controls in code that render in IB when every screen is really different.

I am no too dogmatic about it, I will touch the subject when interviewing people but I am more interested in a balanced view than rabid hatred for either method.

Re: Building a Production Server Swift App

#85
post #8

Its cool that you can run Swift on the server, but that sure does seem like a lot of hoops to jump through, coupled with equally many gotchas. No threading on Linux, NSUnimplemented all the time, no built in random, poorly implemented foundation types, etc. seem like a lot to deal with. It seems a more developed language/runtime (e.g. C#/F#/VB .NET or Java 8) would do a lot better with these specific requirements (ty…

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…

> 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).

Re: Building a Production Server Swift App

#87
post #2

butwhy.gif i get that isomorphism is very helpful long term for larger code bases, and being able to share libraries between your ios and server/backend would be very awesome, but at what cost? there are proven server ecosystems that are going to be much less "innovation token" laiden than swift, surely?

He seems to be a pretty happy iOS developer. He likes Swift as a language (and I must say having used it in frontend dev it does have some very nice things many other languages often used for server-side development don't come with), and he loves XCode as an IDE. If for their personal use-case it does the job and isn't missing major libraries or so, I don't think why such an endeavour shouldn't be supported? I don't…

> Compiles to binary which could bring benefits depending on your needs (compared to JS, Java, Scala..)

While its not there _yet_, JEP 295: Ahead-of-Time Compilation ( http://openjdk.java.net/jeps/295 ) is active, it was just updated last week, is targeted and a priority 1 item. I have reasonable confidence that it will get there in the near future.

See also: JVMLS 2015 - Java Goes AOT https://www.youtube.com/watch?v=Xybzyv8qbOc

Re: Building a Production Server Swift App

#88
post #8

Its cool that you can run Swift on the server, but that sure does seem like a lot of hoops to jump through, coupled with equally many gotchas. No threading on Linux, NSUnimplemented all the time, no built in random, poorly implemented foundation types, etc. seem like a lot to deal with. It seems a more developed language/runtime (e.g. C#/F#/VB .NET or Java 8) would do a lot better with these specific requirements (ty…

Using C#, F# or any .NET language for cross-platform server software would also be a bizarre choice when there's Java or Go which are mature and simply work.

Re: Building a Production Server Swift App

#89
I still wonder why i would use Swift in the backend.

- elixir/erlang: fault tolerance, scalability, high complexity web apps

- Node: npm already has what you need, SSR for SPAs, JS is accessible for frontend guys (sort of)

- Golang: dead-easy microservices with CLI support, single file deployments, good performance, beginner level language makes Training/hiring easy

- Rust: excellent performance and great typesystem, ideal for writing Heavy core algorithms of products and use them as libs from other languages. Also all benefits of Go (except ease-of-learning).

- ...

- swift? Given that learning languages is not an issue, why should I prefer swift over other stuff? Are there real selling points?

Re: Building a Production Server Swift App

#90
post #25

Earlier quoted context omitted.

Swift runs at the speed of C. It could be several orders of magnitude faster than ruby or python or node.

Not necessarily true https://benchmarksgame.alioth.debian.org/u64q/compare.php?la... http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan...

Interesting. Swift runs circles around Python, except Regex-DNA. Problems with string manipulations?
Post reply on HN