Better HN
topnewbestaskshowjobs
Log inSign up

codeflo

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

Submissions

comment 4y ago · link · parent

How is evaluation order even relevant for RVO?

comment 4y ago · link · parent

> No real guarantees around RVO / NRVO

Shouldn’t Rust in theory have a lot more freedom in defining its calling conventions than C++ has? I wonder if there’s anything that prevents doing RVO by default, or if just hadn’t been a priority yet.

comment 4y ago · link · parent

Figuring out that a number is composite is sometimes a lot easier than actually factoring it (see RSA encryption).

comment 4y ago · link · parent

I hate playing these kinds of games, at least with most people, because they simply can’t answer the questions correctly. It’s frustrating beyond belief. Just one example, I once narrowed it down to a fictional character, so I asked “Was it invented after 1980?” and got a “yes”. The answer, after many failures, was Alice in Wonderland. I’m sure it’s my brain that just works differently here, but I can’t for the life of me figure out why people would choose subjects they don’t know the most basic facts about.

comment 4y ago · link · parent

I’m not sure I get what you mean. You wouldn’t have that many String copies in Java by passing an unchanged String down the call stack. My point is that it’s too easy to make this mistake in C++.

comment 4y ago · link · parent

> perhaps the problem is implicit allocations rather than value semantics?

I think that’s true. Expensive copies should never have been implicit. There was a story some time ago about a single keypress in the address bar of Chrome causing thousands of memory allocations. The culprit: lots of std::string arguments up and down the call stack.

Rust gets this right, with the hindsight of C++’s example: “a = b” is a move operation by default and clone() is always explicit, except for plain data types where copying is literally memcpy — and those are clearly marked as such by the type system.

comment 4y ago · link · parent

I'd say this is misleading, or only technically correct (the best kind of correct). Calling conventions are only the first step. For interop to be useful in practice -- to be able pass more interesting C++ types than integers -- you also need your standard library types to be (and remain) compatible[1]. This currently isn't guaranteed even across versions of the same compiler.

[1] Herb Sutter's C++ ABI effort was supposed to solve exactly this, but unfortunately never went anywhere. The proposal document pinpoints the problem very well in my opinion: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n40...

comment 4y ago · link · parent

What the paper you linked to is doing is an interesting statistical analysis of the behavior of random Turing machines for a given time limit.

I just don’t agree that this can be fairly summarized as “estimating Kolmogorov complexity”.

Kolmogorov complexity isn’t a statistical measure — it doesn’t matter how unlikely the machine that produces the output string is. And the time limit they have to impose to actually run those machines is crucial; some of the machines they have to abort would eventually produce an output and halt.

comment 4y ago · link · parent

Waste of time. 4 minutes of useless filler, followed by 2 minutes of bad voice synthesis. Not convincing at all, and all the padded content just serves to get your hopes up.

comment 4y ago · link · parent

I’m not sure that’s worth remembering specifically. You should really already roughly know the Earth’s circumference, 40k km, and the speed of light, 300k km/s. 40/300 = 4/30 = (4/3)/10 = (1.33)/10 = 0.133.

comment 4y ago · link · parent

Nice. A couple of quick thoughts:

- It might be educational to show the sum of sine waves in addition to the components.

- 55 Hz is really low as the base frequency. I think going up a tiny bit would make it easier to hear the base frequency as you add overtones.

- I think the counting you use might be nonstandard: what’s called the “1st harmonic” should actually be the second harmonic, twice the fundamental frequency. But please double check me there.

comment 4y ago · link · parent

GoogleTest was the one we used. I forgot, but now that you mention it, I remember the expect variations. We had decided against them. It’s a confusing feature in my opinion. If that’s what people mean by “multiple assertions”, then I at least understand where there coming from.

comment 4y ago · link · parent

Which ones? I’ve used at least a dozen at this point, across C++, C#, JavaScript, Rust — and all of them throw (the equivalent of) exceptions on assertion failures.

comment 4y ago · link · parent

I hope you realized the irony.

comment 4y ago · link · parent

Continuations I can live without, but is Scheme at all usable without tail calls?

comment 4y ago · link · parent

I think Pico-8 tries to capture the spirit of 8-bit computing more than the reality. The most popular 8-bit computers came with a BASIC, and many home users (me at the time included) programmed that to move some sprites around, and never really went into assembly language. Lua seems more inspired by BASIC than most modern languages, so Pico-8 feels like coding for a very friendly 8-bit computer with an ultra-high-powered BASIC. But it doesn't really simulate an actual CPU that this BASIC interpreter would run on.

comment 4y ago · link · parent

> you get a set number of cycles regardless of the speed of the host computer

If you look at all the PICO-8 clones/inspired platforms without such a restriction, it's hard to overestimate how prescient this was. Basically all of them had raytraced 3D games in their 200x200 pixel box in week 1, which regardless of palette limitations completely kills the 8-bit vibe for me.

Also, this restriction ensures that all the newest PICO-8 games also run on the very old PCs that children might have access to, which I think was great for the health of the platform.

comment 4y ago · link · parent

Scott's concern with encouraging young programmers is, I think, completely genuine, and a huge part of his writing.

But the line between being genuinely humble and humble bragging is sometimes thin, and people have a different tolerance thresholds for the latter.

It's when he phrases this encouragement as "look, I also felt like an idiot at the start of my career, and look at all the awesome things I've done since then", it also comes across as a bit self-serving, even if unintentionally so. I think some people are simply more prone to pick up on that than others.

comment 4y ago · link · parent

First, I agree that using Perl today feels like using something from a different era. Having sigils at all feels so antiquated to me now.

But the mechanics of the sigil thing never confused me. Either because it was explained to me very well, or possibly -- Larry Wall is a linguist, after all -- because there's an analogy to grammatical cases, which English largely doesn't have anymore, but my native language does.

The sigil depends on what you want to get out of the expression, not what you put in. So @foo would name the whole array, while $foo[2] would name a single element from it.

> If you just need to go one level in you can do either $foo[2] or $foo->[2] depending on your whims. It's kind of madness.

You misremember, but I don't blame you, it's a very unorthodox rule. These are very different expressions.

$foo[2] accesses the second (third depending on how you count) element of @foo. @foo is a "value array", whenever possible, I tended to use those because I found them more convenient and intuitive.

For programmers coming from JavaScript or Python, and people building more complex data structures, using a reference array might be more intuitive. Those are stored in scalar variables, like $foo, but to disambiguate with the syntax for accessing @foo, you have to explicitly dereference it with $foo->[2].

comment 4y ago · link · parent

You're right, Rust is an interesting counterexample to this trend I'm ranting against in years. I'm a fan of it. Whether it ever reaches adoption beyond the tiny fragment of people who dive deeply into technologies anyway remains to be seen, however. I've noticed that the backlash that it's too complex is already starting to build up.

comment 4y ago · link · parent

I'm finding that increasingly, whenever I read "X is a myth", it turns out to be mostly a myth. I guess it's a popular article form, it gets clicks, it doesn't have to be completely true, right?

In this case, Wikipedia makes it pretty clear that while surviving a nuclear attack specifically might not have been an explicit part of the design goals of the designers (which may have started the myth myth), resilience against large-scale failures was exactly the feature that made the technology interesting to its military sponsors:

> Nonetheless, according to Stephen J. Lukasik, who as deputy director (1967–1970) and Director of DARPA (1970–1975) was "the person who signed most of the checks for Arpanet's development":

>> The goal was to exploit new computer technologies to meet the needs of military command and control against nuclear threats, achieve survivable control of US nuclear forces, and improve military tactical and management decision making.

(https://en.wikipedia.org/wiki/ARPANET -- where the quote is sourced directly to an article by this Stephen Lukasik.)

My takeaway is that while the ARPANET creators might not themselves have particularly cared about surviving nuclear disasters, without the completely decentralized packet switching that made this at least a possibility, it wouldn't have ever received the funding to get off the ground.

Shortening this fact to "ARPANET was funded to survive a nuclear attack" is IMO a fair sound-bite sized summary, not a "myth" to be debunked, even though the story has obviously more nuances.

comment 4y ago · link · parent

There’s one common criticism that I don’t get: That Perl 5 is hard to learn. I have a theory about this, but warning, rant incoming.

People used to read programming books. I learned both Perl and C from books; for me Perl wasn’t any harder. Yes, the syntax is unique — but you learned to read weirder things, C++ certainly isn’t any more intuitive in a vacuum.

But of course, few people read books anymore, so where do people learn languages? I guess universities and blog posts. (And increasingly YouTube videos, which have even less content density.)

Universities only teach old versions of Java. Blog posts are limited in size. Sad conclusion: any language that has more than a blog post’s worth of differences to Java 1.x will find it hard to reach very broad adoption.

comment 4y ago · link · parent

Exactly. The way biology solved something may not always be the best way to do it with technology, because the constraints or so different. And to be more blunt, I think none of the problems where technology surpassed human performance were achieved by doing it the exact same way. From locomotion (legs vs. wheels) to playing chess (strategic intuition vs. billions of calculations).

comment 4y ago · link · parent

> In theory, a sufficiently capable AI should be able to drive a car at least as well as a human can using the same input: vision.

In theory, cars should be use mechanical legs instead of wheels for transportation, that's how animals do it. In theory, plane wings should flap around, that's the way birds do it. My point being: the way biology solved something may not always be the best way to do it with technology.

comment 4y ago · link · parent

I don’t think that matters much for the distances we talk about. Any such disruption — even if it’s a new philosophy or religion that makes the colonies stop spreading — would only travel at the speed of light, which means that it would take a long time to reach the frontier of a civilization that expands at nearly light speed.

comment 4y ago · link · parent

I think that’s attacking the conclusion, not the assumptions. Have you put numbers on what you consider “mind-bogglingly unlikely” and done the math on that, given the distances involved?

The authors supposedly have, and I’m no expert, but I don’t find the argument completely ridiculous. The universe isn’t that old compared to its size; I think it’s plausible for two unlikely events to have happened without their causal cones having intersected yet.

comment 4y ago · link · parent

ORMs have the problem that the shape of the interface they provide mostly depends on configuration or data (the SQL schema). In static languages at least, this means that code has to be generated at some point. Tooling and convenience wise, there are differences between the approaches, but conceptually, does it really make a huge difference whether this step happens in a separate tool before compilation (seen here), or inside the compiler (in a macro system like Rust’s), or at runtime (as ORMs tend to do in JITted languages like Java and C#)?

comment 4y ago · link · parent

That comment took a turn.

comment 4y ago · link · parent

I think at these sizes and weights, the GPU needs to become a board that you screw onto the case, like a second motherboard. Sagging solved. Now the noisy fan, replace it with a preinstalled water cooling block to be integrated with your overall cooling solution, voila: noise and weird airflow solved as well.

comment 4y ago · link · parent

That’s really cool! But let’s have a technical discussion about the hiccups some commenters mention.

I’ve experimented with Web Audio stuff in the past, and wasn’t happy with it. It seems to be mainly intended to play back premade music files, not seamlessly playing dynamically generated samples.

Normal audio APIs issue a callback whenever their buffer gets low. This is done in a high-priority thread and has a high chance to work seamlessly even on a very busy system — think computer games. You get called, generate a few more bytes and everything is fine.

Web Audio, unless something changed, requires you to actively, manually schedule sending little audio snippets to the playback queue. You have to use timers for that, which are nondeterministic, and you’re competing with everything else that the JavaScript thread is doing. Any tiny hiccup is an audible artifact, and I had found no completely reliable way to avoid them.

Why is Web Audio like this? Are improvements on the horizon that would make this better?

1
202122
51