Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
benhoyt
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
37 ms
·
391.
▲
Mugo, a toy compiler for a subset of Go that can compile itself
(benhoyt.com)
180 points
by
benhoyt
6y ago
|
49 comments
392.
▲
by
benhoyt
6y ago
Forth is (I think?) the oldest and most well-known. Postscript, the printer control language, is possibly more widely-deployed. And Factor is a modern take on Forth.
393.
▲
by
benhoyt
6y ago
> Companies with an explicit diversity and inclusion statement on their job applications get more minority applicants but hire proportionally less minority candidates I'm curious: do you have a source for that?
394.
▲
by
benhoyt
6y ago
Wow, thanks, I did not know that. Though that would be a kinda crazy platform or implementation! I'm betting that a lot of people depend on this.
395.
▲
by
benhoyt
6y ago
Yeah, good point. And then you can allocate the hash table struct and all your buckets in one call to malloc().
396.
▲
by
benhoyt
6y ago
Thanks for this (and parent reply for mentioning it), that's simple and clever! > The basic idea is not complex: when we delete an element, we move the next element to the deleted location if it is pushed away by the deleted element
397.
▲
by
benhoyt
6y ago
Nice. Yeah, looks like it's in section "6.6 Table Lookup", and it implements a simple, fixed-size hash table (array size 101) of char* to char*, and it handles collisions via linked lists.
398.
▲
How to implement a hash table in C
(benhoyt.com)
302 points
by
benhoyt
6y ago
|
156 comments
399.
▲
by
benhoyt
6y ago
There are always going to be some things that people believe we shouldn't be able to decide, even for ourselves. Someone else on the thread posted about consensual cannibalism -- most people would consider that over their line. A lot o
400.
▲
by
benhoyt
6y ago
I'll take a stab (I'm against similar laws). It's more a moral and emotive argument than a "rational" one, but many people believe that taking a human life -- apart from certain cases like self defense -- is wrong,
401.
▲
by
benhoyt
6y ago
No problem -- defaultdict is one of my favourite Python tools! Note that the code you posted is nice for a one-liner, however, it goes against my constraint of not reading the entire file into memory (important for very large files).
402.
▲
Frawk, a JITted and SIMD-Optimized AWK Written in Rust
(github.com)
4 points
by
benhoyt
6y ago
|
0 comments
403.
▲
by
benhoyt
6y ago
No, map[string]int doesn't allocate ints. Why the map[string]*int version is faster is because it avoids a "write" to the map when you're not adding new words -- it can just look up the pointer and increment what it poin
404.
▲
by
benhoyt
6y ago
Thanks for the feedback. I was trying to make that clear with "grep reference", but you're right, it's still ambiguous. I'll add a note to clear it up. Both "wc" and "grep" don't solve the p
405.
▲
by
benhoyt
6y ago
Yes, I'm definitely aware of this, thanks -- and as a result, you can't really compare the "simple" and "optimized" versions. Most of the "simple" versions (except C) are Unicode-aware, most of the op
406.
▲
by
benhoyt
6y ago
Very interesting -- I hadn't seen that. Thanks for the link.
407.
▲
by
benhoyt
6y ago
That link shows that yes, "_count_elements" is implemented in Python, but right after it pulls in the C version if available (which it presumably is in CPython): try: # Load C helper functio
408.
▲
by
benhoyt
6y ago
Yeah, I'm on Linux too and tried that with no noticeable difference in results. There's something off about macOS's approach.
409.
▲
by
benhoyt
6y ago
Yeah, I would have liked to avoid it too. But I think you have to allocate with the hcreate/hsearch API (for the "simple" C version). When I roll my own hash table with optimized.c I don't allocate for the integers.
410.
▲
by
benhoyt
6y ago
Thanks for that - fixed. Repo link is: https://github.com/benhoyt/countwords
411.
▲
Performance comparison: counting words in Python, Go, C++, C, Awk, Forth, Rust
(benhoyt.com)
441 points
by
benhoyt
6y ago
|
303 comments
412.
▲
by
benhoyt
6y ago
Thanks. I re-read this paragraph from the original article and it makes more sense now: > use a zone mapping table, mapping between zone index integers and zone name strings. That’s what the Go standard library does internally. But then
413.
▲
by
benhoyt
6y ago
I don't quite understand why you need the messy/unsafe string interning, instead of a simple (mutex-protected) map with the m[string(b)] optimization that avoids allocations, or josharian's sync.Pool approach? https:/&#
414.
▲
by
benhoyt
6y ago
Out of interest, how do you compare/store in a map? Do you convert to a string, or a [4]byte array (for IPv4), or some other comparable/hashable type?
415.
▲
by
benhoyt
6y ago
Yeah, I wonder what their long-term plan is there. Surely to get substantially better, they'll have to move off Bing at some point (or buy Bing off Microsoft!). In any case, as long as DDG is a "privacy-stripping proxy" (whic
416.
▲
by
benhoyt
6y ago
As someone who's just written about the "small web" [1], this warms my heart. The lite version is probably a little too bare-bones for most people's tastes, but it sure is tiny -- great for people on very slow or flake
417.
▲
by
benhoyt
6y ago
Not sure if you were replying to me, but sure, go ahead -- my email is on my website (which is in my profile).
418.
▲
by
benhoyt
6y ago
Compass is partially funded by SoftBank, but the rest is not true -- there's a whole lot of tech behind it (source: I used to work there as a software engineer). It's mostly tools for agents, and some tools for consumers. They pul
419.
▲
by
benhoyt
6y ago
I love this prediction, and also how you're working to make it self-fulfilling. :-) I've definitely seen it with the raft of small alternatives to Google Analytics that have popped up in the last couple of years. Do you have favou
420.
▲
The small web is beautiful
(benhoyt.com)
119 points
by
benhoyt
6y ago
|
14 comments
More ›