frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Female Asian Elephant Calf Born at the Smithsonian National Zoo

https://www.si.edu/newsdesk/releases/female-asian-elephant-calf-born-smithsonians-national-zoo-an...
1•gmays•23s ago•0 comments

Show HN: Zest – A hands-on simulator for Staff+ system design scenarios

https://staff-engineering-simulator-880284904082.us-west1.run.app/
1•chanip0114•1m ago•0 comments

Show HN: DeSync – Decentralized Economic Realm with Blockchain-Based Governance

https://github.com/MelzLabs/DeSync
1•0xUnavailable•6m ago•0 comments

Automatic Programming Returns

https://cyber-omelette.com/posts/the-abstraction-rises.html
1•benrules2•9m ago•1 comments

Why Are There Still So Many Jobs? The History and Future of Workplace Automation [pdf]

https://economics.mit.edu/sites/default/files/inline-files/Why%20Are%20there%20Still%20So%20Many%...
2•oidar•11m ago•0 comments

The Search Engine Map

https://www.searchenginemap.com
1•cratermoon•18m ago•0 comments

Show HN: Souls.directory – SOUL.md templates for AI agent personalities

https://souls.directory
1•thedaviddias•20m ago•0 comments

Real-Time ETL for Enterprise-Grade Data Integration

https://tabsdata.com
1•teleforce•23m ago•0 comments

Economics Puzzle Leads to a New Understanding of a Fundamental Law of Physics

https://www.caltech.edu/about/news/economics-puzzle-leads-to-a-new-understanding-of-a-fundamental...
2•geox•24m ago•0 comments

Switzerland's Extraordinary Medieval Library

https://www.bbc.com/travel/article/20260202-inside-switzerlands-extraordinary-medieval-library
2•bookmtn•24m ago•0 comments

A new comet was just discovered. Will it be visible in broad daylight?

https://phys.org/news/2026-02-comet-visible-broad-daylight.html
2•bookmtn•29m ago•0 comments

ESR: Comes the news that Anthropic has vibecoded a C compiler

https://twitter.com/esrtweet/status/2019562859978539342
1•tjr•31m ago•0 comments

Frisco residents divided over H-1B visas, 'Indian takeover' at council meeting

https://www.dallasnews.com/news/politics/2026/02/04/frisco-residents-divided-over-h-1b-visas-indi...
1•alephnerd•31m ago•0 comments

If CNN Covered Star Wars

https://www.youtube.com/watch?v=vArJg_SU4Lc
1•keepamovin•37m ago•0 comments

Show HN: I built the first tool to configure VPSs without commands

https://the-ultimate-tool-for-configuring-vps.wiar8.com/
2•Wiar8•40m ago•3 comments

AI agents from 4 labs predicting the Super Bowl via prediction market

https://agoramarket.ai/
1•kevinswint•45m ago•1 comments

EU bans infinite scroll and autoplay in TikTok case

https://twitter.com/HennaVirkkunen/status/2019730270279356658
5•miohtama•48m ago•3 comments

Benchmarking how well LLMs can play FizzBuzz

https://huggingface.co/spaces/venkatasg/fizzbuzz-bench
1•_venkatasg•50m ago•1 comments

Why I Joined OpenAI

https://www.brendangregg.com/blog/2026-02-07/why-i-joined-openai.html
19•SerCe•51m ago•11 comments

Octave GTM MCP Server

https://docs.octavehq.com/mcp/overview
1•connor11528•52m ago•0 comments

Show HN: Portview what's on your ports (diagnostic-first, single binary, Linux)

https://github.com/Mapika/portview
3•Mapika•54m ago•0 comments

Voyager CEO says space data center cooling problem still needs to be solved

https://www.cnbc.com/2026/02/05/amazon-amzn-q4-earnings-report-2025.html
1•belter•58m ago•0 comments

Boilerplate Tax – Ranking popular programming languages by density

https://boyter.org/posts/boilerplate-tax-ranking-popular-languages-by-density/
1•nnx•58m ago•0 comments

Zen: A Browser You Can Love

https://joeblu.com/blog/2026_02_zen-a-browser-you-can-love/
1•joeblubaugh•1h ago•0 comments

My GPT-5.3-Codex Review: Full Autonomy Has Arrived

https://shumer.dev/gpt53-codex-review
2•gfortaine•1h ago•0 comments

Show HN: FastLog: 1.4 GB/s text file analyzer with AVX2 SIMD

https://github.com/AGDNoob/FastLog
2•AGDNoob•1h ago•1 comments

God said it (song lyrics) [pdf]

https://www.lpmbc.org/UserFiles/Ministries/AVoices/Docs/Lyrics/God_Said_It.pdf
1•marysminefnuf•1h ago•0 comments

I left Linus Tech Tips [video]

https://www.youtube.com/watch?v=gqVxgcKQO2E
1•ksec•1h ago•0 comments

Program Theory

https://zenodo.org/records/18512279
1•Anonymus12233•1h ago•0 comments

Show HN: Local DNA analysis skill for OpenClaw

https://github.com/wkyleg/personal-genomics
2•wkyleg•1h ago•0 comments
Open in hackernews

C++ Seeding Surprises (2015)

https://www.pcg-random.org/posts/cpp-seeding-surprises.html
36•vsbuffalo•7mo ago

Comments

rramadass•7mo ago
Relevant: A old Reddit discussion by the same author - https://old.reddit.com/r/cpp/comments/32u4m7/the_behavior_of...
nynx•7mo ago
Is it possible to initialize a prng in C++’s std correctly?
on_the_train•7mo ago
No one uses the <random> header as it's cursed and the usual cult of backwards compatibility ensures it'll stay that way.

There are several high quality alternatives that people use.

thechao•7mo ago
I've found it easier to write my own PRNG than to use the std. Using the std PRNG is about as buggy as my implementation, so the trade-off is reasonable. I usually need non-cryptographically strong PRNGs, so xorshift128+ is sufficient.
nynx•7mo ago
How did it get into the standard then?
loeg•7mo ago
It was better than the bad, C interface LCG rand(), I guess. (There are LCG parameters that make for ~objectively better PRNGs than MT, but rand()'s parameters aren't great and its state is too small.)
rramadass•7mo ago
You need to understand PRNGs to answer that question. It is complicated and nothing to do with C++ language itself.

Here is cppreference on PRNGs (note the various engines available) - https://www.cppreference.com/w/cpp/numeric/random.html You have to "know" how to combine the various options available to get an optimal sequence.

The Mersenne Twister (MT) was one of the best engines and was the default in many other languages/packages too. See "Applications" section in wikipedia - https://en.wikipedia.org/wiki/Mersenne_Twister

The author identified distribution problems with the 32-bit versions of MT (i am not sure whether similar problems exist with its 64-bit versions) and proposed a different one named "Permuted Congruential Generator (PCG)" which has now been adopted as the default by many of the languages/packages - https://en.wikipedia.org/wiki/Permuted_congruential_generato...

As you can now appreciate, the subject is mathematically complicated and the defaults chosen by the language/package implementer becomes the "most commonly used" and hence reference case. While this is good enough for most "normal" applications if you are doing any special simulations (Monte Carlo or otherwise) and/or specific Numerical Computations it is your responsibility to understand what it is that you need and program accordingly using the various options (if available) or roll your own.

o11c•7mo ago
> (i am not sure whether similar problems exist with its 64-bit versions) and proposed a different one named "Permuted Congruential Generator (PCG)"

The 64-bit version might be a bit faster (for certain workloads, on 64-bit hardware) than the 32-bit version, but still wastes the same space and has the same mathematical flaws.

PCG is still not perfect (128-bit math hurts, though the new DXSM variant at least reduces that to 128x64), but its mathematical properties are nicer than the xor* family (its main competitor), and both families are miles ahead of any other RNG out there.

rramadass•7mo ago
It is understanding the non-trivial statistical properties (even at a simple conceptual level) that is of paramount importance. PRNG is one of the most difficult subjects in Numerical Computation and has nothing whatever to do with any language/package/library etc.

From https://en.wikipedia.org/wiki/Pseudorandom_number_generator

Even today, caution is sometimes required, as illustrated by the following warning in the International Encyclopedia of Statistical Science (2010).

The list of widely used generators that should be discarded is much longer [than the list of good generators]. Do not trust blindly the software vendors. Check the default RNG of your favorite software and be ready to replace it if needed. This last recommendation has been made over and over again over the past 40 years. Perhaps amazingly, it remains as relevant today as it was 40 years ago.

loeg•7mo ago
Sadly, people that don't know better use std::mt19937 all the time :-(.
on_the_train•7mo ago
And the only reason is its cool name. Humans are weird
loeg•7mo ago
Well, it's in std. So there's an appeal to authority (the C++ language authors should be smart, right?) and convenience.
on_the_train•7mo ago
There are still others in <random>. Yet they always use the cool twister one with the funny numbers
slavik81•7mo ago
What alternative within <random> would you recommend and why?
loeg•7mo ago
There's std::linear_congruential_engine, but it doesn't provide you with any (good) default parameters; only the bad ones from historical rand() implementations (minstd_rand0 / minstd_rand).
slavik81•7mo ago
I used it because it was recommended by Stephan T. Lavavej, maintainer of Visual Studio's C++ Standard Library, in his "rand() Considered Harmful" talk, back when <random> was introduced. See 11m30s. https://youtu.be/LDPMpc-ENqY?t=10m50s
loeg•7mo ago
If you're aware/concerned about seeding, you probably aren't using the C++ std prng (mt19937) anyway -- other prngs have desirable properties like vastly smaller state, better performance, or cryptographic security.
sltkr•7mo ago
My standard code for doing this looks like this:

    #include <algorithm>
    #include <array>
    #include <random>
    
    std::mt19937 InitializeRng() {
      std::array<unsigned int, 624> seed_data;
      std::random_device dev;
      std::generate_n(seed_data.data(), seed_data.size(), std::ref(dev));
      std::seed_seq seq(std::begin(seed_data), std::end(seed_data));
      return std::mt19937(seq);
    }
This generates seed_seq with 19968 bits of random data, which is enough for the 19937 bits of Mersenne Twister internal state.

Note that 19668 bits of random data is overkill; something like 256 or 128 bits would probably enough for practical purposes. But I believe there is no real need to limit the amount of data extracted from a random source. Modern operating systems are pretty good at generating large amounts of random data quickly. But if this is a concern, just change 624 to 4/8/16/32 for 128/256/512/1024 bits of entropy. In practice, I don't think you'll notice a difference either in randomness or initialization speed.

edit: also, if performance is a concern, consider changing mt19937 to mt19937_64, which is the 64-bit variant of mt19937 that is incompatible (generates different numbers) but is almost twice as fast on 64-bit platforms (i.e. most platforms today).

cjfd•7mo ago
This talks about 'bad' seeding quite a lot. But it really depends on what you need what is bad and what is good. Sometimes you need to have a reproducible program so you need to write the random number generator yourself and/or otherwise fix the algorithm. Then you can use '5' as the seed. This is quite often good enough for simulations. Sometimes you want to create cryptographic randomness. Then you need to somewhere find some seed of true randomness that is not guessable. In a computer game where the level needs some random elements just seeding the random number generator with the current time might be fine. And so on.
quietbritishjim•7mo ago
I don't think it disputes that sometimes using a fixed small number is a good seed for reproducibility. The point is just, if you do happen to be in the other camp, where you actually want to populate the full state of the RNG using hardware randomness, C++ does not give you an obvious way to do that.
b0a04gl•7mo ago
found one more flakiness over cross platform, when seed mt19937 same way on linux and windows, same compiler, same code... but problem is std::random_device or libc internals differ under the hood. some platforms do random_device as true hardware entropy, others fake it or seed from diff system sources. so seed retrieved isn't stable cross platform. that means mt19937 starts from diff states, causing different random sequences

it's not a bug in mt19937 itself, it's how random_device (or libc randomness) works differently across environments. makes cross platform tests flaky even when logic is rock solid

>>

std::random_device rd; // might differ per platform

std::mt19937 gen(rd()); // seed depends on rd output

std::uniform_int_distribution<> dist(1, 100);

int random_number = dist(gen); // different on linux vs windows tho same code

senkora•7mo ago
Why not just run your tests with a fixed seed? e.g.

    std::mt19937 gen(42);
    std::uniform_int_distribution<> dist(1, 100);
    int random_number = dist(gen);
jhasse•7mo ago
uniform_int_distribution differs between compilers/platforms! Don't use it if you don't want true randomness.
senkora•7mo ago
Thank you, that makes sense. I can see that being an issue for testing.

I wouldn't describe "pseudo-random sequences that differ between compilers/platforms/versions but are deterministic for a given toolchain" as "true randomness" but I understand the point.

I have confirmed that uniform_int_distribution gives different results on x86-64 clang (trunk) with libc++ [1] vs x86-64 clang (trunk) with libstdc++ [2].

[1]: https://godbolt.org/z/dd5YMs7zo

[2]: https://godbolt.org/z/8svGn7Exc

atemerev•7mo ago
If you want reproducibility and statelessness, there's random123 which I highly recommend. Particularly useful for GPU code.

(Not cryptographically secure, but passes all statistical tests you throw at it).