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

I’ve personally never encountered the particular misunderstanding the author dispels here, but I’m sure the post is written from bitter experience. On the one hand, I shouldn’t be that surprised: Unfortunately, programming in C++ is really brutal for people who would rather learn by example than by carefully reading documentation.

But on the other hand, my instinctive reaction is: Come on, is this really something that confuses people? emplace_back is all about constructing something in-place, which is exactly the opposite of moving it there! How can any professional programmer be 180 degrees wrong about the purpose of a function they use regularly?

What I want to say here is that C++ is really hard, and that there are a million subtle things that one simply has to look up instead of making educated guesses. I don’t think people appreciate this difficulty enough.

comment 5y ago · link · parent

When talking about city growth, population dynamics and long timescales, do you really believe those administrative boundaries matter in any practical sense?

comment 5y ago · link · parent

Very interesting, I guess my experience here in Germany was very different. No toilet paper anywhere for 2-3 weeks last March/April, and then suddenly supermarkets drowned in it.

Do you know if these are really meaningful shortages, or if businesses have just kept the signs up to make people feel taken care of?

comment 5y ago · link · parent

I guess that's an accurate analysis of the economic situation in Europe AD 1100, a time period famous for its laissez-faire capitalism.

comment 5y ago · link · parent

I don't like "gotcha" style discussions, but I admit I could have worded that more precisely.

What I meant is: There was no reduction in overall toilet paper production, and people didn't suddenly start to shit more. The shortage was mostly a distribution/packaging issue in the form of "not available in packaging X at location Y". Markets tend to solve that kind of problem incredibly quickly.

comment 5y ago · link · parent

> Berlin can't grow forever

That's not self-evident to me. Why not?

comment 5y ago · link · parent

I agree, although the toilet paper situation was a bit different IMO because the shortage wasn't in the supply chain -- it was absolutely clear that inventories would restock sooner or later. In that situation, higher prices wouldn't have incentivized more production.

Still, supermarkets could have temporarily raised prices 10x and still sold their inventory. Why didn't more of them do it? Presumably, they made the rational calculation that the bad reputation they'd get from such a move would outweigh any short-term profits.

comment 5y ago · link · parent

If anything, the article is too optimistic, because supply isn't constant. We're rehashing Eco 101 here, price controls decrease supply, in housing just with a longer delay. Tragically, that delay may be longer than an election cycle, which explains the political motivation to implement such policies.

comment 5y ago · link · parent

My experience here is very limited, but at least in the Rust world, some ECSs seem to make component dependencies explicit, partially to support scheduling parallel systems execution. That is, if there are two systems where neither system writes any component that the other accesses, they can run in parallel. Is that not common in general?

Godot usually gets a lot of praise of HN and elsewhere, probably rightly so. But I got the same weirdly defensive vibes from reading the article. Performance is the strawman used throughout: claiming you don't need that many objects anyway, claiming that there design is "higher level" -- without ever really explaining what that means. I know from other contexts that the real problem with deep inheritance hierarchies often is code duplication, you simply can't solve the diamond problem. Good job pointing out examples of that.

comment 5y ago · link · parent

I’ve recently become interested in immediate mode UIs, and find that there are surprising similarities to React. In both cases, components are just functions that must explicitly render their child components and pass down any shared state. It’s conceptually a very clean way to handle UI state.

However, React introduces a lot of complexity to avoid unnecessary DOM updates, which makes me wonder about the viability of an immediate mode GUI in the browser using canvas.

comment 5y ago · link · parent

That’s what I get for parroting claims I haven’t verified! That’s great, thanks for the correction.

Hmm, as far as I understand the math, your palette being pure colors shouldn’t really matter if the display calibration were perfect. Which I guess is an unrealistic expectation. :)

comment 5y ago · link · parent

As another commenter has noted, the most likely reason for that is missing gamma correction. An sRGB value of 128 is dithered as 50% black, 50% white, when it should be around 78% black, 22% white.

comment 5y ago · link · parent

That was my read as well, it doesn’t make a difference in terms of the total volume occupied by these “grabby” civs.

Also, one civilization dominating wouldn’t mean that the other one would magically disappear. As a simple assumption, I can imagine the stronger civ expanding into the territory of the weaker one relatively unhindered (in terms of expansion speed). But the weaker civ would still expand outwards as well. If it’s expansion speed isn’t slower, it would continue to grow in absolute size.

comment 5y ago · link · parent

Oh? That’s great then. Not the kind of sloppiness I’d have expected in a compiler blog though. Especially since it deep dives into calling conventions, which differ quite a bit between the two.

comment 5y ago · link · parent

> Support for this flag landed in Clang in 2020 only for X86, SystemZ and PowerPC.

How relevant is x86 code in terms of security? Genuine question. I thought Firefox defaults to x86_64 now even Windows. And in open source land, wouldn’t any OS components that could be compiled with Clang be x86_64 as well?

comment 5y ago · link · parent

Just to be clear, Firefox is my main browser. Maybe we use different websites/webapps, but I run into more and more “optimized for Chrome” messages every year. There are lots of examples all over this discussion.

comment 5y ago · link · parent

If running Chromium is no longer viable, and the web increasingly doesn’t work on Firefox, then for the first time in the web’s history, we don’t have an open-source browser. The web becomes proprietary tech owned by Google. Just let that sink in.

comment 5y ago · link · parent

That’s not a bad idea, but Google has no incentive to merge such an abstraction into Chromium mainline. You’d have to maintain it out of tree against a hostile upstream. I fear that’s impractical.

comment 5y ago · link · parent

As someone who writes Windows software now and then, I’m genuinely excited. I tried using this early, when it was limited to WinRT bindings. It looked promising, but compile times were prohibitive. It seems like they now include a build.rs and have clear recommendations around caching — I hope this solves the problem. Has anyone tried a recent version?

comment 5y ago · link · parent

I think the most mathematically natural way to interpret negative indices is to threat them as numbers modulo list length. Then 0 = length, and -1 = length - 1.

comment 5y ago · link · parent

You want a zero-slice because it’s a simpler base case in almost any even mildly complex algorithm. Without empty lists, you need many additional branches throughout a code base to handle the “no element” case, causing more potential bugs. There’s nothing “8-bit” about cleaner code, quite the opposite.

comment 5y ago · link · parent

> offsets are 0-based, indexes are offsets, therefore indexes should be 0-based

You might dispute the premises, but I don’t see the circle. Isn’t this just “men are mortal, Socrates is a man, therefore Socrates is mortal”?

comment 5y ago · link · parent

I can totally believe that. My point is that a “why not X” article should explain why it’s better, not just name a feature that X nominally also has.

(BTW, bindgen hasn’t changed that much. The expectation seems to be that people write a safe wrapper around the generated bindings anyway, so not a lot of effort goes into making them maximally convenient. I also don’t find that ideal.)

comment 5y ago · link · parent

For me personally, the problem with C++ isn't that it has too many features, but that they interact poorly and require complicated rules to makes them work together. To list a few pairs: destructors and exceptions, templates and inheritance, templates and headers, encapsulation and headers, namespaces and operator overloading.

At least at the moment, Rust's many features are mostly orthogonal and work well in combination. But in some sense, that makes the learning curve even harder, because you can't focus on an "accepted subset" as you would in an existing C++ codebase.

comment 5y ago · link · parent

Ah, the memories: I once cut the compile time of a multi-million line C++ codebase by over 20%, just by removing one single-line use of Boost Spirit and replacing it with atoi.

comment 5y ago · link · parent

I get your point. But even in non-mathy business software, data structure access is so much more convenient in languages with an overloadable index operator:

C#: foo[index] = bar[index];

Java: foo.put(index, bar.get(index));

comment 5y ago · link · parent

It's a bit unfortunate that an article titled "Why Zig when there is C++, D and Rust" mentions a lot of features that are shared by Zig, C++, D or Rust, not always giving credit or explaining how Zig solves these problems better.

Point by point:

- No hidden control flow: Linus Torvalds used to argue for C over C++ for similar reasons. I think it's a valid point for some kinds of systems programming. IMO, the argument is a lot stronger for features like destructors (C++) or Drop (in Rust) because those are truly hidden. At least the + sign is visible, and experienced C++ devs read it as a function call anyway.

- No hidden allocations: This is just a library design choice in C++ and Rust, not baked into the language. The standard libraries of those languages usually favor convenience over the last bit of flexibility and performance. At least in the case of C++, there's an ecosystem of libraries like the EASTL that make different choices.

- No standard library: That's fully supported in common C++ compilers and Rust. If Zig goes beyond what those languages offer, which it might, then the article should probably explain how.

- Error handling: "Zig is designed such that the laziest thing a programmer can do is [...] properly bubble errors up." That's also true for exceptions. Presumably, Zig doesn't have exceptions. This could be explained, and contrasted with Rust's monadic approach to error handling.

- Compatibilty with C: That doesn't tell me much, because C++, D and Rust all have excellent C compatibility.

- Package manager: Great! Both Rust and D also have one, so this might mainly be a point in contrast to C++?

- No metaprogramming: I looked up how Zig treats format strings. It looks like it's possible for functions to have "compile time arguments", and there are some rules around compile-time evaluation of if statements and inlineable loops [1]. At first glance, there might be some parallels to D's metaprogramming capabilities, which also has static ifs and loops, but I don't know if that mechanism is as powerful. It certainly looks elegant, but to me, it clearly is a kind of metaprogramming, not "no metaprogramming".

Having said all this, I'm very happy that there are more languages in this space now.

Maybe at this point, the best strategy for a project like Zig is to address Rust head-on in comparisons like this. It's very unlikely that someone reads this article in 2021, is looking for a new systems language and isn't also considering Rust.

[1] https://ziglang.org/documentation/master/#Compile-Time-Expre...

comment 5y ago · link · parent

A very low-effort way to learn good Rust patterns is to put

  #![warn(clippy::all)]
at the top of your crate’s entrypoint. This enables Rust’s default linter. It’s a lot more friendly and focused on good design than you might expect, often suggesting more elegant alternatives. Plus, many of its suggestions can be applied automatically in an environment like VS Code + rust-analyzer plugin.

comment 5y ago · link · parent

Interesting thought experiment. However, you have to realize that Sun wasn’t a charity. At the time, platform vendors were were hoping to target intranet applications for the enterprise. Microsoft had a similar concept for trusted applications with IE’s “Active Scripting”, with very similar results in terms of (non)security.

comment 5y ago · link · parent

I’m not sure either. There are some technical differences. WASM is more low-level than JVM bytecode, which is important for some applications and makes it a more normal compiler target. It’s more integrated with the rest of the browser: it doesn’t come with its own rectangle like Flash and Java did, but instead manipulates the DOM just like (or at the moment, only through) JavaScript. And it’s a true open standard, not a corporate-controlled platform.

Do these differences really matter, or is it mostly just the timing?

1
383940
51