Live data from Hacker News

Show HN: A glib-like multi-platform C library

github.com

11–13 of 13 posts

Re: Show HN: A glib-like multi-platform C library

#11
post #8

Earlier quoted context omitted.

no, it should be `v2.6.5/xmake-v2.6.5.tar.gz` instead of `tags/v2.6.5.tar.gz` https://github.com/xmake-io/xmake/releases/download/v2.6.5/xmake-v2.6.5.tar.gz

Ah, I see. That might be Github’s problem, but the link I used is the one at the bottom of the list labeled “Source code”: https://github.com/xmake-io/xmake/releases/tag/v2.6.5 I see that one you mention in the middle of the list, with the name “xmake-v2.6.5.tar.gz”. Please note that this is not a criticism, I’m just telling what can happen when someone tries to compile it. Edit: trying this now: wget https://github.…

Github’s auto-generated source tars don’t include submodules.

https://github.com/dear-github/dear-github/issues/214

Re: Show HN: A glib-like multi-platform C library

#13
Whenever I see such libraries, the first thing I check out is their PRNG implementation, and this one must be the worst I've seen so far. (The rest of the library is probably quite good, I'm just talking about the PRNG part)

The library has one PRNG, and it is the following:

    tb_spinlock_enter(&g_lock);
    g_value = (g_value * 10807 + 1) & 0xffffffff;
    tb_spinlock_leave(&g_lock);
Using this is literally worse than using the rand reference implementation.

Also, tb_random_range uses a biased and slow implementation with modulo. (see https://www.pcg-random.org/posts/bounded-rands.html for the proper way to do this)

I might look into adding a proper PRNG implementation, but I'll recommend a few resources:

A lesson of what not to do: https://youtu.be/LDPMpc-ENqY ("rand() Considered Harmful") Some good modern PRNGs: https://www.pcg-random.org/, https://prng.di.unimi.it/, https://romu-random.org/ Generating random numbers in a specific range: https://www.pcg-random.org/posts/bounded-rands.html

Post reply on HN