News for hackers. Stuff that matters.
Re:Nimony: A New Compiler for Nim by PMunch on Tuesday November 17, 2026 @06:11AM (#50529934)
Nim is very strict about types, which is probably what you remember. Things that are typically expressed as a dictionary/object in JavaScript and Python are better represented as a fully typed tree of objects in Nim. The language of course supports the data-structure dictionary/hashmap/table (called Table in Nim) which is "anything hashable" -> "any type" lookup. This is what's used for things like `myTable["hello"] = 5` for storing the number 5 for the key "hello". However because of the strict types you can't mix which types they map to without creating some sort of wrapper type that gives you the alternatives you're allowed to use. Many people reach for Nims JsonNode type to fill this gap for small collections of string/number/array/dictionary since it already is such a wrapper type.
Re:Nimony: A New Compiler for Nim by jeremyjh on Tuesday November 17, 2026 @08:07AM (#50530853)
I wonder if this is more palatable with first-class sumtypes/ADTs in Nim 3? Or is that already what JsonNode essentially was?
Re:Nimony: A New Compiler for Nim by xigoi on Tuesday November 17, 2026 @02:40PM (#50537039)
Sum types already existed in Nim 2, but Nimony makes them more convenient to use.
Re:Nimony: A New Compiler for Nim by klibertp on Tuesday November 17, 2026 @07:57PM (#50540481)
As others wrote, what makes it unpalatable for you is static typing. You simply cannot make working with arbitrary JSON as convenient in a statically typed language as in a dynamic language (like JS or Python). No matter what you do, in a static language you need to provide or recover/generate the full type information of anything before you can use it (unless the language or the runtime system offers an escape hatch: some kind of "dynamic" type (but that means the language is now gradually typed) or strong reflection capabilities - which Nim doesn't provide to my knowledge). On the other hand, Nim has macros, so typing your JSON payloads is as painless as it can possibly be in the presence of static types.

So it's not really Nim's characteristic to make working with arbitrary JSON (heterogeneous collections more generally) "unpalatable" - it's common to (almost) all statically typed languages. While Nim looks a lot like a scripting language, it really isn't. It can be used as one, and it's much better for that than C, but it's better used for apps and systems programming than for scripting, like all the other languages in its class (ie. Go, Crystal, OCaml; Rust and Java are also close).