Hacker Newsnew | past | comments | ask | show | jobs | submit | fancy_pantser's commentslogin

The compiler can substitute the value how it sees fit. It's like #define, but type-safe and scoped.

Maybe it's folded into expressions, propagated through constant expressions, or used it in contexts that require compile-time constants (template parameters, array sizes, static_assert, other constexpr expressions).

I mean, not in this case of pi/2, where it's more about announcing semantics, but in general those are the purposes and uses.


I'd like something like this in C or C++ quite honestly.

Something like a struct that I can say "this struct is global to the whole program and everyone can see it, but once this function exits those values are locked in". Maybe something like that one function is allowed to unlock and update it, but nowhere else.

Think in terms of storing a bunch of precomputed coefficients that are based on the samplerate of a system, where you really only need to set it up once on startup and it is unlikely to change during the application's running lifetime.

I feel like there probably is a way to do this, and if I was good at high level languages like C I'd know what it is. If you know, tell me what I'm not understanding ;-)


Same, this is something I would use often. Sort of like #pragma once, but for initialization.


It can do this with const too or even a normal variable that just happens to not vary.


It depends on what you want to do with it.

If you just want the optimizer to be able to constant-fold a value, then yes, either of those will work.

If you want to be able to use the value in the other contexts the parent mentioned that require constant expressions as a language rule, then you generally need constexpr. As an exception, non-constexpr variable values can be used if they’re const (not ‘happens to not vary’) and have integer or enum type (no floats, structs, pointers, etc.). This exception exists for legacy reasons and there’s no particular reason to rely on it unless you’re aiming for compatibility with older versions of C++ or C.

Even if you don’t need to use a variable in those contexts, constexpr evaluation is different from optimizer constant evaluation, and generally better if you can use it. In particular, the optimizer will give up if an expression is too hard to evaluate (depending on implementation-specific heuristics), whereas constexpr will either succeed or give an error (depending only on language rules). It’s also a completely separate code path in the compiler. There are some cases where optimizer constant evaluation can do things constexpr can’t, but most of those have been removed or ameliorated in recent C++ standards.

So it’s often an improvement to tag anything you want to be evaluated at compile time as constexpr, and rarely worse. However, if an expression is so trivial that it’s obvious the optimizer will be able to evaluate it, and you don’t need it in contexts that require a constant expression, then there’s no concrete benefit either way and it becomes a matter of taste. Personally, I wouldn’t tag this particular pi/2 variable constexpr or const, because it does satisfy those criteria and I personally prefer brevity. But I understand why some people prefer a rule of “always constexpr if possible”, either because they like the explicitness or because it’s a simpler rule.


It's explicitly illegal in China.

A 2017 national intelligence law compels Chinese companies and individuals to cooperate with state intelligence when asked and without and public notice.

China has no equivalent of the whistleblower protection that enables resignations with public letters explaining why, protests, open letters with many signatures, etc. Whenever you see "Chinese whistleblower" in the news, you're looking at someone who quietly fled the country first and then blew the whistle. Example: https://www.cnn.com/2026/02/27/us/china-nyc-whistleblower-uf...


Isn't that basically the same as a National Security Letter and its attached gag order in the USA?


It's along the same lines, but an NSL can be challenged in court (the FISC is a secret and lopsided court, alas). Companies like Apple and Google have fought specific orders publicly (and possibly some secretly), and some have won.

NSLs are also narrow in scope: they compel data disclosure, not active technical assistance in building surveillance systems like the Chinese law.

The Chinese laws can compel any citizen anywhere in the world to perform work on supporting state military and intelligence capabilities with no recourse. There have been no cases of companies or individuals fighting those orders.


Not at all. If you're an employee at a company that receives a National Security Letter then you can just quit if you want to. Unlike in China, the US government can't force you to keep working there to suit their purposes.


CSS word-break property


This is a perfect Tommy Saxondale story.


Hmmm. OK.

Chris Barrie's (Rimmer in Red Dwarf) old man was in the (British) army and I remember my parents mentioning they met him at one of their mess dinners.

I could go on 8)


have you tried Kagi?


Was Georgi ever approached by Meta? I wonder what they offered (I'm glad they didn't succeed, just morbid curiosity).


...or just ask something only they would know? takes no coordination, works even in a stressful situation, and you can always follow up with more


This was my thought as well. We have a lot of shared knowledge and memories with details that are definitely not shared in any online artifact. Those would be very hard to spoof for any casual attack. We'd have to be talking state level attacks...


This is great advice and will give a good background in programming that mirrors what you would learn in a CS program.

I'd also like to suggest studying the practical side of building software that many university programs don't spend much time on. To help address this gap, John Ousterhout wrote A Philosophy of Software Design. He has retired from teaching, but captured the hard-won lessons in the book.

This type of book offers the perspective I wish I had developed more before working in software teams early on, as it would have made me a more valuable developer right off the bat. Instead, I went deep on architecture patterns and language theory, becoming somewhat insufferable to my peers (who were very tolerant and kind in return!) for the first few years. 20 years later, I can see that I was trying to hammer a CS "peg" into a business-software-shaped hole :)


I see your point about pragmatic software engineering not being valued enough in university programs. Somehow the incentives are not aligned properly, which is unfortunate. I try to be as pragmatic as possible when I happen to teach courses where this makes sense. Next semester I'll probably teach "C programming" again after a few years, which is always fun for the students, who will never see a raw pointer again in their career.


Sure. Someone on /r/LocalLLaMA was seeing 12.5 tokens/s on dual Strix Halo 128GB machines (run you $6-8K total?) with 1.8bits per parameter. It performs far below the unquantized model, so it would not be my personal pick for a one-local-LLM-forever, but it is compelling because it has image and video understanding. You lose those features if you choose, say, gpt-oss-120B.

Also, that's with no context, so it would be slower as it filled (I don't think K2.5 uses the Kimi-Linear KDA attention mechanism, so it's sub-quadratic but not their lowest).


Yeah but now Jon Stewart only does one day a week.


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

Search: