frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Montana Law Allowing Experimental Medical Treatments

https://www.technologyreview.com/2025/05/14/1116428/first-us-hub-for-experimental-medical-treatments/
1•vjulian•8s ago•0 comments

Free VoiceTyping App

https://voicetype.com/free
1•mlashuel•4m ago•0 comments

Build your first LLM from scratch

https://github.com/Michaelgathara/GPT
1•Michaelgathara•10m ago•0 comments

Coinbase suffers cyberattack as oversees employees bribed to steal customer data

https://www.marketwatch.com/story/coinbase-suffers-cyber-attack-as-oversees-employees-were-bribed-to-steal-customer-data-c74b2840
1•zerosizedweasle•13m ago•2 comments

Unpatched iOS Exploit Chain Disclosed After Cert/CC Approval

https://josephgoydish2.substack.com/p/ios-exploit-chain-and-remaining-unpatched
1•FluGameAce007•14m ago•0 comments

Joining threads as they finish in Rust

https://jpmelos.com/posts/joining-multiple-rust-threads/
2•jpmelos•14m ago•0 comments

Williams Syndrome: The people who are too friendly

https://www.bbc.com/future/article/20250515-williams-syndrome-the-people-who-are-too-friendly
1•neom•15m ago•0 comments

Geo-Sleuthing 101: How to Pinpoint Locations with Osint

https://medium.com/@haydenbanz/geo-sleuthing-101-how-to-pinpoint-locations-with-osint-e474998833c9
2•navbvvdasvv•16m ago•0 comments

Gold Prediction Wiki

https://www.goldprediction.wiki/
1•amisinggjj•22m ago•1 comments

Show HN: A bot that doesn't join your calls and writes your follow-up

https://www.withcustos.com/
1•khalilosman123•28m ago•0 comments

Why bad philosophy is stopping progress in physics

https://www.nature.com/articles/d41586-025-01465-6
3•bookofjoe•31m ago•1 comments

Urge Congress to Save Public Media Like PBS

https://protectmypublicmedia.org/
5•burnt-resistor•34m ago•1 comments

Repository with system prompts that for Grok chat assistant

https://github.com/xai-org/grok-prompts
1•sxp•37m ago•0 comments

Update on an incident that happened with our Grok response bot on X yesterday

https://twitter.com/xai/status/1923183620606619649
8•sxp•38m ago•7 comments

Advertisers hit back at Elon Musk's ad boycott lawsuit

https://www.businessinsider.com/advertisers-elon-musk-x-ad-boycott-lawsuit-dismiss-2025-5
3•pinewurst•38m ago•1 comments

US set to lose $12.5B in international tourism

https://wttc.org/news/us-economy-set-to-lose-12-5bn-in-international-traveler-spend-this-year
8•geox•40m ago•0 comments

Aurura time-lapses from space captured by NASA's Don Pettit [video]

https://www.youtube.com/watch?v=KVPyGznA9QY
1•pavel_lishin•42m ago•0 comments

Trump's sanctions on ICC's chief prosecutor have halted tribunal's work

https://www.pbs.org/newshour/world/trumps-sanctions-on-iccs-chief-prosecutor-have-halted-tribunals-work-officials-and-lawyers-say
6•bhouston•45m ago•1 comments

A Resolution in Response to the Adoption of ChatGPT Edu at CSU Northridge [pdf]

https://live-csu-northridge.pantheonsite.io/sites/default/files/2025-05/ChatGPT%20resolution%20v%202.0_0.pdf
2•mooreds•47m ago•0 comments

Green Fabrication of Sulfonium-Containing Bismuth Materials for X-Ray Detection

https://advanced.onlinelibrary.wiley.com/doi/10.1002/adma.202418626
2•PaulHoule•50m ago•0 comments

Ollama's new engine for multimodal models

https://ollama.com/blog/multimodal-models
3•LorenDB•54m ago•0 comments

Show HN: I built a Goal Meter I always wanted

https://goalmeter.xyz
1•bhu1st•56m ago•0 comments

A Garbage Collection Strategy

https://irreal.org/blog/?p=12989
2•todsacerdoti•56m ago•0 comments

Spatial Speech Translation: Translating Across Space with Binaural Hearables

https://babelfish.cs.washington.edu/
1•gnabgib•1h ago•0 comments

In Celebration of Accessibility

https://feaneron.com/2025/05/15/in-celebration-of-accessibility/
2•hysan•1h ago•0 comments

I was a Theranos whistleblower. Here's what I think Elizabeth Holmes is up to

https://www.statnews.com/2025/05/15/theranos-whistleblower-tyler-shultz-commentary-elizabeth-holmes-billy-evans-haemanthus-startup/
16•iancmceachern•1h ago•3 comments

Continued Corespotlightd High CPU Usage on Sequoia

https://iboysoft.com/howto/continued-corespotlightd-cpu-overload-sequoia.html
1•Nancy-ooo•1h ago•1 comments

AI headphones translate multiple speakers at once

https://www.washington.edu/news/2025/05/09/ai-headphones-translate-multiple-speakers-at-once-cloning-their-voices-in-3d-sound/
3•gmays•1h ago•0 comments

ESC190 Lab 10: Vibe Coding [pdf]

https://www.cs.toronto.edu/~guerzhoy/190/labs/lab10.pdf
1•watusername•1h ago•0 comments

Apple Used China to Make a Profit. What China Got in Return Is Scarier

https://www.nytimes.com/2025/05/15/books/review/apple-in-china-patrick-mcgee.html
5•perihelions•1h ago•2 comments
Open in hackernews

Initialization in C++ is bonkers (2017)

https://blog.tartanllama.xyz/initialization-is-bonkers/
92•todsacerdoti•5h ago

Comments

gnabgib•4h ago
Small discussion at the time (42 points, 6 comments) https://news.ycombinator.com/item?id=14532478

Related: Initialization in C++ is Seriously Bonkers (166 points, 2019, 126 points) https://news.ycombinator.com/item?id=18832311

nlehuen•3h ago
Not to worry, there is a 278 page book about initialization in C++!

https://leanpub.com/cppinitbook

(I don't know whether it's good or not, I just find it fascinating that it exists)

nitrogen99•3h ago
Well, authors are incentivized into writing long books. Having said that it obviously doesn't take away the fact that C++ init is indeed bonkers.
harry8•2h ago
What would be the incentive for making this a long book? Couldn't be money.
Analemma_•1h ago
I imagine if I'd managed to actually memorize all of C++'s initialization rules, I'd probably have to write a book too just to get it all out, or I'd lose my sanity.
jcelerier•1h ago
It is actually. It's been shown that longer books make more sales as they are considered more trustworthy, so authors are incentivized to artificially drag them longer than they actually require
bhk•1h ago
Wow! Exhibit 1 for the prosecution.
kazinator•37m ago
C++ doesn't have initiation hazing rituals, but initialization hazing rituals. (One of which is that book.)
ts4z•3h ago
This is a specialization of the general statement that C++ is bonkers.
timewizard•3h ago
> Explicitly initialize your variables, and if you ever fall in to the trap of thinking C++ is a sane language, remember this

It's a systems language. Systems are not sane. They are dominated by nuance. In any case the language gives you a choice in what you pay for. It's nice to be able to allocate something like a copy or network buffer without having to pay for initialization that I don't need.

vacuity•3h ago
I think in this case it's not amiss to mention Rust. Rust gives a compile error if it's not certain a variable is initialized. Option is the standard dynamic representation of this, and works nicely in the context of all Rust code. MaybeUninint is the `unsafe` variant that is offered for performance-critical situations.
gosub100•2h ago
That may have made sense in the days of < 100 MHz CPUs but today I wish they would amend the standard to reduce UB by default and only add risky optimizations with specific flags, after the programmer has analyzed them for each file.
jcelerier•2h ago
> That may have made sense in the days of < 100 MHz CPUs

you don't know how much C++ code is being written for 100-200MHz CPUs everyday

https://github.com/search?q=esp8266+language%3AC%2B%2B&type=...

I have a codebase that is right now C++23 and soon I hope C++26 targeting from Teensy 3.2 (72 MHz) to ESP32 (240 MHz). Let me tell you, I'm fighting for microseconds every time I work with this.

vjvjvjvjghv•2h ago
I bet even there you have only a few spots where it really makes a difference. It’s good to have the option but I think the default behavior should be safer.
jcelerier•1h ago
I don't know, way too often often my perf traces are evenly distributed across a few hundred functions (at best), without any clear outlier.
gosub100•1h ago
"how much code" =/= how many developers.

the people who care about clock ticks should be the ones inconvenienced, not ordinary joes who are maintaining a FOSS package that is ultimately stuck by a 0-day. It still takes a swiss-cheese lineup to get there, for sure. but one of the holes in the cheese is C++'s default behavior, trying to optimize like it's 1994.

jcelerier•1h ago
> the people who care about clock ticks

I mean that's pretty much the main reason for using c++ isn't it? Video games, real-time media processing, CPU ai inference, network middleware, embedded, desktop apps where you don't want startup time to take more than a few milliseconds...

gosub100•58m ago
No, it's not a dichotomy of having uninitialized data and fast startup or wait several milliseconds for a jvm or interpreter to load a gigabyte of heap allocated crap.
timewizard•1h ago
CPU speed is not memory bandwidth. Latency and contention always exist. Long lived processes are not always the norm.

In another era we would have just called this optimal. https://x.com/ID_AA_Carmack/status/1922100771392520710

wffurr•40m ago
>> Systems are not sane.

“The systems programmer has seen the terrors of the world and understood the intrinsic horror of existence.”

https://www.usenix.org/system/files/1311_05-08_mickens.pdf

vitaut•3h ago
https://www.reddit.com/r/ProgrammerHumor/comments/8nn4fw/for...
e-dant•3h ago
Let the language die, hope it goes quicker than cobol.
gosub100•2h ago
COBOL is alive and well. Why would a company rewrite a codebase that has decades of error free functionality? What do they get?
cheema33•2h ago
> Why would a company rewrite a codebase that has decades of error free functionality? What do they get?

All well and good if it is something you do not have to modify/maintain on a regular basis. But, if you do, then the ROI on replacing it might be high, depending on how much pain it is to keep maintaining it.

We have an old web app written in asp.net web forms. It mostly works. But we have to maintain it and add functionality to it. And that is where the pain is. We've been doing it for a few years but the amount of pain it is to work on it is quite high. So we are slowly replacing it. One page at a time.

gosub100•1h ago
the insurance companies running COBOL don't care. it's cheaper to pay a cowboy $X00,000/yr to keep the gravy dispenser running than trying to modify it. by definition, this is code that's been in use for decades. Why change it?
bdangubic•2h ago
“quicker than cobol” means it will die in the next 100 years (maybe) :)
jimbob45•1h ago
I suspect the committee agrees with you. I think they’ve anticipated a competitor coming to kill C++ for two decades now and see themselves as keeping C++ on life support for those who need it.

It’s shameful that there’s no good successor to C++ outside of C# and Java (and those really aren’t successors). Carbon was the closest we came and Google seems to have preemptively dropped it.

compiler-guy•1h ago
Carbon is still quite active.
wffurr•46m ago
The latest Carbon newsletter is here, from March: https://github.com/carbon-language/carbon-lang/discussions/5...
compiler-guy•1h ago
https://www.phoronix.com/news/GCC-15-Merges-COBOL

COBOL Language Frontend Merged For GCC 15 Compiler Written by Michael Larabel in GNU on 11 March 2025 at 06:22 AM EDT. 33 Comments

beached_whale•3h ago
And for the most part it does what you expect.
jandrewrogers•3h ago
I largely prefer modern C++ as systems languages go but there is no getting around the fact that the initialization story in C++ is a hot mess. Fortunately, it mostly does what you need it to even if you don't understand it.
vjvjvjvjghv•2h ago
And sometimes it doesn’t do what you think it does.
waynecochran•2h ago
This idea that everything must be initialized (i.e. no undefined or non-deterministic behavior) should never be forced upon a language like C++ which rightly assumes the programmer should have the final say. I don't want training wheels put on C++ -- I want C++ do exactly and only what the programmer specifies and no more. If the programmer wants to have uninitialized memory -- that is her business.
anon-3988•2h ago
If they want the program to do exactly what is told they won't get to have optimization.
GrantMoyer•2h ago
The problem is that the initialization semantics are so complex in C++ that almost no programmer is actually empowered to exercise their final say, and no programmer without significant effort.

And that's not just said out of unfamiliarity. I'm a professional C++ developer, and I often find I'm more familiar with C++'s more arcane semantics than many of my professional C++ developer co-workers.

vjvjvjvjghv•2h ago
The dev should have the option to turn it off but I think that removing a lot of undefined and non deterministic behavior would be a good thing. When I did C++ I initialized everything and when there was a bug it could usually be reproduced. There are a few cases where it makes sense performance wise to not initialize but those cases are very small compared to most other code where undefined behavior causes a ton of intermittent bugs.
yxhuvud•2h ago
The discussion about what should be the default behavior and of what should be the opt-in behavior is very different from what should be possible. It is definitely clear that in c++, it must be possible to not initialize variables.

Would it really be that unreasonable to have initialisation be opt-out instead of opt-in? You'd still have just as much control, but it would be harder to shoot yourself in the foot by mistake. Instead it would be slightly more easy to get programs that can be optimised.

frollogaston•1h ago
C++ is supposed to be an extension of C, so I wouldn't expect things to be initialized by default, even though personally I'm using C++ for things where it'd be nice.

I'm more annoyed that C++ has some way to default-zero-init but it's so confusing that you can accidentally do it wrong. There should be only one very clear way to do this, like you have to put "= 0" if you want an int member to init to 0. If you're still concerned about safety, enable warnings for uninitialized members.

tonyhart7•2h ago
"If the programmer wants to have uninitialized memory -- that is her business."

idk, seems like years of academic effort and research wasted if we do the way C++ do it

loeg•2h ago
As someone who has to work in C++ day in and day out: please, give me the fucking training wheels. I don't want UB if I declare an object `A a;` instead of `A a{};`. At least make it a compiler error I can enable!
ryandrake•1h ago
Ideally, there would be a keyword for it. So ‘A a;’ would not compile. You’d need to do ‘A a{};’ or something like ‘noinit A a;’ to tell the compiler you’re sure you know what you are doing!
charlotte-fyi•1h ago
The entire problem is that what the programmer wants to do and what the program actually does isn't always clear to the programmer.
kstrauser•1h ago
By that logic, you'd have to dislike the situations where C++ does already initialize variables to defined values, like `int i;`, because they're removing your control and forcing training wheels upon you.

So, do you?

jcelerier•1h ago

    int i;
does not initialize the value.
kstrauser•49m ago
It's a gotcha to be sure. Sometimes it does, sometimes it doesn't. From a reference[0]:

  #include <string>
  
  struct T1 { int mem; };
  
  struct T2
  {
      int mem;
      T2() {} // “mem” is not in the initializer list
  };
  
  int n; // static non-class, a two-phase initialization is done:
  // 1) zero-initialization initializes n to zero
  // 2) default-initialization does nothing, leaving n being zero
  
  int main()
  {
      [[maybe_unused]]
      int n;            // non-class, the value is indeterminate
      std::string s;    // class, calls default constructor, the value is ""
      std::string a[2]; // array, default-initializes the elements, the value is {"", ""}
      //  int& r;           // Error: a reference
      //  const int n;      // Error: a const non-class
      //  const T1 t1;      // Error: const class with implicit default constructor
      [[maybe_unused]]
      T1 t1;            // class, calls implicit default constructor
      const T2 t2;      // const class, calls the user-provided default constructor
      // t2.mem is default-initialized
  }
That `int n;` on the 11th line is initialized to 0 per standard. `int n;` on line 18, inside a function, is not. And `struct T1 { int mem; };` on line 3 will have `mem` initialized to 0 if `T1` is instantiated like `T1 t1{};`, but not if it's instantiated like `T1 t1;`. There's no way to tell from looking at `struct T1{...}` how the members will be initialized without knowing how they'll be called.

C++ is fun!

[0]https://en.cppreference.com/w/cpp/language/default_initializ...

90s_dev•43m ago
Stroustrup once said

> "There's a great language somewhere deep inside of C++"

or something to that effect.

portaltonowhere•39m ago
Unless `i` is global…
Maxatar•1h ago
It's so ironic hearing a comment like this. If what you really want is for C++ to do only what you strictly specified, then you'd always release your software with all optimizations disabled.

But I'm going to go out on a limb here and guess you don't do that. You actually do allow the C++ compiler to make assumptions that are not explicitly in your code, like reorder instructions, hoist invariants, eliminate redundant loads and stores, vectorize loops, inline functions, etc...

All of these things I listed are based on the compiler not doing strictly what you specified but rather reinterpreting the source code in service of speed... but when it comes to the compiler reinterpreting the source code in service of safety.... oh no... that's not allowed, those are training wheels that real programmers don't want...

Here's the deal... if you want uninitialized variables, then explicitly have a way to declare a variable to be uninitialized, like:

    int x = void;
This way for the very very rare cases where it makes a performance difference, you can explicitly specify that you want this behavior... and for the overwhelming majority of cases where it makes no performance impact, we get the safe and well specified behavior.
frollogaston•1h ago
How about int x = 0 if you want 0. Just `int x;` doesn't make it clear that you want 0.
kstrauser•35m ago
Safe defaults matter. If you're using x to index into a array, and it's randomly initialized as +-2,000,000,000 because that's what happened to be in that RAM location when the program launched, and you use it before explicitly setting it, you're gonna have a bad time.

And if you used it with a default value of 0, you're going to end up operating on the 0th item in the array. That's probably a bug and it may even be a crasher if the array has length 0 and you end up corrupting something important, but the odds of it being disastrous are much lower.

90s_dev•48m ago
That's the inherent tension, though, isn't it?

A programmer wants the compiler to accept code that looks like a stupid mistake when he knows it's not.

But he also wants to have the compiler make sure he isn't making stupid mistakes by accident.

How can it do both? They're at odds.

titzer•35m ago
> I want C++ do exactly and only what the programmer specifies and no more.

Most programmers aren't that good and you're mostly running other people's code. Bad defaults that lead to exploitable security bugs is...bad defaults. If you want something to be uninitialized because you know it then you should be forced to scream it at the compiler.

shadowdev1•2h ago
Heh, low comments on C++ posts now. A sign of the times. My two cents anyway.

I've been using C++ for a decade. Of all the warts, they all pale in comparison to the default initialization behavior. After seeing thousands of bugs, the worst have essentially been caused by cascading surprises from initialization UB from newbies. The easiest, simplest fix is simply to default initialize with a value. That's what everyone expects anyway. Use Python mentality here. Make UB initialization an EXPLICIT choice with a keyword. If you want garbage in your variable and you think that's okay for a tiny performance improvement, then you should have to say it with a keyword. Don't just leave it up to some tiny invisible visual detail no one looks at when they skim code (the missing parens). It really is that easy for the language designers. When thinking about backward compatibility... keep in mind that the old code was arguably already broken. There's not a good reason to keep letting it compile. Add a flag for --unsafe-initialization-i-cause-trouble if you really want to keep it.

C++, I still love you. We're still friends.

juliangmp•2h ago
> When thinking about backward compatibility... keep in mind that the old code was arguably already broken. There's not a good reason to keep letting it compile.

Oh how I wish the C++ committee and compiler authors would adopt this way of thinking... Sadly we're dealing with an ecosystem where you have to curate your compiler options and also use clang-tidy to avoid even the simplest mistakes :/

Like its insane to me how Wconversion is not the default behavior.

loeg•2h ago
Compilers should add this as a non-standard extension, right? -ftrivial-auto-var-init=zero is a partial solution to a related problem, but it seems like they could just... not have UB here. It can't be that helpful for optimization.
Matheus28•1h ago
Yes but it’s not portable. If zero initialization were the default and you had to opt-in with [[uninitialized]] for each declaration it’d be a lot safer. Unfortunately I don’t think that will happen any time soon.
loeg•1h ago
I don't really care if it isn't portable. I only have to work with Clang, personally.

> If zero initialization were the default and you had to opt-in with [[uninitialized]] for each declaration it’d be a lot safer.

I support that, too. Just seems harder than getting a flag into Clang or GCC.

ryandrake•1h ago
Portability is always for the other guy’s sake, not your own. That’s why so many people don’t care about it.
loeg•7m ago
Again, I'm not opposed to the idea, it just seems more challenging logistically.
tialaramex•19m ago
You probably don't want zero initialization if you can help it.

Ideally, what you want is what Rust and many modern languages do: programs which don't explain what they wanted don't compile, so, when you forget to initialize that won't compile. A Rust programmer can write "Don't initialize this 1024 byte buffer" and get the same (absence of) code but it's a hell of a mouthful - so they won't do it by mistake.

The next best option, which is what C++ 26 will ship, is what they called "Erroneous Behaviour". Under EB it's defined as an error not to initialize something you use but it is also defined what happens so you can't have awful UB problems, typically it's something like the vendor specifies which bit pattern is written to an "unintialized" object and that's the pattern you will observe.

Why not zero? Unfortunately zero is too often a "magic" value in C and C++. It's the Unix root user, it's often an invalid or reserved state for things. So while zero may be faster in some cases, it's usually a bad choice and should be avoided.

markhahn•2h ago
Most of that actually just makes sense if you approach it from the historic,low-level, minimalist direction. But maybe if you're coming from some other, higher-comfort language...
frollogaston•1h ago
Coming from C, none of this made sense to me. Wut is `foo() = default;`? If you want a default value of 0, why isn't it just

  struct foo {
    int a = 0;
  };
In Python, which is higher-level ofc, I still have to do `foo = 0`, nice and clear.
zabzonk•53m ago
> If you want a default value of 0, why isn't it ...

It is.

Maxatar•25m ago
`foo() = default;` is an explicit way to generate a default constructor for `foo`. The default constructor works by recursively calling the default constructors for all class instance fields. In C++ there are a bunch of rules about when a class has a default constructor or not, but by explicitly declaring one you are guaranteed to have it so long as all your class instance fields have default constructors.

Your example of having a field called `a` that is initialized to 0 is perfectly valid C++ as well but it's not the same as an explicitly declared default constructor.

nyarlathotep_•1h ago
Aside, but the author of this blog is the author of https://nostarch.com/building-a-debugger

A wonderful exploration of an underexplored topic--I've pre-ordered the hard copy and have been following along with the e-book in the interim.

jeffbee•1h ago
It's fun to cross the streams of HN catnip.

C++ sucks, it's too hard to use, the compiler should generate stores all over the place to preemptively initialize everything!

Software is too bloated, if we optimized more we could use old hardware!

Maxatar•1h ago
I'm not familiar with programming languages that generate redundant stores in order to initialize anything.

Usually what happens is the language requires you to initialize the variable before it's read for the first time, but this doesn't have to be at the point of declaration. Like in Java you can declare a variable, do other stuff, and then initialize it later... so long as you initialize it before reading from it.

Note that in C++, reading from a variable before writing to it is undefined behavior, so it's not particularly clear what benefit you're getting from this.

kazinator•38m ago
> This rule makes sense when you think about it

No, it is bonkers; stick to your consistent point, please.

These two should have exactly the same effect:

  bar() = default;       // inside class declaration

  bar::bar() = default;  // outside class declaration
The only difference between them should be analogous to the difference between an inline and non-inline function.

For instance, it might be that the latter one is slower than the former, because the compiler doesn't know from the class declaration that the default constructor is actually not user-defined but default. How it would work is that a non-inline definition is emitted, which dutifully performs the initialization, and that definition is actually called.

That's what non-bonkers might look like, in any case.

I.e. both examples are rewritten by the compiler into

  bar() { __default_init; }

  bar::bar() { __default_init; }
where __default_init is a fictitious place holder for the implementation's code generation strategy for doing that default initialization. It would behave the same way, other than being inlined in the one case and not in the other.

Another way that it could be non-bonkers is if default were simply not allowed outside of the class declaration.

  bar::bar() default;  // error, too late; class declared already!
Something that has no hope of working right and is easily detectable by syntax alone should be diagnosed. If default only works right when it is present at class declaration time, then ban it elsewhere.
alexvitkov•13m ago
This is not even worth thinking about, just type " = {}" on every struct/class member and every variable declaration, and forget about all this nonsense.