However I really can't speak more highly of Kotlin, it's the most productive language I have used in large part because of access to the massive JVM ecosystem but with a modern, highly expressive language with amazing tooling (IntelliJ, YourKit, lightRecorder) and excellent performance.
Maybe you can do that with JS+HTML+CSS on the front end and NodeJS on the backend but Swift is such a nice language to work with.
Here is Vapor, a web framework made with Swift: https://vapor.codes
I wish I had understood this sooner. Thank you for your comment!
To my mind, the best learning resource is Tim Condon et. al.'s Server-Side Swift with Vapor (Ray Wenderlich publishing) but this book needs to be updated. Vapor 4 was released in April but the ORM (Fluent) and template engine (Leaf) weren't upgraded at the same time (June and November, respectively). The first half of the book was updated in September but everything else has been on hold waiting for the Leaf release. My progress through latter part of the book has been slow whilst I translate the examples and wrestle with the compiler errors brought on by my unamiliarity with the above concepts.
Tim C. is on the case and is very active and helpful on the forums so I expect the new version of his book will be finished quickly.
Anyway, to answer the question: Vapor should be nearly as productive as Rails once you become familiar with it. There's an offically supported MySQL driver for Fluent but no admin screen builder like you might find on Django, for example, so you'd have to put those together yourself.
For example, I need to be able connect to Firestore and listen continuously for new data and changes so I can fetch them, do some calculations and put the results back on Firestore. I am doing it with NodeJS because of the official support but I have to tell you that it melts my brain when I have to switch to NodeJS way of thinking and back again.
If I could have used Vapor, I would have been able to just use some the already implemented algorithms in the user facing App instead of re-implementing everything in again but this time in a NodeJS way.
It is about ecosystems, not languages.
Swift's ecosystem is Apple products. If you're not doing that, don't use Swift.
You will have to learn and use multiple languages and multiple ecosystems regardless because each ecosystem insists on using its own language and tools. So just use the most popular one for each - it will be the most polished with the fewest number of gotchas.
At this point, the clear winners for each ecosystem are Kotlin, Swift, Typescript, C# and C++ if you're doing games.
If you write a todo app on each platform, you'll realize you're using the same set of language features with different syntax - that should lessen the anxiety of learning a new language. Once you're free and nimble, you'd have to be nuts to choose anything but the right tool for the job or when in doubt, the most popular.
Traditionally for HTTP servers I carve off a URL prefix, e.g. /diagnostics/ or listen on a different port, and make handlers there to let me know how things are going. The downside is that I then have to protect those which collides with whatever other authentication is going on.
Moving that to a command console eliminates all those ways to screw up and let evil people into my diagnostic functions.
The command line parser package is trivial to use once you get the hang of it and generates acceptable "help" automatically, so you'll end up with a custom CLI of your diagnostic commands with a "help" function to remember them for essentially zero coding and maintenance effort.
Now I have to spend all day resisting the urge to weld this into my latest HTTP server to see how it goes.
Update: There is an example server in the Sources/NIOSSHServer directory of the repository. 5 files, about 500 lines total to implement a "bash" command executer and a remote port forwarder.
Update 2: 50 minutes in and I have an ssh server embedded in my server. Maybe. When I send a command it explodes my process with a Posix.close() to a bad file descriptor tripping a precondition check. So, maybe don't rush this to a live server.
I spent more time fighting Swift Argument Parser than the NIOSSH. Fundamentally, there is not a way to pass context down to a command that is run. Fine when you are a whole program reading its commands and everything is implicitly global, but if you have a bunch of SSH connections coming in then just getting the output to the right one needs context.
I'm not real happy with my solution, but its clean and it works. Figure two days to get a usable subsystem working.
I have a few more things to try to clean up my mess. If it works I'll tidy up the package and publish it.
The dev said it's basically because Swift Crypto API does not support email@example.com, which is a non-standard construction (compared to chacha20-ietf-poly1305).
Now I just need to dust it off, it's been sitting on that code-shelf over there for 2 years.
Edit: probably Gankra too. IIRC she had an internship at mozilla designing important parts of the Rust standard library then later went to work at Apple.
Nevertheless, I guess it's good sum types are making it into the mainstream.
Swift is miles ahead of Rust in terms of language usability and ergonomics.
As a very basic made-up example, the real value of named arguments is code like this:
FileManager.copy(from: path1, to: path2)
MyOwnFileManager.copyFileFrom(_ path1: String, to path2: String)
But you are correct that it started with ObjC. That doesn't make it a bad thing. It seems that Apple is starting to circle back.
I prefer the initial one that you posited. I'm pretty sure the Swift style guide suggests the way you mentioned, and not the ObjC way.
BTW: I deleted the post where I talk about where I saw this. It seems folks just want to argue, and that's not why I come here.
I guess whatever floats your boat. Personally, I enjoy not having to write functions like doStuff(true, true, true, false) or alternatively define types for every single boolean flag I want to have. Terseness is a non goal for Swift.
> And on the first half of the file there are a bunch of POD struct definitions with a few init functions.
I don't know how rust handles this but in swift, each POD struct has an implicit member wise constructor visible from the file it's defined. This is for encapsulation purposes, as its signature of course changes if you add fields to the struct.
Yeah that's not beautiful, but most of my code is rather
doStuff(foo, bar, baz)
where foo, bar and baz are descriptive variable names.
I agree that it's hard to understand with literals, but in the rare cases you need such flags you can either have a config struct or use the builder pattern.
Also, nowadays you can set up vscode to use the rust-analyzer LSP plugin, which shows you the types as well as the parameter names. But of course that doesn't work on Github and similar places.
IDK in general, the people who want named arguments outnumber the people who don't want them, at least in threads about the question, which obviously preselects the people who want them. Maybe eventually Rust will get them, no idea. But IMO that code shows how named arguments can make code more noisy than before.
> I don't know how rust handles this but in swift, each POD struct has an implicit member wise constructor visible from the file it's defined. This is for encapsulation purposes, as its signature of course changes if you add fields to the struct.
In Rust, POD structs can be constructed iff all their members are visible through the publicity system to the code that tries to construct them. If it's in a different crate, it's also important whether there is a #[non_exhaustive] attribute on the struct declaration or not.
But descriptive variable names should describe what those variables ARE, not how they are going to be passed to a function.
So, does copy(tempFile, databaseFile) copy the temporary file over the database file, or vice versa?
Ergonomics is things like the optional handling syntax in Swift, or named arguments.
1. Swift abstract away lot of memory management by defaulting to thread safe reference counting. In Rust you are free to use stack, heap and wide range of other option. Rust has a freedom here. ARC is basically a garbage collection whatever apple say.
2. Rust pattern matching is novel. You can see match on csharp, php because its so good.
3. Rust is far better in concurrency world.
4. Cross Platform support is Meh in Swift. Its starting but its too far.
If you are writing ios app or anything for mac yes swift is ahead.
But in other field Rust is far ahead. See the link for fair comparison. I have used various PL in my life time from c, c++ , java, swift , rust etc. And I am not biased towards rust. But simply saying swift is miles ahead is totally unfair to me.
In your disagreement you are pointing out how you think Rust is more _advanced_ than Swift. But this goes into a tangential topic, that was not what the parent was pointing out.
In developer productivity and ergonomics Rust is not far away from C++, and Swift is more akin to Kotlin, C# and Java, but it feels a little better like Typescript or Dart.
I wonder, why, so many times, Rust folks (Why to get tied to a tech, i also don't get it) gets so hostile and arrogant about the language, and to be fair this is some of the reasons i keep a certain distance from it, and i can imagine that im not the only one.
It's honestly crossed over from being a meme (rewrite it in Rust) into becoming obnoxious. Obviously a small, vocal minority as always.
They are both forms of automatic memory management but that is about it.
There is nothing novel about pattern matching in rust, swift has pattern matching too, and both languages inherited it from Ocaml, and the ml family of languages in general.
Just because apple made a swift doesn't mean its design is better.
The topic here is that Swift developers made a release of an open source software and it is not if Swift is the best or if Rust is better. Why would you try to steer it in that direction?
It's like having your friend serving you his Lasagne that worked on and is pride of, then have someone in the group saying that Brussels sprouts is a better meal but we are going to eat this because most people don't care enough about their health or don't know better. Don't be that person if you want to be likeable.
* https://news.ycombinator.com/item?id=25158147 spends 530 characters on their past programming life and an evaluation of the Swift language, and only then ends the comment with "I'll definitely check this one out."
* https://news.ycombinator.com/item?id=25157942 mostly talks about the language as well instead of this ssh library. It's a bit more on topic though as it talks about swift on the server, which this library can belong to (but doesn't have to, the library also has a ssh client part). Still, way offtopic if you are strict.
* https://news.ycombinator.com/item?id=25158932 alright so this comment is actually about the SSH library. Only barely has any replies though. Apparently hn'ers don't like to talk about the ssh library.
* And there is my comment https://news.ycombinator.com/item?id=25158334 which as of now has the most discussion, but it's downvoted at a -4 score ATM.
I actually came to this thread where these responses were the top replies (except for the single one which is actually on-topic, it wasn't present yet). So I thought I'd add my own.
Also it's sad how nobody replied to the second part of my post. I think that employability is a clear benefit of Swift and Go over Rust. If I check indeed Germany for "Swift Software", I get 596 results. If I check "Go Software" I get 2463 jobs. Checking "Rust Software" gives me 131 results. A big difference.
Talking about Swift is not irrelevant as it is a prerequisite to use the software in question.
I guess If you have replied to someone asking if Swift or something else is worth learning, I would have upvoted you.
The way it is just feels spammy.