HNHacker News
TopNewBestAskShowJobs

UkrainianJew

670 karma · joined May 27, 2022

submissionscomments
UkrainianJew··on Factory-made homes cut carbon emissions by 45%
Key takeaway:

>Embodied carbon, the CO2 produced during the design, construction and decommissioning phases of a development, is slashed because buildings require lower volumes of carbon-intensive products such as concrete and steel.

So we are likely trading CO2 production for reduction of some physical properties, likely affecting the building lifespan, thermal insulation/soundproofing, etc. It would be interesting to see the details, but like all things sensationalist, the article is extremely sparse on them.

UkrainianJew··on I only care about the helpful notifications, not the promotional ones
>I really wish companies let us turn this kind of thing off

Well, if you are not paying for the service with your money, you are paying with your attention. And this is the mechanism to extract additional attention from you, and it works very well.

UkrainianJew··on Why Rust easily optimizes out smart pointers where C++ cannot?
Well, you can somewhat simplify it:

  int add_two_numbers_smart_way(int a, int b) {
      auto x = std::make_shared<Data>(a, b);
      return add_numbers(x);
  }
But you still get what you ask the compiler to deliver. If you don't specifically ask it to count references, it won't:

  static int add_numbers(Data *p) {
      return p->a + p->b;
  }

  int add_two_numbers_smart_way(int a, int b) {
      Data x(a, b);
      return add_numbers(&x);
  }
Here's the result:

  add_two_numbers_smart_way(int, int):
          lea     eax, [rdi + rsi]
          ret
To answer the original question, it won't optimize the smart pointers away because the smart pointers are not implemented by the compiler. They are a generic construct telling the compiler to allocate memory, increase reference counter, decrease reference counter and free memory. How does it now this is not a unit test for memory allocation API or atomic operations?

A better question would be why C++ went for implementing certain things on the library level instead of the compiler level, and the answer here is probably "historical reasons" and someone's judgement call on flexibility vs performance under specific circumstances.

UkrainianJew··on Why Rust easily optimizes out smart pointers where C++ cannot?
Also, C++ allows you to be explicit about things. Like std::unique_ptr<> that does not have to count references and guarantees at compile time that:

* There will be not more than 1 reference to the object at any time.

* The object will be deleted once the reference dies.

That's a zero-overhead GC that is enforced at compile time.

And that is the main appeal of C++. You can get close-to-optimal instruction-level behavior while still describing things at reasonably high levels of abstraction. Yes, it has a hell of a learning curve, but once you master it, you can beat any other language out there.

UkrainianJew··on Why Rust easily optimizes out smart pointers where C++ cannot?
That's because you are explicitly telling the compiler to create a copy of your shared pointer, that involves incrementing/decrementing the counter:

  static int add_numbers(std::shared_ptr<Data> p) {
      return p->a + p->b;
  }
Try this:

  static int add_numbers(const std::shared_ptr<Data> &p) {
      return p->a + p->b;
  }
You'll get 4 instructions (don't forget to put __attribute__((noinline)) on add_numbers()):

  add_numbers(std::shared_ptr<Data>&):
          mov     rdx, QWORD PTR [rdi]
          mov     eax, DWORD PTR [rdx+4]
          add     eax, DWORD PTR [rdx]
          ret
The only difference is that Rust physically placed the structure in 2 registers (hence just 1 instruction), while C++ physically placed it into memory (hence the need to 2 extra instructions fetching the values).
UkrainianJew··on Ask HN: Anyone else quickly losing confidence in Amazon?
>and the results are all overpriced junk

Oh, the funny part is, for most of this junk you can find exactly the same items at Aliexpress with the same pictures and Chinglish descriptions at a fraction of the price...

UkrainianJew··on Questions candidates can ask about equity compensation
To learn by observing the founding members, understanding the business model, the market, and eventually becoming a founding member of the next company.

Not something you can do on a full-time job of resolving Git conflicts at FAANG.

UkrainianJew··on Internet drama in Canada
So long story short: after decades of mergers and acquisitions, the only 2 options to get home Internet in Canada is through TV cable (owned by one monopoly) or the phone cable (owned by another monopoly).

Monopolies being monopolies are charging the consumers exorbitant prices, making Canada one of the countries with the most expensive Internet.

To create some semblance of competition, the 2 companies owning the infrastructure are required to rent it to smaller service providers (although at arbitrary prices effectively pricing them out). The arbitrary pricing was contested by the smaller providers and the regulator attempted to mandate fixed prices for infrastructure access. That was in turn contested by the monopolies, arguing that they were forced to subsidize the smaller providers.

That said, I think it would be a much better idea if our government had balls to actually separate infrastructure owners from the service providers, and block further mergers. So multiple end user facing companies would compete for access to the same infrastructure, and the infrastructure owners would compete for servicing the providers, not being able to directly own either of them. Both layers would be have the incentives to offer good service at reasonable prices, while the current incentive for the infrastructure owners is to hamper the small players as much as they can.

← PreviousPage 3 of 3