News for hackers. Stuff that matters.
Re:Businesses are in for a mighty debt hangover by packetlost on Tuesday May 16, 2023 @07:23PM (#35969128)
> All I know is that computer programming is qualitatively an entirely different thing than it was six months ago

Citation needed. My day to day has not changed one bit, even if I'm using Copilot and ChatGPT. I get marginally faster autocomplete and a buggy template engine. This type of comment is exactly what GP means when they say "grossly overestimated."

Re:Businesses are in for a mighty debt hangover by jimsimmons on Tuesday May 16, 2023 @07:33PM (#35969222)
Somehow all the non programmers are in full force telling actual coders how their job is changing
Re:Businesses are in for a mighty debt hangover by sublinear on Wednesday May 17, 2023 @02:24AM (#35971882)
This is so blindingly obvious to anyone and I can't believe it's not said enough
Re:Businesses are in for a mighty debt hangover by fnordpiglet on Tuesday May 16, 2023 @08:33PM (#35969765)
I use ChatGPT throughout the day. I don’t find code completion very useful, but I ask questions about esoteric areas I’m unsure of, or about some numerical technique I’m trying to recall. It unblocks me faster than anything I’ve ever used and I’ve learned more about some topics in the last six months than in the last thirty years. The fact I can ask elaborative questions and get answers that are fairly deep and nuanced is remarkable. Code it emits is often specious but fairly close to usable, more than enough to open a door for me in what used to be hours of fruitless searching and reading countless stack overflow answers telling the questioner they’re asking the wrong question and answering something unrelated instead.

That you guys aren’t finding the value tells me you’re using the tool wrong and likely have already decided with prejudice, because I have primary experience that once you try to figure out how it’s useful, you’ll find remarkable utility waiting. It’s ok, man. I’m sure many folks found the computer useless too.

Re:Businesses are in for a mighty debt hangover by packetlost on Tuesday May 16, 2023 @08:39PM (#35969820)
The quality of answers goes down dramatically the more niche your questions are. Further, while it might be helpful for "research", the answers it gives will have very wide variations of accuracy and isn't very useful for the day to day work of an actual software engineer which involves much more than just writing code. It works great if you treat it like a freshman in college who loves hearing their own voice and bullshits answers, but not great at being a fact engine.
Re:Businesses are in for a mighty debt hangover by fnordpiglet on Wednesday May 17, 2023 @12:32AM (#35971276)
This explains fairly clearly a bit of rust that, while not the most obscure, is IMO fairly poorly explained in most resources I’ve found, and covers a lot of edges that are really useful to understand… I can keep digging and digging into the details presented. I find it absurd to say it’s like a freshman in college - I’d love to hire those freshman if you can point them out:

> Explain when pin is important in rust when dealing with asynchronous code, particularly when dealing with Box<dyn> types.

In Rust, Pin is a concept that is central to understanding the implementation of asynchronous operations. To explain why, let's first cover the basics.

Asynchronous tasks often involve future types that encapsulate a computation that will produce a value at some point in the future. These futures may need to poll other futures, which in turn might not be ready, causing them to be suspended and resumed later on. This suspension and resumption is where the Pin concept comes in.

By default, Rust allows moving types around in memory. However, when you have self-referential structures, like many of the future types in asynchronous programming, this can lead to problems. A future may hold a reference to another part of itself, and if the future is moved in memory, that internal reference may become invalid.

Pin is Rust's solution to this problem. If a type is "pinned" (wrapped in a Pin), it is a guarantee that the memory location of the value inside will not change. This means that you can safely keep references to different parts of the same structure because you know they won't move around.

Box<dyn Future> is a heap-allocated future object. Using Pin with Box<dyn Future> (i.e., Pin<Box<dyn Future>>) is common in async code because it guarantees that the future object will not be moved around in memory, making it safe to poll.

However, one should note that simply creating a Pin<Box<T>> does not mean that the T will stay put; it's also necessary to ensure that T does not move itself or its interior around. The contract of Pin is such that, once a value has been pinned, it is not allowed to move or have its memory invalidated until it is dropped. For a type to uphold these guarantees, it must be Unpin or ensure that all its operations maintain these guarantees. Most native Rust types are Unpin and therefore don't need to worry about these guarantees.

In short, Pin is important in Rust's async code as it provides a mechanism to safely handle self-referential structures, which are common in async programming. The Rust async ecosystem uses Pin to ensure that once a future begins executing (is polled), it will remain at a fixed location in memory until it has completed.

Re:Businesses are in for a mighty debt hangover by steveklabnik on Wednesday May 17, 2023 @01:10AM (#35971481)
This is also a good demonstration of how it can be slightly wrong, or maybe misleading

> If a type is "pinned" (wrapped in a Pin), it is a guarantee that the memory location of the value inside will not change.

Pin is a wrapper around a pointer type and disallows moving the value that that pointer points at. You don’t pin a value, you pin a reference to a value. IMHO this sentence is unclear about that.

You sorta get the right vibes from the rest of the post, but there’s a major important concept in here it explains decently but also just wrong enough that you may internalize the incorrect thing.

Re:Businesses are in for a mighty debt hangover by fnordpiglet on Wednesday May 17, 2023 @12:46PM (#35977937)
Interestingly I read what it said as precisely what you said. But you’re right it elides the crucial nuance that the pointer is pinned, and “the value inside” can ambiguously be read as the type is a value and not a pointer to a value. I read “inside” to mean “inside the pinned pointer” but it can (maybe more accurately?) be read as inside the pin is a value.

I agree - it’s not a panacea devoid of human involvement. I think really importantly, whatever failings the technique has, it’s reflective of humanity itself, and humans are often slightly wrong or misleading. I think confusing it’s output with that of a deterministic program is wrong - it’s much more akin to the output of a human than not.

My argument though is it’s not a freshman in college level of human failings. It’s clarity is far beyond that on many subjects, and it’s facility to “understand” is remarkable for a human let alone a computer. The fact I can interrogate it and ask it the clarifying question you bring out is beyond useful - I can dig into the specific areas of confusion I have, and often if it’s wrong I’ll cop to it unlike a human oracle.

> Clarify then: If a type is "pinned" (wrapped in a Pin), it is a guarantee that the memory location of the value inside will not change.

When we say "the memory location of the value inside will not change," what we mean is that the value that the pointer points to is guaranteed to not move in memory. This is a critical guarantee when working with certain types of data, like self-referential structs or certain async code in Rust.

Let's take an example of Pin<Box<T>>. Here's what it means:

Box<T>: This is a heap-allocated instance of T. The Box is a smart pointer that points to this heap-allocated T. Pin<Box<T>>: This is a Pin wrapping the Box. This means that the T that the Box points to is pinned. This does not mean that the Box itself cannot be moved. The Box is a pointer, and pointers can be copied and moved freely. But because we have used Pin, the actual heap-allocated T that it points to cannot be moved. This is what we mean when we say "the memory location of the value inside will not change." We're talking about the T, not the Box.

This is important when the type T has self-references, because moving T in memory would invalidate those self-references. By using Pin, we ensure that T stays put, and those self-references remain valid. This is a key part of the design of Rust's async programming model.

However, this guarantee is only upheld as long as the type T does not implement Unpin, which is a marker trait that indicates that it is safe to move a type out of a Pin. Types that are not Unpin uphold the guarantee that they cannot be moved out of the Pin once they are placed in it.

Re:Businesses are in for a mighty debt hangover by steveklabnik on Wednesday May 17, 2023 @01:26PM (#35978520)
> I think really importantly, whatever failings the technique has, it’s reflective of humanity itself, and humans are often slightly wrong or misleading.

Absolutely, and I don't think every explanation has to be perfect to be useful, hence me saying "you gotta watch out" and not "fuck this tool, nobody should use it."

Re:Businesses are in for a mighty debt hangover by yobbo on Wednesday May 17, 2023 @06:05AM (#35973274)
It may give you explanations/code of numerical methods that run and look very plausible, but are subtly wrong; and you have to know both the language and methods in order to untangle the bug.

But I have found asking questions like "how would I ..?" or "explain ..?" can be useful as long as you don't treat like a final answer.

Programming is one of the fields were correctness actually matters in a binary way. But jobs where "sort of" or 80% is good enough can be replaced with language models.

Re:Businesses are in for a mighty debt hangover by andresp on Wednesday May 17, 2023 @07:28AM (#35973812)
The quality of the answers is often too poor to be used as reference.
Re:Businesses are in for a mighty debt hangover by carlosjobim on Wednesday May 17, 2023 @07:52AM (#35973992)
> All I know is that computer programming is qualitatively an entirely different thing than it was six months ago

^ Your citation, sir.

Re:Businesses are in for a mighty debt hangover by tunesmith on Wednesday May 17, 2023 @04:37PM (#35980960)
I am the primary source of my opinion, give me a break. I'm sharing my own personal experience; it is therefore not an "estimation".

I will say that checking back a day later, I am stunned at how many smart programmer types are clearly not even close to getting how useful this tool is. For people that don't find it very helpful, to me that just means they're not asking enough of it yet. More people just need to spring for the $20/month and start asking GPT4 about any old technical subject they think they know well but about which they might also have holes in their knowledge.

It's a tool that rewards creativity, so you kind of get out what you put in. Many folks here are too young, but back when search engines were coming out, there was a phase for many people where they only knew how to treat it as a toy. Like, search for their own web page to see if it showed up; search for a question they already knew an answer to to see if it was correct. It required a bit of a mental reset; a "click"; before each person would know automatically, without reminding themselves, that they could actually search for things they didn't know.

It seems like there is something similar going on here. It's not a search engine so it's not exactly about stuff we do or don't know, but I gather that a lot of people thus far have not uncovered the advantages it actually gives them.