4 ms·
I would not pick Rust over C#/Go/Python for web development.
by sanxiyn 8y ago
I would not pick Rust over C#/Go/Python for web development.
- wild_preference 8y agoI think "web development" is too generic to say something like that. I'd consider a small data processing service, maybe a service invoked from the web server you're already using in Ruby or whatever, is a perfectly pleasant place to use Rust, and often likely to be 1:1 identical to those other languages.
- v_lisivka 8y agoTry percy. It's still in alpha, but it awesome.
- qaq 8y agoGo? Here's Rust enum for working with JSON enum Value { Null, Bool(bool), Number(Number), String(String), Array(Vec<Value>), Object(Map<String, Value>), } How would this look in Go?
- happysanta 8y agoNot proficient in Go but I see an interface{} somewhere in the answer.
- qaq 8y agoAt which point type safety goes out the window
- Matthias247 8y agothrowing annotations on structs and letting the library generate suitable serializers and deserializers works reasonably well in Go, as long as the JSON is not too unstructured. The same applies for Java and C# (here the JSON libs might be even better). And obviously for Rust too via serde.
- qaq 8y agoThats a fairly big restriction though and a sign of type system that is not flexible enough.
- Matthias247 8y agoMaybe. However your representation isn't without drawbacks either: All fields are typed by strings, and are thereby not strongly typed. And each additional level (in an array or object) requires mandatory boxing and allocations. The codegen variants on pure structs don't have this drawbacks. I would say your representation is favorable when someone wants to work with arbitrary JSON in a flexible fashion. However if schemas and code generators are available, I would prefer to use those.
- qaq 8y agoThing is in Rust you can do both