HNHacker News
TopNewBestAskShowJobs

jcranmer

36,256 karma · joined November 17, 2014

submissionscomments
jcranmer··on The Elizabeth Holmes documentary “You Can See Everything” is deceiving
They could have exercised any sort of reasonable oversight. If you're getting any sort of stonewalling from your business partner, that is a massive red flag, and something that should get you talking to the rest of the board about kicking them out
jcranmer··on Why I Wrote PGP (1991, revised 1999)
I once had a chat with a security professor who had decided to try to get his group to use encrypted email for all of their communications. And they just couldn't get mailing lists working right with encrypted email.
jcranmer··on BIPM decides to stop adding leap seconds to UTC
TL;DR: No more leap seconds. The replacement will not be leap minutes but leap hours.
jcranmer··on Your C is not standard C
The complaint that has been brought up there--repeatedly--is that the term 'discarded' creates confusion with the similar 'discarded-value expression' in C++, which is completely different semantically despite the similar name.
jcranmer··on Your C is not standard C
As far as I can tell, the US didn't start standardizing the power plug until the 1940s, and the current three-prong system doesn't come about until the 1960s. The actual receptacles themselves have had improvements to them over the decades, the most recent one coming about apparently in 2016.

> I wonder if languages like RUST or GO will ever become ISO standards..

I doubt it, but mostly because everyone I know on the ISO standardization committees have expressed frustration with ISO (the organization) in ways that I haven't seen for other standards bodies like Ecma.

jcranmer··on Your C is not standard C
This is the complete definition of the behavior of left shift operators in C89:

> The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has an unsigned type, the value of the result is E1 multiplied by the quantity, 2 raised to the power E2, reduced modulo ULONG_MAX+l if E1 has type unsigned long, UINT_MAX+1 otherwise. (The constants ULONG_MAX and UINT_MAX are defined in the header <limits.h>.)

You notice what's not mentioned there? What happens if E1 is signed. The standard says nothing. And when the standard says nothing, it's undefined behavior.

jcranmer··on Your C is not standard C
N3863 is one of those papers where what the paper proposed and what was actually discussed in the meeting ended up being rather different things, and it's the meeting discussion that I'm pointing to, not the paper itself.

> Wait. An implementation-defined behaviour isn't allowed to be trap/termination of execution? Okay, make it unspecified then, with the options of trapping or calculating some unspecified (not indeterminate) integer value.

Unspecified behavior also isn't allowed to be a trap. The difference between unspecified and implementation-defined is whether or not the compiler has to document its choice; the difference between unspecified and undefined is whether or not the choice is limited.

jcranmer··on Your C is not standard C
I joined WG14 and WG21 because I was worried that there were not enough people on either committees who had the perspective of someone who works in middle-end optimization rather than the frontend. I haven't written any papers for WG14 because so far all of the feedback I need to give can easily be given merely by discussion on the reflector or during the paper discussions (this is not the case for WG21, and I have consequently written papers for them), and--as a middle-end person--there is actually relatively little feature development for me to specifically propose. Most of the big features I'd want to see included already have active proposals (e.g., _Vec) and there's little reason for me to write a different proposal. Maybe you'll eventually see a paper from me if I take up some of the proposal work for CFP, or if I get around to writing a version of restrict that's based off of the Tree Borrows model. Or maybe if I turn some of my thoughts on multiple return values into a paper, though I don't actually have a proper frontend proposal for that that I like, so it's more likely to remain a reflector message.
jcranmer··on Your C is not standard C
One of the tricky things is that undefined behavior is commonly understood as having an unlimited "blast radius" and implementation-defined behavior is commonly understood as not permitting that kind of "blast radius." So any extension point that needed that unlimited "blast radius" had to be undefined behavior. (This has changed somewhat in modern times, but it does hold a little bit today--I'd point you to the discussion of N3863 at the most recent meeting, but I don't have any minutes that I feel really captured that discussion well enough.)

And one of those kinds of "blast radius" is traps, and I suspect the original motivation for making signed integer overflow undefined behavior was precisely to preserve the ability to trap on signed integer overflow, which couldn't be implementation-defined. But the records of the discussions leading up to C89 and C99 are just too fragmentary for me to be certain.

jcranmer··on Your C is not standard C
> (instead of just being there to make sure special interests are preserved in voting)

This kind of attitude tends to make me suspect that you are disinclined to actually listen to my feedback.

jcranmer··on Your C is not standard C
> Does it mean "If E1 has negative value, or E1 × 2*E2 is unrepresentable, then the behavior is undefined"? Because that's a ridiculous ordinance.

That's exactly what it means, see the change mentioned in https://www.open-std.org/jtc1/sc22/wg14/www/docs/n723.htm. (Previously, in C89, left shift on signed integers was completely undefined, only unsigned integers had a defined left-shift operation.) My guess is that it has to do with signed-magnitude representation causing left shifts to be absolute garbage with negative numbers. You also have to remember that the standard having undefined behavior doesn't preclude implementations from defining that behavior, and this is especially true with the freewheeling nature of a lot of the original undefined behavior introduced in C89 and C99.

> Also, C23 (and C2y) is moving ever closer to actually having defined semantics.

Eh, having seen how some of the sausage gets made, there's definitely been some cases where the overeager urge to rip out undefined behavior from the standard has worsened the quality.

jcranmer··on Your C is not standard C
There's a lot of post-C99 that has somewhat questionable value (_Generic is very much a we-have-templates-at-home kind of feature), but there are some post-C99 features that I'm rather happy to have:

* thread_local and _Atomic support from C11

* fopen("foo", "x") from C11

* aligned_alloc from C11

* CMPLX macro from C11

* C++ attribute syntax ([[foo]] flows better to me than __attribute__((foo)) does)

* C23 finally gets rid of _Who _The _Hell _Thinks _Users _Like _This-style _Keywords.

* Multi-level break/continue in C2y

* Variable declarations in if conditions.

* Some of the new operations like ckd_add or stdc_rotate_left. I do dislike the names, but meh, at least C is starting to gain a competent set of fundamental operations.

jcranmer··on Your C is not standard C
Compilers have, for several decades now, stopped viewing optimization in terms of optimizing the instructions of a function and instead viewed it as preserving the semantics under some machine model. Consequently, it's rather important to actually nail down some of the object model semantics to be able to do things like understand which loads and stores actually need to be preserved, and you can't really do that with just library functions.

And, FWIW, in a lot of high-performance code, the overhead of a function call may be too high for an atomic operation.

jcranmer··on Problems with the Rust Language
There are many problems with the Rust language. None of the things mentioned here are them, though:

1. The Rust Foundation is a legal entity that owns things like the webhosting for servers and stuff that. Are you going to claim that, e.g., the C++ Foundation makes C++ the purview of nefarious evil corporations simply because all of the C++ members are companies?

2. I've never really seen the "social momentum" the author talks about. And even though I work in the kind of environment where you'd think people would be eager Rust converts... I'm pretty much the only person at work who tries to do anything in Rust.

3. "Rewrite-it-in-Rust" memers are viewed negatively by everyone I know, including the actual Rust developers.

4. There's nothing inherent about GPL versus MIT versus Apache or whatnot for Rust libraries. I think the trend in open source over the past decade or so has been to move away from GPL anyways, and that so many Rust packages are non-GPL is simply because Rust code is mostly newer than the heyday of GPL.

5. No, it's not "completely possible" that Rust's compiler contains a backdoor. If you want to, you can bootstrap the compiler from the ocaml-based compiler (which involves way too many steps). I think the mrustc compiler is also capable of building the current rustc. It's pure FUD.

jcranmer··on Banks are now trying to offload the AI data center debt they just underwrote
Honestly, that would be more like the railway mania in the 1840s or, really, insert any "Panic of X" here. Speculative mania has been a thing for centuries and will continue to be a thing for a centuries.

The specific problem of the 2008 financial crisis was that the banks were going out of their way to obfuscate the source of their CDOs so that, even when it was clear in 2007 that the subprime mortgage market was unraveling, you couldn't look at your instruments and figure out whether or not you were affected. The problem wasn't the CDO, it was the obfuscation. And as far as I'm aware, the current debt offerings aren't being obfuscated--if you want to avoid the data center debt because you think it's junk, just avoid the stuff being touted as data center debt.

jcranmer··on Tesla's Robotaxis Blow Through School Zones, NHTSA Petition Alleges
There was a commenter on a similar article a few months ago arguing that speed limits being excessively low is just for trapping drivers and there's no reason for there to ever be speed limits below 30mph.

That's the kind of person I expect who speeds in a school zone.

jcranmer··on Imposing Sanctions on the International Criminal Court
The treaties a country signs up to is a good start on defining what constitutes crimes.
jcranmer··on Reducing undefined behavior in the C language
My knowledge of SQL NULL is rusty, but I think NULL is just plain unordered with respect to other values, more akin to a NaN value in floating-point than an indeterminate value.
jcranmer··on Reducing undefined behavior in the C language
Because uninitialized memory isn't "it could be any possible value." Uninitialized memory is semantically an indeterminate value whose value is not guaranteed to be consistent between different reads of the value. Optimizations generally "choose" a value that is most convenient for eliminating code; for example, when comparing an indeterminate value to another value, it's easiest to "choose" one that makes the comparison just outright false. But these choices are not necessarily consistent between different uses of the value, since there's nothing to force the compiler to remember the value it chose.

(Note that it's not just the compiler that plays the game--a memory allocator might choose to use MADV_FREE for freed pages of memory, which means that at any point until its next write, the OS may replace the contents of the page with a zero page. So if a subsequent call to malloc reuses a MADV_FREE'd page, then reads of that data before anything it has been written to it may suddenly switch to a different value depending on the whims of the kernel.)

jcranmer··on Reducing undefined behavior in the C language
> Dead code removal is unexpected by the programmer, because programmer does not write dead code.

Dead code elimination is like the single most profitable optimization in the compiler, especially in conjunction with inlining and constant propagation that makes several branches become trivially dead. And its removal is very much expected by programmers, because (for example) bounds checking tends to work by generating bounds checks for every possible array access and relying on the compiler to be able to prove most of those bounds checks redundant.

No, my suspicion is you're actually only against certain kinds of dead code removal, but the kinds you're against are so inconsistent that it's impossible to implement a decision program except by including a routine to read the programmer's mind.

jcranmer··on Reducing undefined behavior in the C language
> [1] Said person said the appendices to C99 aren’t authoritative, but if something is in the spec, including in the appendices, it’s authoritative.

That's not true. There is a difference between normative text and informative text. Informative text is not authoritative, and you were citing an appendix that is labeled as informative.

> I am hoping the up and coming C2y spec has very clearly defined behavior when using unintialized memory (ideally where it will work but the bytes can have any values).

It won't. Uninitialized memory can't have "very clearly defined behavior" without breaking essentially every single implementation, and WG14 is very loth to break existing implementations.

jcranmer··on Float and integer arithmetic follow two different paradigms
That is what you have to do enable turning FP exceptions into traps on a hardware level. But the FP instructions your compiler actually emits as hardware instructions bears only a superficial resemblance to the code you originally wrote. Compilers generally assume FP operations are pure operations without side-effects, so it happily speculates them (including ones that might generate the trap you're looking for) on paths where they didn't, or remove them, or evaluate them at compile time instead of run time, etc. Turning this behavior off so that the traps you get are actually the traps you expected to get involves disabling a lot of optimizations.
jcranmer··on OpenAI annualised revenues $20B less than previously signalled
Regulations that limit the ability of investors to invest in private companies, although these have been weakened in recent decades, which helps fuel the growth of private credit markets that allow private companies to stay private.

I'd say it's the growth of private markets to allow companies to keep getting funding even at the $100 billion range while staying private that has fueled the trend to stay private rather than SOX and other new regulations for public corporate governance dissuading them from going public.

jcranmer··on Float and integer arithmetic follow two different paradigms
Sticky flags tend to be really annoying for a compiler to support for various reasons, but principally it makes every operation have a hidden dependency to shared global state that is almost never read. Note that IEEE 754 standardized support for sticky flags 40 years ago, but support for these sticky bits is still poor to nonexistent in most programming languages, and sticky bit stuff for floating-point operations is less problematic than integer operations because FP math is already far more black box in practice.
jcranmer··on Float and integer arithmetic follow two different paradigms
It's no overhead in the same sense that zero-cost exception-handling is zero-cost: turning them on properly (e.g., #pragma STDC FENV_ACCESS ON or equivalent command-line flags) disables a fair amount of optimizations which incurs an overhead in and of itself.
jcranmer··on How did Rosalind Franklin miss the helix in her iconic DNA image? She didn't
> which of course she couldn't, she wasn't a chemist

Actually, of all of the characters involved, she was the only chemist. Watson was a biologist, Crick was a physicist, as was Wilkins. That's why Franklin was ultimately brought in: to make further progress, they needed a chemist with crystallography experience, and Franklin was the one who had that experience.

jcranmer··on Navier–Stokes Lost in Translation
The incompleteness theorems state that every sufficiently complicated logic lets you construct a statement that is effectively "this statement has no proof," so either there exists true statements that lack proofs (incompleteness) or there exists false statements with proofs (incorrectness).
jcranmer··on California closed the Montana license plate loophole
> The United States was built on these very ideals: mini, hyper-localized governance than a larger centralized governance that is not in touch with the people they govern.

That's a common tale of American mythos, but it's not really an accurate portrayal of American history. Hyper-local governance only really existed in New England and never spread outside of it. Most governance centered on states which are--let's be frank--small countries: the median state in population and area is around 40th percentile among world countries, so smaller than average, but not by that much. And if you look throughout the history of states' rights in US history, invariably those advocating for states' rights are bleeding hypocrites. Note that, e.g., when the southern states established the Confederate States of America, they expressly forbid their own states from having the rights they were claiming for themselves in the antebellum period.

Indeed, in many cases, the more localized governance really turns out to just be people who have lost the political debate at the national level, and thus unable to impose their views on everybody, settling for imposing them at the state level and eagerly oppressing those within the jurisdictions where they can win from exercising their differing views.

jcranmer··on What's Earth's dominant species by mass?
> (At least that's true for Americans. The Chinese seem to think in terms of decades and, occasionally, centuries.)

The Chinese political system is just as short-term-oriented as <insert democracy here> on the whole, and I don't think there has ever been a politician in history who ever thought about workable century-long impacts.

jcranmer··on High Diesel Prices Bankrupted 16 Trucking Companies in Just 30 Days
The annual revenue of the trucking industry is roughly $900 billion. That puts their net profit margin at about 3-5%.

I suspect many commenters here work in companies that expect their profit margins to be 10× that.

← PreviousPage 3 of 34Next →