Learning Go. Does anyone actually like their type syntax? I mean, come on, `map[string]int`?
Discussion
?cid=2154d3d7e2pa2tbnk15lixpqcgxxy3rlwcb8z48uwnjfsbj0&ep=v1_gifs_search&rid=giphy.gif&ct=g
Or even better, `map[string][]map[string]int`. In typescript that would be `Record
No. Rust is better
rust is just C++ with a better build system than Cmake and an extra, super complicated syntax for memory management
isn't it?
There is not syntax for memory management. Memory is managed by the types themselves, in "unsafe" code, that is allowed to do pointer stuff. A String handles the heap allocations and frees in the drop method/destructor. Memory is no different to other resources, a File closes the file in it's drop method, a mutex guard unlocks in it's drop method, etc.
yes, i like it very much
you should be very careful messing with maps, you may not need maps
maps are not concurrent safe and iterate randomly
i built a key/value collection type, took me an afternoon, that does much of what a map does, but preserves field ordering
also, the reason why go's maps are so basic is because go doesn't force you to use any high level abstractions more complex than this map for your data types
if you need large tables, better to use a database like badger or leveldb
if you need proper ordering, you need to write code that unpacks the map into a slice before rendering it, or you can use a heap or other similar ordered complex data type, container/heap is where the priority queue heap implementation lives
main thing you are going to learn about go is that it's not easy to work with dynamic typed wire encodings like JSON this is why i've spent a lot of time on making sure my in-development relay codebase has some clean and precise implementations that work with Nostr's json types