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

We pay a very heavy price for the complexity of modern compilers: slow compilation times even on crazy fast hardware, real-world bugs from undefined behavior propagation, and now here, leaking cryptographic secrets unless heroic engineering efforts are made to prevent it.

What we get in return for all that pain is slightly faster execution — in theory. A recent post on HN actually showed that at least in some cases, modern LLVM compiles to code that actually runs 1-2% slower than an ancient LLVM version.

Shouldn’t we conclude from all this that what we need is a movement to go back to simple, deterministic and fast compilers?

comment 4y ago · link · parent

I wonder what percentage of these Twitter posts are fake (“OMG so lucky LOL”).

comment 4y ago · link · parent

None if that explains why it’s so, how do I put it, fiddly? A flexible tool could still have reasonable defaults. If you rent a managed K8s cluster from AWS, you’re of course fine, but why does deploying it yourself have to be so complicated that the recommendation is now to use a “Kubernetes distribution” like K3s. Why can’t it just be a daemon you install using standard mechanisms?

comment 4y ago · link · parent

I think the article’s missing an important trick: Brainstorming establishes a shared understanding (depending on the group dynamics, you might call it a fiction) that the group, not any individual, came up with the idea. That sense of ownership is psychologically important for aligning the group during the execution phase: People are usually a lot more motivated to implement a plan that they came up with, and if anyone challenges the idea, much more eager to defend it.

comment 4y ago · link · parent

You probably know this, but for reference, while Rust doesn’t support implementation inheritance, it has inheritance and runtime polymorphism at the interface level.

You put your dynamic components into references and smart pointers of the form Box<dyn Component>, where Component is a so-called “object-safe trait” (which is exactly what you’d call an interface in the OO world). These traits can inherit from each other, and you can upcast a Box<ConcreteType> into a Box<dyn Interface> into a Box<dyn ParentInterface>.

comment 4y ago · link · parent

“Wizard” is the right way to put it. There’s a certain kind of “experienced” developer who enjoys being the local guru way too much. Even regardless of technology, their projects are invariably set up in such a way that no one can do anything without them.

C++ seems perfect for these people because there are so many little traps and arbitrary rules to remember. “Ha ha, you wrote for (const auto x: y) instead of for (const auto& x: y)? Stupid fool!”

(Or is it auto&& now? decltype(auto)? I honestly don’t remember and don’t really care.)

I’m not remotely suggesting all or even most C++ experts are like this, but anecdotally, their share is higher than among, say, Python programmers.

It’s not like Rust is particularly easy to learn. On a conceptual level, it’s probably harder than C++ (traits, generics, lifetimes). It’s just so much less arcane.

comment 4y ago · link · parent

In my opinion, UIs back then where created with the expectation that users would learn them. Good designers made learning and discovery easy (bad ones failed, of course), but either way, learning was expected to happen.

Nowadays, UIs are designed with the expectation that users don’t learn them. This limits what software can do, but (I don’t mean this cynically) was probably necessary to bring those apps to the majority.

comment 4y ago · link · parent

Genuinely wondering: Are we at the point where people feel nostalgic about early 2000s computing?

As someone who was in their mid to late teens at the time, I find nostalgia for Windows XP in particular a bit funny because back then, people couldn’t disable the new UI and activate the “classic look” (Windows NT/9x style) fast enough.

comment 4y ago · link · parent

I think Hyrum’s Law should be best understood as a warning for users rather than as handcuffs for implementors: don’t rely on non-obvious implementation details.

I’ve seen software break due to a race condition when an upgrade made something faster. Hyrum’s Law tells us the performance was a hidden part of the interface. Is the solution to never optimize anything? Instead, I claim the client code was broken all along.

comment 4y ago · link · parent

Everything in C++ is just there to solve a weird interaction between <feature that’s in your codebase> and <feature that’s also in your codebase>. The “just learn a subset” crowd is wrong, you really do need to know everything.

comment 4y ago · link · parent

If you’re dealing with pure data, reinterpret_cast/mem::transmute is fine, and for certain types of low-level code, necessary. In Rust, I’ve recently discovered the “bytemuck” crate, which offers ways to do that safely.

comment 4y ago · link · parent

I don’t think so. According to https://stackoverflow.com/a/39382728 (the original SO answer that prompted the linked SO question, and which quotes the relevant parts of the spec), the allocation is not UB, but accessing the member after that (at least without the std::launder trick) is UB. It’s precisely this latter part that I don’t think is very reasonable to have in the spec.

comment 4y ago · link · parent

I think you have to do

  void some_func(foo *f) {
      new(f) foo { 5, 5 };
  }
because no assignment operator is generated for a struct with a const member.

comment 4y ago · link · parent

I realize that, but no variable is const, only the field is. And you don’t need a const_cast to change the value, as the example in the question shows, some_func can do:

  void some_func(foo *p) {
      new(p) foo { 42 };
  }
That’s not UB.

comment 4y ago · link · parent

This confuses me even more than C++ usually does. From the first answer:

  > struct foo{ int const x; };

  > void some_func(foo*);

  > int bar() {
  >    foo f { 123 };
  >    some_func(&f);
  >    return f.x;
  > }
> bar will always return 123. The compiler may generate code that actually accesses the object. But the object model does not require this. f.x is a const object (not a reference/pointer to const), and therefore it cannot be changed.

I like to think I know quite a bit about C++, but I don’t get this at all. Why is f.x a const object even when accessed through a non-const variable? f isn’t const; there’s no const_cast here. At first glance, this looks like a bug in the spec, roughly like confusing

  int const *p
(pointer to const) with

  int const *const p
(const pointer to const). Only the latter will always point to the same thing.

What am I missing?

(Edit: Since it’s a bit hidden in the SO question, the idea is that some_func does something like this:

  void some_func(foo *f) {
      new(f) foo { 42 };
  }
Note that there’s no const_cast here, and f’s storage isn’t const, so this isn’t UB to the best of my knowledge.

BTW, in case it’s not obvious, it’s not all that helpful to reply to the question why the spec is a certain way by tautologically repeating the spec.)

(Edit 2: Unfortunately also very typical for C++ discussions, I just love how people think that C++ confusing me must mean that I’m dumb, and then condescendingly post a wrong answer. Rule of thumb: If you’re confident in your ability to understand C++, you don’t understand it very well.)

comment 4y ago · link · parent

I agree Apple is the bad guy here and even the public discussions were a clown show, who knows how much worse it was behind closed doors. But I’d rather have an inelegant standard than none at all, and I think the problems with WGSL can be worked around.

comment 4y ago · link · parent

I, for one, am highly skeptical about the current wave of ML-enabled “discoveries” in physics and chemistry, where ML models replace simulations. ML can’t reliably extrapolate into never before seen territory in the way a simulation can. This has to backfire at some point.

comment 4y ago · link · parent

Here’s a comment summarizing the official rationale: https://github.com/gpuweb/gpuweb/issues/847#issuecomment-642...

TBH, I don’t find those arguments convincing, but then, WebGPU is largely a political compromise, not a technical one. In a politics-free zone, they’d have standardized a “WebVulkan”, not made an entirely new thing. That would have been on the table, but Apple vetoed it. The same for a “Web-SPIR-V”.

However, I also don’t think it’s that big of a deal in the grand scheme of things. I’m glad we have a viable standard at all.

comment 4y ago · link · parent

I don’t think it’s a matter of trends, we have to look at the particulars of each API.

OpenGL/WebGL aren’t well enough aligned with modern hardware to serve as a cross-platform graphics layer.

That’s where the newer APIs come in. Vulkan, Metal and DirectX 12 all follow similar principles that would work from a technical standpoint, but we live in an age where platform vendors would rather cripple their platform than make it easy to port software. Apple is the worst offender here, because while Microsoft isn’t happy about it and disables it in “metro” apps, at least they don’t prevent GPU vendors from shipping Vulkan support for normal “desktop” apps.

But I’m optimistic about WebGPU: It’s designed to be efficiently implemented on top of the vendor APIs, so platform vendors can’t block it. And it’s low-level enough that it should allow implementing modern games on top of it.

(To clarify: I’m optimistic about WebGPU as an API for desktop applications. For browser apps, it seems like all vendors are on board already.)

comment 4y ago · link · parent

A surprising number of people seem to believe that Bitcoin pioneered all forms of cryptography.

comment 4y ago · link · parent

It’s important that the “angle” isn’t directly the fraction of c, but tanh^-1(v/c). This number is also called “rapidity”, and goes to infinity as v -> c. Yes, hyperbolic angles aren’t limited to [0, 2 pi).

You can’t rotate all the way to lightspeed, that would be rotation by an infinite angle. For any finite angle (i.e. speed below c), you can always add the angle of the bullet to get a new (finite) angle.

comment 4y ago · link · parent

> Not many car brands even diagnose you via submitted video record.

Your post might contain a clue why that is.

comment 4y ago · link · parent

You’re bending logic to the point where I have a very hard time assuming you’re arguing in good faith.

comment 4y ago · link · parent

If you consider the compiler to be part of the platform, that’s mostly true.

I think the hard problem in practice is that headers and templates make for a very fuzzy boundary between library code and client code. Calling C++ from Rust already works fine for traditional OO code, but it’s hard to imagine that anything could ever use modern templated C++ code that isn’t a full superset of C++.

comment 4y ago · link · parent

But C isn’t tied to POSIX any more than it is tied to the Windows API. The standards working groups weren’t stupid, they just tried to specify things in a way that wouldn’t force an inefficient UNIX emulation layer on everyone else.

comment 4y ago · link · parent

I don't think that would work in general: trait methods can have signatures for which you can't synthesize an implementation for the sum type (something that takes a second Self as an argument, like std::ops::Add, comes to mind).

For object-safe traits where this would be possible, you can at least do this at the cost of an allocation, as you probably know:

  fn some_func() -> Box<dyn SomeTrait> {
      if some_condition {
          Box::new(a)
      } else {
          Box::new(b)
      }
  }

comment 4y ago · link · parent

>> It also only works for end applications, as libraries cannot reasonably pin their own dependencies.

> Really?

At least not usefully if types from those dependencies appear on the API surface.

comment 4y ago · link · parent

I'm not sure those are counterexamples.

The discussion is about large standard libraries vs. package managers. C and C++ are even older languages that had neither. Back then, the idea of having a large abstraction layer between the language and the OS wasn't even thinkable -- that idea didn't really appear before the 90s.

If you don't know the size of Java's standard library in the 90s, it's maybe risky to imply that it must have been small. :) Kidding a bit. But to give a hint, it included two different incompatible GUI frameworks by 1998.

JavaScript is from the 90s, but wasn't a standalone programming language until Node.js, which was released in 2009.

C# is the newest non-Go language you mention with a large standard library. It was released in 2000 (so in the 20th century if we're being pedantic), and even it has moved a lot of stuff into Nuget packages that used to be built in. For example, the entirety of ASP.net.

comment 4y ago · link · parent

Actually, the "batteries included" school of library design was a 20th century idea; the trend in the 21st century in all other ecosystems very much goes in the opposite direction: fewer features in the stdlib to allow faster iteration, and strong package managers that make it seemless to mix and match packages.

Go just dodges that trend and does the 20th century thing, as it does for many other design decisions. Just as it has common data structures as hardcoded language features, instead of the ability to build them as abstractions.

To be clear: One can take the position that the trends go in the wrong direction and Go is right to reverse them -- that's a matter of opinion. I just don't think it's fair to argue Go is the language that does the more modern thing.

comment 4y ago · link · parent

The fact that the Rust project resists standardizing too early — which could lead to being stuck with a bad design — is in my opinion one of its virtues.

But I agree that we’re past that point at least for simple async worker threads and simple IO. I don’t follow the progress that closely, but I think work is happening towards standardization there.

1
313233
51