4 ms·
What's the problem? People will just use libraries. Why does it need to be part of the base language? Seems like that made C++ quite a mess in fact, while NPM-l
by guerrilla 4y ago
What's the problem? People will just use libraries. Why does it need to be part of the base language? Seems like that made C++ quite a mess in fact, while NPM-like ecosystems have done well.
- edflsafoiewq 4y ago> And the design of the Hare language doesn’t even allow me to provide that as a library. I have to fall down to code generation at best.
- sedeki 4y agoHow is it possible that the design of a language do not allow for external code/libraries?
- ayende 4y agoThe issue is _generic_ data structures, not external code. If I have to re-create a hash table for each scenario, I'll not invest the proper time to do so. So if I need a hash table to map inodes to strings and another to map strings to IP addresses, I'll need to create that anew each time. That means either writing a lot of code twice, or relying on manual code generation (which sucks for many reasons).
- sedeki 4y agoRight, I take my question back
- rootlocus 4y agoNo support for generics or custom allocators, combined with no desire to implement a package manager. The language author accepts that (1) Hare is just as limited as C and (2) C has no way of implementing a good hash map. > Recall that Hare is designed to be similar to C in terms of scope and goals. C also provides no general-purpose hash map, and little by way of other data structures (though some attempts exist, none of them good). So you're stuck using a crappy general-purpose hash map that you have to convince your linux distribution package managers to maintain.
- rootlocus 4y agoHere we go implementing Hare++!
- lifthrasiir 4y agoThe entire post is a reply to [1], which mentions the exact code the OP criticizes. Drew said "Hare doesn’t provide us with a generic hash map, but we were able to build one ourselves in just a few lines of code", but the OP demonstrates that hash map is incorrect. [1] https://harelang.org/blog/2021-03-26-high-level-data-structures/ https://harelang.org/blog/2021-03-26-high-level-data-structu...
- alxlaz 4y agoSo... people will just use libraries that have a correct implementation? Lots of C++ compilers shipped STL implementations with atrocious performance (and outright bugs) for like a decade. It's not like putting something in the standard library guarantees correctness or performance.
- masklinn 4y ago> So... people will just use libraries that have a correct implementation? The entire issue is that the language does not allow for that: like Go (pre 1.18) it does not have userland generics. And unlike Go it doesn't even have a builtin hashmap, only arrays and slices.
- alxlaz 4y agoC doesn't have userland generics or built-in hashmaps, and there are plenty of hash map implementations in libraries out there (glib, apr to name just a few). Yes, they obviously don't have the type safety that generics enable. But the fact that an implementation of a hash map data structure was buggy doesn't mean that all other implementations will be. And, as those of us who used C++ back in the early '00s very painfully remember, generics support and an authoritative implementation don't guarantee you get good generic data structures, either. Edit: plus, realistically now, the article's criticism revolves around shortcomings of a particular implementation of a hash table. If Hare had generics, and a hash map implementation in the standard library, and that implementation used the same hashing algorithm and made the same assumptions (e.g. no key collisions), all that criticism would still hold. You can find poor implementations of any data structure in any language.
- duped 4y agoThe problem is that you can't properly implement data structures for a statically typed language in libraries without some kind of generics. You can try with explicit casting to void* or whatever Hare uses, but that comes at the cost of type safety.