Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I would not pick Rust over C#/Go/Python for web development.


Go? 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?


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


Thats a fairly big restriction though and a sign of type system that is not flexible enough.


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


Thing is in Rust you can do both


Not proficient in Go but I see an interface{} somewhere in the answer.


At which point type safety goes out the window


Try percy. It's still in alpha, but it awesome.


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




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: