Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "lifetimes"
-
Someone on a C++ learning and help discord wanted to know why the following was causing issues.
char * get_some_data() {
char buffer[1000];
init_buffer(&buffer[0]);
return &buffer[0];
}
I told them they were returning a pointer to a stack allocated memory region. They were confused, didn't know what I was talking about.
I pointed them to two pretty decently written and succinct articles, the first about stack vs. heap, and the second describing the theory of ownership and lifetimes. I instructed to give them a read, and to try to understand them as best as possible, and to ping me with any questions. Then I promised to explain their exact issue.
Silence for maybe five minutes. They disregard the articles, post other code saying "maybe it's because of this...". I quickly pointed them back at their original code (the above) and said this is 100% an issue you're facing. "Have you read the articles?"
"Nope" they said, "I just skimmed through them, can you tell me what's wrong with my code?"
Someone else chimed in and said "you need to just use malloc()." In a C++ room, no less.
I said "@OtherGuy please don't blindly instruct people to allocate memory on the heap if they do not understand what the heap is. They need to understand the concepts and the problems before learning how C++ approaches the solution."
I was quickly PM'd by one of the server's mods and told that I was being unhelpful and that I needed to reconsider my tone.
Fuck this industry. I'm getting so sick of it.26 -
1 - when I actually got the point of OOP
2 - When I got that I could check if a number was odd or even by doing & 1
3 - (in the future) when I will understand lifetimes in rust.20 -
I've been using the Square REST API and I spent one hour thinking there was something wrong in my code until I f** found that THEY were not following OAuth 2 guidelines, which made their workflow incompatible with the OAuth lib I was using, so I had to mark an exception for Square's OAuth from the rest of my OAuths. Specifically, RFC 6749 Section 4.2.2 and 5.1.
However, after reading OAuth 2 guidelines, I became angry at THEM instead. The parameter `expires_in` should be the "lifetime in seconds" after the response. This will always be innevitably inaccurate, since we are not taking into account the latency of the response. This is, however, not a huge problem, since the shortest token lifetimes are of an hour (like f** Microsoft Active Directory, who my cron jobs have to check every ten minutes for new access tokens). Many workflows (like Microsoft, Square, and Python's oauthlib) have opted to add the `expires_at` parameter to be more precise, which marks the time in UTC. However, there's no convention about this. oauthlib and Microsoft send the time in Unix seconds, but Square does this in ISO 8601. At this point, ISO 8601 is less ambigious. Sending a raw integer seems ambiguous. For example, JavaScript interprets integer time as Unix _milliseconds_, but Python's time library interprets it as _seconds_. It's just a matter of convention, a convention that is not there yet.
Hope this all gets solved in OAuth 2.1 pleeeaasseee1 -
Rust is beautiful. Rust is also extremely difficult to understand. What the fuck are lifetimes?! I’ve never seen this shit before in my life.15
-
what are your guys' opinions on rust vs c++? I personally prefer rust. the only thing that I really struggle with in rust is lifetimes. I definitely feel that rust is more modern and it's pretty similar to c++ from what I've seen14
-
Rust lifetimes are taking my only lifetime.
I'm too tired to fix this and probably too old for this stuff.1 -
"Rust, the language that makes you feel like a memory astronaut navigating through a borrow-checker asteroid field. Lifetimes? It's more like love letters to the compiler. Safety first, even if it means writing a Ph.D. thesis to move a mutable reference around."2
-
So I decided to learn sass today... Turns out you need to run that good old watch command every session to make your styling work...
It only took me 42 lifetimes to discover that one...1 -
you either get unreadable rust code or 7 layers of misdirection so that the compiler can work around keeping track of lifetimes
I mean maybe I'm too opinionated about readability. technically the computer can read it so people should just get good I guess -
Saw a discussion on object lifetimes in C++.
I was wondering: Is this an object existential rumination?
What does it mean for an object to exist if it can live and die?1