Hacker Newsnew | past | comments | ask | show | jobs | submit | Calavar's commentslogin

For ergonomics in the general case, I agree that it's not even a question, the Rust/Zig create-and-return approach wins on every count.

However, create-and-return makes in place construction difficult. C++ allows you to construct directly into any pinned memory block with satisfactory size and alignment, whereas create-and-return requires you to construct elsewhere and then copy the bytes. This has downstream implications:

- The address of "this" always changes at least once, which makes self-referential data structures and cyclic data structures more difficult. Now you have a pointer fixup step, or you are passing around some form of handle rather than raw pointers. These solutions can range from trivial to complicated, fast to slow, depending on the specific patterns in your code base. A simpler work around is to always construct with a fresh heap allocation and return a pointer to it, which, again, may or may not be an acceptably performant solution for your particular problem.

- You have to rely on your optimizer to do copy elision, which is not a guarantee. Not an issue for small objects, but it can become an issue for larger ones or for many repeated constructions.


But C++ has the return value optimisation (even the named return value optimisation), where you construct an object in a function and then "return" it, but it's actually constructed in place at the call site (not guaranteed but allowed by the language and widely implemented):

   Foo make_foo() {
      Foo result;
      result.blah = 7;
      return result;
   } 
   Foo f = make_foo();
   
   // Equivalent to:
   Foo f;
   f.blah = 7;
I don't know enough about Rust to know whether it has the same thing, but surely it could? If anything, it feels like it ought to be easier (for the compiler) because Rust moves rather than copies by default, and moves are destructive and bytewise.

Given that, it seems like a language could be designed so that a static method that returns an object could be allowed to construct an object in place. Again, I don't know enough about Rust or Zig to know if that's true of them.


Rust doesn't really have a good answer for guaranteed copy elision or in-place initialization at the moment. The devs are working on it, though (https://github.com/rust-lang/rust/issues/153825).

> not guaranteed but allowed by the language and widely implemented

Ome can make it guaranteed (assuming Foo is an aggregate) by writing:

    Foo make_foo() {
      return Foo{.blah = 7};
    }
This guarantees initialization happens at the end of the function, since you are returning a pure rvalue. Generally a good style rule to adopt and no annotations needed.

All young languages try to guarantee it until they don't. zig also fell into this trap.

What is this abomination? This syntactic aversion to my eyes…

(except they’re right and you just gained +1 to wisdom)


The serious answer is it's the ultra-rare aggregate initialization constructor.

https://en.cppreference.com/cpp/language/aggregate_initializ...

Generally, when you're doing the

    Foo result;
    result.blah = 7;
pattern, it's because Foo is a struct with only public members and no constructor used for passing data around. e.g.

    struct Foo{
        int blah;
        int bar;
        int snafu;
    }
When it's that simple rather than type out:

    Foo result;
    result.blah = 7;
    result.bar = 6;
    result.snafu = 5;
You'd type:

    Foo result = {.blah = 7, .bar = 6, snafu = 5};
Congrats the code is shorter!

It's only rare because it's relatively recent. I expect it to become more widely used because it can be used for simulating named parameters:

   struct Params { int p1 = 1, p2 = 2, p3 = 3, p4 = 4, p5 = 5; };
   void foo(Params p) {}
   int main() {
     foo({.p2 = 12, .p4 = 14});
   }
They have to be in the correct order though:

   // Not allowed
   foo({.p4 = 14, .p2 = 12});

right, first-class support for a special say "must_construct_inplace" keyword on a function returning an object would be an interesting language design direction...

What happens inside

    must_construct_inplace Foo make_foo() { ... }
can be as "inefficient" as your example above, but the compiler would validate & figure out a way to make it an in-place-construction, guaranteed RVO.

(similar to `constexpr` validation)

EDIT: Looks like this already exists under several names ("build-in-place", "placement by return", "result location semantics") in Ada's `return W : Widget do ... end return;`, Carbon's returned var c: Circle; ... return var;`, and Rust has (still open) RFC 2884 "placement by return", and Zig seems to have this fully built-in via result location semantics?!


RVO helps, but it is not necessarily enough. Let's say you have a vector and you want to construct in-place an element with an arbitrary set of arguments.

In c++ this is solved[1] via 1) emplace_back 2) perfect forwarding 3) constructors having an homogeneous name and being selected via overload resolution.

In a language with RVO, it is not enough for 'make_foo' in 'push_back(make_foo(args...))' to guarantee zero copy, 'push_back(x)' must also be able to guarantee that its parameter x is somehow constructed in place.

In practice you need some form of lazy evaluation (call by name, or an explicit thunk or passing the function and parameters separately) or some form of macro expansion.

[1] it does comes with its own set of foot-bazookas of course.


> However, create-and-return makes in place construction difficult

This is definitely the closest thing to an answer in this thread. This is something that languages without constructors do struggle with, yes, and as other commenters pointed out, Rust sees this as a performance issue and is working on it.

Thanks for the informative reply.


As you say C++ needs constructors that are not ordinary functions for things like in-place construction.

However this is a very bad and unnecessary hack, which I consider as the worst mistake of C++ (already present in the first "C with Classes", before becoming C++).

The correct solution is to distinguish output parameters from input-output parameters, like e.g. in Ada.

The difference is that an input-output parameter contains memory on which some object has already been constructed before invoking the function, while an output parameter contains uninitialized memory upon function entry.

In a language that has 3 parameter types (input, output and input-output), constructors are just ordinary functions that have an output parameter of the type that is constructed. No special treatment for constructors is needed.

When defining classes, one would have to optionally specify only a default constructor and a destructor, because these must be invoked implicitly by the compiler. Any explicit initialization of an object would use arbitrary functions with suitable parameter types.

The result parameter of a function should be an output parameter. If an already existing object is passed as an output parameter to a function, inclusively for its result parameter, the compiler would invoke implicitly the destructor for that class, before invoking the function.

Both output parameters and input-output parameters may be passed either by value or by reference, based on compiler or on ABI choices that are appropriate for their types.

When output parameters are passed by value, in registers, the compiler will store an output parameter from its register to the desired location, after the function returns, while when input-output parameters are passed by value, in registers, the compiler will load those registers before invoking the function and store them after the function returns.


Agree. C++17 lets you write factory functions that directly return `T(args...)` and can initialize an `auto foo = make_t();` so in many cases the distinction between rust and modern c++ is diminished.

But still, doing `std::make_unique<T>(args...)` or allocates storage and guarantees to run T's constructor there, and you can even do `std::optional<std::mutex> slot; slot.emplace();` which builds the mutex inside the optional even though a std mutex can't be moved or copied.


I feel like this is leaving out the option of only ever referring to objects by a pointer. this means there's no shenanigans around moving or copying things around, and language semantics can still enforce single owners etc. The main disadvantage to this is that it makes any copying explicit, and introduces some (IMO fairly minor) sharp edges around accidentally modifying objects passed into functions etc.

It also makes everything heap allocated and prevents dense representations, both of which are not good for performance.

Could point to memory from alloca

That doesn’t give you the lifetime freedom aspects of the heap, which is what’s required to not think about it.

So Zig makes 'build-in-place' hard?

That's difficult to believe for a C-like language..


It's a tradeoff thing. In languages like C and Zig you can declare a struct (which, naturally, will start out containing whatever random garbage was at that memory location) and then just begin assigning values to its fields.

But in C++ and Rust, assignment itself is a method which can be overridden. So what does it mean to call a method on an object that doesn't exist yet? Also, destructors have to be run when an object goes out of scope. But what if an error occurs before all the fields have been assigned - now you're destructing objects that don't semantically exist yet, and whose memory contains garbage.

That's why I say it's a trade-off - if they wanted, the designers of C++ and Rust certainly could have just allowed programmers to paint themselves into such corners. But they preferred to disallow these things entirely and instead require objects to be constructed all at once as a semantic unit.


To clarify, Rust doesn't allow overloading the assignment operator. The compound arithmetic assignment operators like `+=` are overridable, but that doesn't pose any problem for the use-before-init analysis, which already prevents all methods from being called on uninitialized variables.

They never said the submissions were concurrent.

Dozens of different journals over several months implies there was concurrency.

C++ committee members (mainly Boehm, but also Stroutstrup) also deserve a lot of credit for giving us a well specified memory model for concurrency outside of functional languages. Rust basically copy/pasted the C++11 memory model wholesale. Rust's fearless concurrency owes a lot to standing on the shoulders of giants.


C++11 borrowed heavily from the Java memory model that came before it.

It's basically everyone learning from everyone else on what works and what doesn't work.


Java deserve a lot of the credit for the happens-before concept that is the foundation of both its memory model and C++'s, but it can't express relaxed access and figuring out how to fit that in was a really big deal.


I don't think fearless concurrency is strongly related to the atomic memory ordering model.

C++ 11 wants to model two non-trivial orderings, Acquire-Release and Consume-Release, but only Acquire-Release is actually usable. So yes, C and Rust both also choose to offer Acquire-Release ordering like C++ but it's also clear that the universe of possibilities is actually smaller than WG21 realised when C++ 11 was developed.

If on your first random stab you guess 65537 is prime, you're correct and you might foolishly assume all those Fermat Numbers are prime and then try say, 4294967297. Nope, that's divisible by 641 for some reason. There are only Five of these Fermat Primes so far as we know, they weren't common after all.


My understanding is that Consume is actually a desirable semantic that models what algorithms often want, and would allow for more optimization than Acquire if implemented properly, but that its failure was due almost entirely to it being difficult to implement correctly in compilers. In particular, the semantic is difficult to preserve across all compiler passes, especially given that existing compilers are essentially 20-40 years of accumulated optimizations that were never designed to preserve this semantic.

I sometimes wonder how difficult it would be for a compiler that was designed from the outset to implement Consume correctly.


Nit: Rust currently adheres to C++20 memory model. At least one notable difference from earlier versions which tripped me up recently is that release sequences aren't extended by further writes.


> but from all models, it's the closest

Care to back this up? What evidence do we have to suggest that back propagation, self attention, and byte pair encoding are mechanistically similar to human cognition? Similarity of the outputs says nothing about similarity of the machinery underneath. Turboprop engines tell us nothing about how birds fly - doesn't matter that they successfully transport millions of people around the world.

I would say that when it comes to higher level cognition, logic engines are more human like even if they only have a tiny fraction of the practical utility of LLMs.


> Turboprop engines tell us nothing about how birds fly

That is not true.

Turboprop engines and flying birds are different things, but there is a set of common properties.

A blade of a screw propeller functions exactly in the same way as a flapping wing of a bird, except that the wing cannot rotate without limits around the body of the bird, so it must stop, change angles and revert the motion, while the blade can rotate continuously around the axis, functioning on one side like a falling wing and on the other side like a raising wing. The similarities between propeller blades and insect wings are even greater, because insect wings cannot change their shapes so much as those of birds.

For now, our understanding of the networks composed of the neurons of animals is much less advanced than our understanding of wings and propellers, which is why there is a much greater uncertainty about whether there are any similar mechanisms in biological neural networks and in LLMs.


Also, AFAIK, insects rely on their (flat) flapping wings to create lift by creating vortices.

"Nothing" may be a little too strong -- physics is physics, after all -- but (small) birds and airplanes have Reynolds numbers about 1000x different and different underlying material science.

Airplanes are engineered (with a very small number of exceptions) to be stable during flight, whereas bird flight is inherently unstable, requiring a lot of specialized cognition so birds can fly.

I would think a lot of cognitive ornithologists (who I really hope exist!) would be interested in finding out about this.

At this point, I'm at the complete end of my knowledge of bird flight!


We already know that the most basic mechanisms in ANN and actual neurons are very different. Spiking and neurotransmitters are basically everything in brains and don't exist in ANNs.


ok, compare a wheel to a human leg. If you look long enough you will find similarities, but you honestly cannot say that you "understand how humans walk" when all you can do is put a man in a wheelbarrow, move it, and say "look! my device accomplishes the same task!"


> A blade of a screw propeller functions exactly in the same way as a flapping wing of a bird, except that the wing cannot rotate without limits around the body of the bird

The "except" in your argument is doing an incredible amount of work. The rotation of a turboprops generates forward force, wings (whether a bird's or a plane's) generate lift. And plane's wings are called "wings" because they, and not the turboprop, mimic the structure and function of a bird's wings.

Regardless, this whole line of argument is missing the forest for the trees.


attention + residual seems kind of like Chomsky's merge operation.


This is always the first response to criticism of LLMs, and it's starting to feel banal, because it's a counter that you can pull reflexively from your back pocket at any time without engaging with the actual content of the criticism. I'm not saying it's wrong necessarily, but rather that the added information value of "have you tried GPT Cosmica 15" in a discussion on LLMs is approaches zero. Because it's such a generically applicable response.


Well, it's just a rephrasing of "I don't share this experience at all."

And it's an easy explanation for why one person can be getting "confidently wrong" results still, and another person hasn't experienced it in a long time.

I'm one who hasn't experienced it lately. I haven't even thought about it in quite some time. Maybe a domain thing, maybe I'm not doing fancy enough work, maybe that guy is using some shitty model.


There are so many other explanations.

Maybe this person is working in a different domain where these tools work less well. Maybe this person is a particular kind of expert where they detect incorrect or suboptimal output that would be difficult for others to detect. Maybe the mechanism they use to evaluate the output is different than what other people use.


Seconding this. It's come to the point where I tried out gemini (argon) and saw it was giving me a wrong answer and was immediately shocked how far behind google obviously still is.


Well, no: it’s a shorthand for “I don’t share your experience AND ALSO your experience is invalid.”


Well yeah. If your exposure to AI is Google ai search then I don't really care what you have to say.


So Kushner's phone was hacked around the same time as Hunter Biden's laptop? Why has the latter captured the media so much more then the former?


Because the latter included clips of the presidents son smoking crack and hanging out with prostitutes? lol


The President’s son being a private citizen versus the President’s son in law being some pseudo-secretary of state?


Did you know Hunter served on the board of directors of a Ukrainian energy company?


Yes? You're describing someone having a private sector job... like how private citizens do...

Did you know Hunter at the time he joined Burisma had an 18-year career as a Yale-educated corporate lawyer, PE and VC investor, and lobbyist?

Obviously he's a nepobaby but nothing on his resume is atypical of the types of people who serve on boards for companies like Burisma.

Top law school, cushy investor and advisory gigs, serving on boards, etc.


It actually was unusual. He had no experience with the energy sector or Ukraine, and he was paid $65,000 per month, which is pretty high.

https://proof.csmonitor.com/USA/Politics/2019/0930/Joe-and-H...


Several people on the Burisma board had little to no experience in the energy sector or Ukraine. In fact most people on most boards have no direct experience in the specific domain of the company. Boards are not operating the company, they aren't managing it. They are governing it. The most common way to become a board member is to invest in the company. Obviously most companies are not investment companies, ergo outside investors are not experts in the company's domain.

Here's the profile of someone who served alongside Hunter. Pretty similar: https://www.sofocleous.com.cy/en/people/christina-sofocleous...

The chairman of the board was a Columbia-educated lawyer from Sullivan and Cromwell (similar to Hunter's Boies Schiller role) who went into investment banking at Merrill Lynch and Morgan Stanley.

By what metric is $65,000 per month "pretty high?" Compared to other Burisma board members? Board members are typically paid the same base salary.


The "similar" profile is the daughter of a guy who's the attorney for a Ukranian oligarch: https://en.wikipedia.org/wiki/Andreas_Sofocleous

Directors at Exxon get about a sixth of what Hunter made: https://contracts.justia.com/companies/exxon-mobil-500/contr... So yes, it's pretty high.


Yes? As described above: it’s the type of educational and career trajectory that is typical of nepobabies. “Here’s another nepobaby” is not a refutation.

I’m not sure what evidence of impropriety one is supposed to derive from a publicly traded American company having a different board compensation scheme than a privately held Ukrainian company… perhaps you could connect the dots more explicitly?


So you agree that she is a nepo baby. That is, not particularly qualified. The thing is, when you are the vice president of the United states, and as the article says, "the Obama administration’s point person on relations with Kyiv", then any reasonable person would say you should be careful about letting your children take advantage of their nepobaby status in Kiev specifically!

Regarding compensation for the position, you had said "of course he was compensated, board members are often compensated". I am pointing out that it is very unusual for them to get that much compensation, to the point where you should be suspicious.


Yes, my view was adequately described here: "Obviously he's a nepobaby but nothing on his resume is atypical of the types of people who serve on boards for companies like Burisma. Top law school, cushy investor and advisory gigs, serving on boards, etc."

That would imply there are many similar nepobabies serving in such roles. "Nepobaby" does not necessarily mean someone is not qualified for a given role. It means they utilize their parents' status to grow their own. Obviously a Senator's child has massive advantages throughout their life. As described above... those advantages often produce exactly the life path he had (just like his Burisma board colleagues, and just like many board members of many corporate boards).

Perhaps you should say explicitly what you mean by "you should be careful about..." What specifically constitutes "being careful" about such a thing? And what exactly are they being careful of? The possibility of an appearance of impropriety?

Getting sweet gigs because your dad is a Senator and then a VP because people love hiring cushy connected people to cushy connected jobs is not, in and of itself improper. It's absolutely a reason to pay close attention to all such family members of all such politicians, but if the "paying close attention" doesn't yield actual evidence of actual wrongdoing, you can't just assume otherwise.

P.S. Don't put in quotes things that people didn't actually say. That was quite clearly not my line of questioning.


Sure, I'll say it explicitly! Government employees are supposed to avoid not only conflicts of interest, but the appearance of conflicts of interest. https://www.lawinsider.com/dictionary/appearance-of-a-confli...

If you are working for the government on relations with a particular country, and your son gets a job paying $750,000 a year working at the biggest company in that country, then you need to resign or get your son to resign.

Please let me know if you want further clarifications.


So when Hunter joined Burisma he also had a cushy job as counsel at Boies Schiller. Probably getting paid $1MM+. Boies Schiller is a US law firm, and Joe Biden is the VP of the US.

Does this also invoke appearance of impropriety to you?


It would depend on the cases he takes. But Burisma interests were very closely tied to Ukrainian interests, which are not necessarily US interests. So it was clearly improprietary.

It is true that there were conflicts of interest for other work that Hunter did, though, such as when his father was visiting China on a diplomatic trip.


The cringey thing about boards of directors in general, and about the discussion surrounding Biden and his scandal specifically, is that board members being picked for superficial reasons and being paid to vote mindlessly with the majority when the board votes is regrettably very common and normal. Perhaps most people don't understand that, and think that "board member" is usually a real job.

> he was paid $65,000 per month, which is pretty high.

I doubt it's high for a petrochemical conglomerate.


Did you know he's actually qualified for the role he had? Do you even know what a board of directors does?


But... So what?


Exactly, Hunter is a good negotiator and has a lot of expertise. I’m tired of people casting aspersions on his success


[flagged]


Can you be very specific in how Hunter "defrauded the American public?" I genuinely have never heard a specific allegation (other than like drugs and hookers and guns, obviously)


This question and the potential answers are honestly the most interesting thing in this thread, so far.



Media had access to the laptop, and we only have second hand claims about the phone.


Boy, that sounds like a job for an investigative reporter with the public interest in mind.


Is there an alternate reality where the dem aligned mass media didn't completely bury the ridiculously salacious laptop story (drugs, money for access aaaand onlyfans level nudity!!) to steer the election?

Because i distinctly recall the head of what to that point I though was a credible journalistic organization saying she didnt want to "waste people's time" with that.


The alternate reality is the one where "dem aligned mass media _did_ completely bury" -- because it's all I heard about for months, and months, and months, and months, and months, and months, and months, and months, and months, and months, and months, and months, and months, and months.


You mean *after* the election, right? At which point it mattered f_all, other than the sheer entertainment value.


I heard about it before, during and after the election. It was everywhere, it just never mattered as much as you wanted it to.


Pretty sure I didn't have any horses in that race - frankly I found the very coordinated campaign by ostensibly-independent journalistic orgs to discredit the story ahead of the election (russian plot! man your tinfoil hats!) far, far more interesting that pictures of Hunter's dong.

Performatively pretending the above didn't happen is intellectually dishonest.


You're moving the goalposts now because your original claim was that "dem aligned mass media _did_ completely bury" the story "to steer the election."

Your hyperbolic and partisan language makes it obvious you aren't simply a neutral observer, and implies that you had a horse in that race, and you're still mad that he lost.

Or else you aren't American, in which case your investment in the Trumpist narrative is just kind of pathetic. Like Americans giving a shit about the British royal family.


> Trumpist narrative

There literally is a NYT article alluding the whole store is fake and should be dismissed, and (post election ) NYT article admitting it is not. Your prefered the definition of "bury" must exclusively involve shovels and earthwork.

Also this, verbatim: https://x.com/NPRpubliceditor/status/1319281101223940096?

Not quite sure what de


Money for access is a stretch, at least if you mean for Joe. Some speakerphone conversations that included no business, and zero evidence of Joe ever doing anything untoward that benefited any of Hunter's associates.

Archer was quite explicit in his testimony that if anything, Hunter was basically scamming them with the illusion of access.

Which, well, is bad, but if anything, the situation reflects that Joe never let his son influence him to do anything corrupt, which turns it entirely into a bunch of TMZ level drama about Hunter's drug and prostitution habits.

And I still heard about the laptop plenty before the election. If that is a buried story, then plenty of widely published and discussed stories would be buried by your definition.

The amount of attention it has received has always been silly.


Biden's laptop was in the possession of a computer shop in the US, and the owner leaked its contents to the media.

Kushner's phone data was in the possession of Dutch intelligence who didn't want the public to know they had it -- and as far as I know, this was not public knowledge until today.


Biden’s laptop was in the possession of “someone” who brought it to a blind computer repair person (seriously!), who then got in touch with Rudy Giuliani, who then leaked the contents to the media… and so we can’t really know who actually gained possession of it. The repair man was blind lol.


I think it's becoming clear that although the media just happily accepts the left-wing bias accusations, they are by no means left-wing. They shouted every random Biden mistake from the rooftops while this administration mostly gets a free pass.


crowd control on 4chan?


> Why has the latter captured the media so much more then the former?

Kushner is a boring nerd and Biden is a Chad with a huge dong.


The ordinary matter that gets tangled up is interstellar dust clouds, not stars and planets.


What are some GNU coreutil extensions that you find you can't live without?


The conventions for the long parameters on the command line.


The use of LLMs to make automatic or semi-automatic decisions on firing weapons. This is already happening [1, 2, 3] and has already led to weapons being delpoyed erroneously against civilian targets [1, 3]. It's easy to imagine it happening again on a larger scale, maybe involving nuclear weapons at some point in the future.

[1] https://gizmodo.com/pentagon-investigators-say-overreliance-...

[2] https://www.the-independent.com/news/world/americas/us-polit...

[3] https://www.nytimes.com/2026/08/24/world/europe/russia-drone...


Establishing a correlation is only a starting point. After that there is an entire field of statistics called causal inference that is devoted to establishing causality using a variety of tools.

The strength of correlation is NOT the only useful metric and should not be mistaken for more rigorous statistical analysis regarding causality.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: