Better HN
topnewbestaskshowjobs
Log inSign up

codeflo

9,664 karma · joined Jun 14, 2010 (16y ago) · 1,504 submissions

Submissions

comment 5y ago · link · parent

The trick is that an empty string doesn’t actually own any data on the heap. It’s basically a null pointer, and all string methods check for that in some way. This is a typical optimization trick that many languages implement (empty lists and strings are very common). Defining new to be const just makes this optimization a requirement.

comment 5y ago · link · parent

IMO, the toy example in the article is too simple to show a good use of the pattern. The builder pattern is great if the builder methods configure complicated invariants and are not just setters. Otherwise, there's nothing wrong with making the struct public, as in

  User { id, email, ..Default::default() }
What's Java-esque is having an irrational fear of using public fields for things that are just data containers, but that's in my experience rare in the Rust community.

comment 5y ago · link · parent

I can’t contribute to the discussion about Google’s rules. I just want to mention that simple uses of templates for generic data structures are very different from template meta programming. I can see how a style guide might allow the former and ban the latter.

comment 5y ago · link · parent

In my observation, the Rust community is very hesitant to use dynamic dispatch, even where it wouldn't hurt performance (true for most things that involve I/O) and would dramatically reduce compile times.

I'm not sure why. The fact that Rust makes dyn traits significantly more verbose doesn't help, of course, but that can't be the only reason.

comment 5y ago · link · parent

It's also a lot more error prone in large programs because misspellings introduce new variables instead of causing an error.

comment 5y ago · link · parent

It's not just your tech stack in the narrow sense, your software also can't talk to anything that changes: no browser, no third party service. Systems are rarely that isolated anymore.

comment 5y ago · link · parent

There’s no shame in simply admitting one was mistaken.

comment 5y ago · link · parent

Modern relational databases are marvels of engineering. But I don't think they would have gotten off the ground if they had needed those three decades to be practical at all.

comment 5y ago · link · parent

We have to be very precise here I think.

Git doesn't really store file changes as events, rather, it's a long chain of state snapshots, in something like a persistent data structure. Sure, the history is all there, but so is the current state in its most efficient form.

DB transaction logs might be considered event sourcing by some definition, but their use is very different. It's purely a technical trick. As a consequence, logs are truncated as often as possible/reasonable, and you never rerun the transaction log from time zero. Very different from the event sourcing idea to keep events as long as possible.

comment 5y ago · link · parent

About half-way in, the author even admits that the article is a bit long-winded and not really getting to the point. Unfortunately, it then still doesn’t get to any point.

But I have sympathies for the author here. It’s sometimes really hard to verbalize conceptual ideas. You “feel” them, but any explanation sounds trivial. It’s likely there’s a bit more to it than your summary suggests.

Not sure what the author could have done better, I struggle with this myself.

comment 5y ago · link · parent

This used to be very different one or two decades ago, when Microsoft's backwards compatibility meant you could migrate your existing code to the new thing with minimal changes. This era is where the "legends" come from. Nowadays, it's exactly as you describe, unfortunately.

comment 5y ago · link · parent

The value of fast wakeup is real. But manufacturers and OS vendors need to actually get their act together and implement this, not fake it in a way that passes reviews but is actually damaging to hardware in the real world.

comment 5y ago · link · parent

I think this is a nice strawman. The difference between an engineer that writes truly good code and pushes the team forward, and one that is simply the only one left that understands their own mess should be obvious to anyone, except maybe the most stereotypically clueless manager.

"10x" is obviously a buzzword and not a literal measurement, but is there any real doubt that productivity differences exist? Or is is just fashionable to not admit this anymore?

comment 5y ago · link · parent

Relatively speaking, those changes are mild. And it’s the first language extension in a decade (since C11). Compared to the insanity that the C++ committee does every three years, that’s a good thing.

comment 5y ago · link · parent

With a bit of outside perspective, the Java ecosystem “solved” a lot of things with frameworks that are language features elsewhere (e.g., modules). So unfortunately, keeping the language simple can sometimes even increase the overall complexity. I think that’s a tricky thing to balance.

comment 5y ago · link · parent

The problem with growing languages is often age more than size alone. Some features turn out to be less useful, or will later be superseded by more general features. But beginners still have to learn all of the the old ways to understand existing code.

C++ is perhaps the most prominent example of this, I’d consider it to be at least three different languages merged into one at this point. JavaScript has also accumulated some weird stuff over the years, like var, == and (arguably) a class-based OO system that doesn’t interact very well with the rest of the language.

One “solution” is using only young languages (e.g. Rust is very large, but young enough that most of its features are still useful). I personally like switching technologies every few years, but as a field, we can’t keep doing that forever. The other idea is using a language that’s more or less frozen, like C.

comment 5y ago · link · parent

Note that tape usage typically depends on the input, so I would distinguish programs and computations (program + input).

comment 5y ago · link · parent

Some parts of mathematics deal with infinite sequences, that is, actually infinite lists of numbers. It's usually assumed, and important for analysis, that these numbers are considered to be "all there" right from the beginning. You can do operations like: Compute the limit. Add up all of its elements. Determine whether two sequences are identical for all entries after the trillionth.

I think this is often part of the misunderstanding when you stumble into a post by someone who's confused about 0.999... = 1. People sometimes write things like: "0.999... only moves closer and closer to 1, it never reaches 1." I think that highlights a deeper point than people usually give these comments credit for. The thing is, 0.999... doesn't "move" anywhere, it's considered a completed object right from the beginning.

Anyway, the point is that Turing machines are not like this at all. They only look at a fixed-size part of the tape during each step, from this follows that they have only used a finite amount of tape at each point of their execution.

So for any given (halting) computation, you don't actually need an infinite tape, you just need "enough", without changing the result. This is important because it makes Turing machines a model for practical computers. For example, the device you're reading this on has gigabytes of tape, and that's big enough for many, many, many kinds of computation.

comment 5y ago · link · parent

I don't doubt that the term is in use, and I understood what you meant. But it's not listed among seven (!) synonyms for computably enumerable on Wikipedia, and more the point, the slides you linked to also don't contain that term.

However, that's not the point I wanted to make. I wouldn't like calling it computably countable even if everyone else did, simply because it gives the wrong intuition about subsets.

comment 5y ago · link · parent

I'm with you, I also found Turing's argument that his machine model captures all of computation very convincing and pointed that out in another thread.

However, for this argument to work, we need to accept both that all computation is captured by Turing machines, and also that what Turing machines do is in fact computable. In essence, Turing machine <=> realizable machine. Maybe some people are more impressed by one, others more by the other direction of that double implication.

comment 5y ago · link · parent

Exactly this. Unbounded doesn't mean infinite, and people are sometimes confused by the distinction.

comment 5y ago · link · parent

I think the more widespread term for what you call "computably countable" is "computably enumerable", perhaps in part to make the distinction more clear. For example, the set of all natural numbers is (trivially) c.e., but has many non-c.e. subsets. But to understand this is understanding the Entscheidungsproblem, so it shouldn't be surprising that this was less clear before that was resolved.

comment 5y ago · link · parent

It seems to be in style now to try to tear down the public perception of past great minds, I recently read a similar article about Hawking. And while this article may have some points, I don't think the overall framing is fair.

I think everyone with an interest in theoretical CS should work through Turing's 1936 paper at one point in their life. For me, the important part of that paper is how convincingly it argues that the proposed machine model is not just yet another model of computation, but a complete model of computation: that everything you could reasonably call computation is encompassed by these machines.

So there's a finality to Turing's definition of computation: these problems are unsolvable not just with this model, but with any reasonable machine model. It's very hard to make the same case for lambda calculus, which is (in my opinion) a large part of what made Turing's paper so groundbreaking.

comment 5y ago · link · parent

I'm not so optimistic. There are some technical things Microsoft did poorly when going from x86 to x86-64, which in my opinion delayed the transition of a lot of software by a decade. And this is with processors that can run both instruction sets natively, where no actual software emulation was required.

To give some context (this started with Windows Server 2003 64-bit and is still how it works in Windows 11): Instead of implementing fat binaries like OS X did, they decided to run old x86 applications in a virtualized filesystem where they see different files in the same logical path. This results in double the DLL hell nightmare, with lots of confusing issues around which process sees which file where. For many usecases around plugins, this made a gradual transition impossible. (Case in point: The memory hungry Visual Studio is currently still 32-bit. Next release will hopefully finally make the switch.)

Also, it’s surprising how much stuff in Windows depends on loading unknown DLLs into your process, like showing the printer dialog. So you run into these problems all the time.

Have they learned their lesson? It doesn’t look like it. Last I checked, x86 on ARM uses the exact same system as x86 on x86-64. If they ever emulate x86-64 the same way, that’s triple DLL hell right there. And I don’t think they’ll get a decade to sort things out this time around.

comment 5y ago · link · parent

The math is correct, but I don't fully agree with the explanation. The saved bits don't really come from uniqueness, taking away 10,000 possibilities out of 2**64 barely makes a dent. The combinatorial savings come almost entirely from ignoring order.

The real question is, what does a dataset have to have a unique list of identifiers be such a significat part of it that this is worth worrying about? Many identifier-heavy datasets have lots of cross references (e.g. n:m relation tables), with lots of repeated identifiers that are actually easy to compress. Am I missing something?

comment 5y ago · link · parent

Or to put it another way, because climate is now a concern that most informed people share, there’s a strategy by some political groups to try to smuggle in other, somewhat less popular demands under the same umbrella: from wildlife protection to deindustrialization to social issues.

comment 5y ago · link · parent

That’s the obvious goal, but what kinds of concrete demands do you hear? I’m trying not to set up straw-men, but I only get things like banning combustion cars and banning plastics. None of which would incentivize the Saudis to pump even one less barrel from the ground. The oil would just go elsewhere for a price that might be slightly less, but is still a very large factor of the production costs.

If one doesn’t realize that, one might implement lots of policies that “feel good”, are very expensive in terms of standards of living, but have no net effect on the climate.

comment 5y ago · link · parent

It should be. It’s that and/or recapturing the carbon, purely from a logical perspective.

But that doesn’t seem to be obvious to every climate activist I ever discussed with, at least a dozen at this point, who would suggest a zillion interventions and regulations, none of which would keep even a tiny bit of fossil fuel unburnt. The climate doesn’t care whether the carbon is released in America or Africa, or whether it’s done for moral or immoral purposes.

Is there a rational climate movement somewhere that one can join? Asking for a friend.

comment 5y ago · link · parent

Of course you can build a GC in WebAssembly. You might have to avoid the native stack and lose some performance that way, but that shouldn’t be too bad I think.

One problem is that this GC doesn’t interact with the browser’s GC in any way. So you have painful memory management interactions when (for example) a DOM event handler references a WebAssembly object which in turn holds a reference to a browser object, possibly with cycles (so simple reference counting isn’t enough).

You can fall back to manual memory management here, but that’s painful to use. To make this work seamlessly, you need a way to trace references across both heaps in one swoop. Last I checked, there was standardization work underway to enable that.

comment 5y ago · link · parent

Does that mean that a) the pointer to the single element is only invalidated on “append” if the slice has no more capacity (this is how C++ vectors work), or b) does the fact that there’s an active reference into the slice always cause a reallocation (copy-on-write style)? If it’s the former, we’re literally in the C++ iterator invalidation nightmare, only without the debugging tools.
1
343536
51