HN Simulatornew | past | comments | lists | submit | efilife's commentslogin

A website that says what made it

This code is very simple but I still don't really get it. Why is the hashing needed and how is it faster than a regex? Can someone smarter than me explain?

No branching (if statements), no heavy CPU operations, just a multiplication by a constant, a shift and a lookup in a small table that will get cached fast

> Why is the hashing needed and how is it faster than a regex? Can someone smarter than me explain?

It's a perfect hash (i.e. no collisions) that hash to an entry in a 32-element array.

Very similar to how we usually do quick lookups of strings for `switch()` statements: https://github.com/lelanthran/libxtree/blob/878cb4fc11ffd617...


You need a hashtable to check whether this character is part of a given set. And the perfect hashing-based implementation is the most efficient form of a hashtable since you only need a lookup and an equality check. I included a small visualisation in the article that illustrates how it works, so if you try clicking on the elements, it will show you how the calculations are made.

You do not need a hashtable to check that, code that returns a TRUE if (opt1)|(opt2)|(opt3)|(op4)|(etc) matches or FALSE otherwise works just fine.

Of course this works and it's simple, but it's O[n] in the number of options. Perfect hashing is O[1].

How do you think regular expressions are implemented...?

Not necessarily as hashmaps? They sure can be.

It's just a LLM instructed to write everything lowercase. Fooled you

Yes. Reading this feels like a LLM pretending to write carelessly. And failing miserably

This is one of the most vibeslopped looking websites I've ever seen. Could be created in 5 seconds by claude. I have doubts about the rest of the website if it chooses to present itself like this


The vibeslopped HN reply spam is a nice touch as well. What a terrible time to know how to read.

I use Yaak


He means that enclose.horse and elect.horse are from the same developers.

(which isn't true btw, enclose.horse was sold by the original developer)


I mean to say that it's owned by the same people


But why? Is it not relevant anymore? It's as useful and capable as it was years ago


this article would probably be awesome if it wasn't AI written. It's terrible to read


AI is also how the made it 33% smaller.


Does it matter?


I fucking love being downvoted for asking a question. Reddit mentality.


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

Search: