hackertube.io

rand() Considered Harmful

aghuttun · talk · Watch on YouTube

What it is

Stephan T. Lavavej's GoingNative 2013 talk explaining why calling rand() and using rand() % 100 is bad in C++, and how the C++11 <random> header does the job properly.

Why Hacker News recommends it

It is the standard reference for why rand() is broken in C++ and what to use instead.

  • 1 people recommended it
  • 1 different months
  • 0 strong recommendations
  • first 2019, last 2025

What HN commenters said

  1. “A lesson of what not to do: ("rand() Considered Harmful")”

    Lesson on what not to do with rand().

    camel-cdr, 2022-05 · Recommendation · in “Show HN: A glib-like multi-platform C library”

Excerpts from Hacker News comments, linked to the originals. Summaries and labels were written by a language model from those comments.

Topics: c++, random, stl, c++11, goingnative

Also recommended by the same people