Readit News logoReadit News
grogers commented on I wasted weeks hand optimizing assembly because I benchmarked on random data   vidarholen.net/contents/b... · Posted by u/thunderbong
scottlamb · a month ago
> It's not like C++ users don't say the exact same thing about String, though.

If they do, they're wrong, as the two languages are quite different here. In Java, String requires two allocations: your variable is implicitly a pointer to String allocation, which in turn has a pointer to a char[] allocation. In C++, the std::string itself is a value type. The actual bytes might be inline (short string optimization) or behind a single allocation accessible from the std::string.

Rust's std::string::String is somewhere between: it's a value type but does not have a short string optimization (unless you count the empty string returned by String::new).

> Different people and programs always have a different notion of what a String should do (Should it be mutable? Should it always be valid UTF-8? Which operations should be O(1), O(n) or O(n log n)? etc.)

Sure, there can be call for writing your own String type. But what's unique about Java as compared to say C, C++, Go, Rust, even to some extent C# is that you can't have a class or struct that bundles up the parts of your data structure (in the case of a mutable string, two fields: data pointer/capacity + the used length) without boxing. There's a heavy cost to any non-primitive data type.

grogers · a month ago
Also, you can't construct a java String without copying the data into it, because String is immutable. In other languages like c++ or rust the string type is mutable so you don't need an extra copy. Java doesn't even special case blessed APIs like StringBuilder to avoid the extra copy, since StringBuilder itself doesn't have a method to consume the inner buffer, you can only create a string from it without touching the buffer even though it's not the normal usage to create multiple strings from a given StringBuilder.
grogers commented on I wasted weeks hand optimizing assembly because I benchmarked on random data   vidarholen.net/contents/b... · Posted by u/thunderbong
kazinator · a month ago
If they were forking that JVM in order to offer it as a development tool to a broad developer base, then such an optimization might be worth keeping.

Someone out there might have an application in which they are serializing large numbers of large integers.

The case for abandoning it is not as strong, since you don't know who is doing what.

It's a guessing game in programming language run-times and compilers: "will anyone need this improvement?" You have room to invent "yes" vibes. :)

grogers · a month ago
If the distribution of numbers you are serializing is uniformly random, you generally wouldn't choose a variable length encoding. Sometimes the choice is made for you of course, but not usually.
grogers commented on phkmalloc   phk.freebsd.dk/sagas/phkm... · Posted by u/fanf2
grogers · 2 months ago
> Reasonable people who’s opinions I respect, have called this hack anything from “brilliant” to “an afront to all morals”. I think it is OK.

It's definitely a clever hack given the constraints of malloc, but this anecdote made me smile very widely.

In addition to multi-core becoming the norm causing it to be less performant than alternatives, I imagine the "sanity checking" aspects of phkmalloc were subsumed by things like ASAN.

grogers commented on US Supreme Court limits federal judges' power to block Trump orders   theguardian.com/us-news/2... · Posted by u/leotravis10
acoustics · 2 months ago
The majority seems too trusting that the government will appeal its losses.

Strategically, the government could enact a policy affecting a million people, be sued, lose, provide relief to the named plaintiffs, and then not appeal the decision. The upper courts never get the opportunity to make binding precedent, the lower courts do not get to extend relief to non-plaintiffs, and the government gets to enforce its illegal policies on the vast majority of people who did not (likely could not) sue.

grogers · 2 months ago
IANAL but isn't any ruling by even a lower court precedent? Like if I sue the government for thing A and a lower court rules in my favor, doesn't that make the next plaintiff's case for sueing the government for thing A much easier? All it seems to do is make everything much less efficient.
grogers commented on How multiplication is defined in Peano arithmetic   devlinsangle.blogspot.com... · Posted by u/nill0
grogers · 2 months ago
After reading it, I still don't understand why the hate for "multiplication as repeated addition" compared to the recursive formulation. For programming at least, iteration and recursion are functionally equivalent (or at least convertible to each other). What's "wrong" with respect to that formulation for math?
grogers commented on Tell HN: Help restore the tax deduction for software dev in the US (Section 174)    · Posted by u/dang
yojo · 3 months ago
The argument I’ve heard is it specifically makes investing in speculative software (new product lines, new features, etc) more expensive.

If you’re doing new drug discovery at a bio-lab, treating all your failures as depreciating “assets” seems bonkers. The same seems true of much software development where the work product ends up thrown away.

grogers · 3 months ago
How does this compare to a machine that breaks and is thrown away before its amortization is complete? For the machine can you immediately deduct the remaining amount or is it required to continue to spread the value over the original time period?

I would imagine software that is thrown away should be similar?

grogers commented on More Everything Forever   nytimes.com/2025/04/23/bo... · Posted by u/c0rtex
janalsncm · 4 months ago
I will say that our discourse is weighted pretty heavily towards people who don’t deserve it. Most genuine experts are careful to only talk about things they know, not bloviate about everything under the sun.

I am sure Marc Andreesen is a very intelligent person but he built and sold a web browser. He isn’t an expert on every tech topic. Same with Peter Thiel and the rest of the PayPal mafia. PayPal isn’t revolutionary and getting rich off of that doesn’t make you an expert on (for example) AI.

grogers · 4 months ago
VCs won't be expert level in every area, but they are in a unique position to have a deep knowledge about a lot of different things. It's necessary to be able to invest effectively.
grogers commented on Evolving a NoSQL Database Schema   karmanivero.us/projects/e... · Posted by u/smitty1e
grogers · 10 months ago
I would strongly recommend against using a fixed key 'user' for the hash key on dynamodb, with the range key being used to select the actual record. DDB does not handle splitting by range key very well, so you will run into load balance and throttling issues even with the sharding scheme (i.e. 'user!2') mentioned later.

It will save you a lot of headaches to make the hash key the actual userid (e.g. 'user!abcdef123456'). This will make it more expensive if you do need to occasionally scan all users, but it's not drastically so. You can either do scan and ignore stuff you don't care about, or maintain an index that just contains the userids (in a similar hash/range key as the article) and then do point gets for each userid for the actual data. This will spread the load of these scans out better, because the range scan contains little data compared to if all user data is stored in the range key.

grogers commented on AWS claims its cloud faces competition from on-premises IT   theregister.com/2024/09/1... · Posted by u/laktak
grogers · a year ago
To be honest, whole foods and the go stores could be (at least in some small part) a way to shift their competition base from "online retail" to "all retail" for anti-trust purposes. I wonder if AWS outposts melding cloud to on-prem fulfill enough to be a similar premise of widening the span of competition.
grogers commented on The only two log levels you need are INFO and ERROR   ntietz.com/blog/the-only-... · Posted by u/acossta
JohnFen · a year ago
I agree. I found the argument against DEBUG and TRACE to be particularly weird, since it's very rare that you enable these log levels in production code.

While debugging and testing locally, though? They're extremely useful.

I think they're also useful in production code, although much more rarely. I've had a few times when a customer is having a strange problem that higher log levels helped to quickly resolve.

Being able to have them enable the higher log levels, reproduce the issue, reduce the log level to normal, and send you the logs can occasionally find an issue that would have taken forever to track down otherwise.

And that's not even to mention special processing. In the unices, anyway, the log daemon can take different actions depending on what level the log message was issued at. CRITICAL errors can result in automatic notification to a dev, for instance.

grogers · a year ago
The problem with doing this with logging is that the frameworks usually make it hard or impossible to selectively enable debug logging for just one customer, or just one in a million requests, especially if you want to do it dynamically (which you usually do). These patterns are far more useful than enabling debug logging for everything, because that just creates a spew and slows everything to a crawl. So you usually end up rolling your own sampling that you manage yourself.

u/grogers

KarmaCake day893March 27, 2009View Original