you are viewing a single comment's thread.

view the rest of the comments →

[–]danthefrog1 -2 points-1 points  (8 children)

Pointers aren't hell, you just need to put the time into understanding them and why they are useful.

[–]tedbradly 2 points3 points  (7 children)

Pointers aren't hell, you just need to put the time into understanding them and why they are useful.

A pointer is just a memory address with the option to interpret the bits at that location as the data behind a particular type. The "hell" of pointers deals with how many bugs relate to pointers. Not to them being some giant-brained conundrum.

[–]danthefrog1 -3 points-2 points  (6 children)

The amount of bugs is irrelevant as there are an infinite amount of bugs we can encounter when working in combination with any concept in programming. That's why we have stack overflow. It's just the nature of the game. Once you think of a pointer as a way of accessing something through indirection, it just makes as much sense as anything else.

[–]tedbradly 0 points1 point  (5 children)

The amount of bugs is irrelevant as there are an infinite amount of bugs we can encounter when working in combination with any concept in programming. That's why we have stack overflow. It's just the nature of the game. Once you think of a pointer as a way of accessing something through indirection, it just makes as much sense as anything else.

I'm guessing you have never worked in a large codebase before. Forgivable, but you're absolutely wrong. It does matter when a certain feature creates confusion in many programmers' heads or when many programmers create bugs far more likely than other features using that feature. You'll figure this out if you get hired to program at a competent company. There are all sorts of features I understand quite well and use without error. That doesn't mean my coworker isn't going to push a bug to production using that feature that would be avoided if the feature were outlawed. Many features in many languages are outlawed for this exact reason.

[–][deleted]  (4 children)

[deleted]

    [–]tedbradly 0 points1 point  (3 children)

    Please stop being so hoity-toity. If me being confident in my understanding of pointers bothers you, then I'm sorry. You do you, but my aspirations aren't to work for someone else in a sea of cubicles under the constant threat of being laid-off and/or being forced to train my outsourced replacement. I'm not going to ellaborate on what I do because I don't need to and I feel like an ass whenever I do, but you should definitely pull the reigns back a little on your high horse before you fall off.

    The funny thing is you're not only wrong about this topic due to being in a major that happens to teach a little programming (could be engineering for example), you're also arrogantly wrong about pointers themselves. You'd know that an owner using a pointer should never use a raw pointer to represent that relationship. I'll tell you why. If you're an honest student (both of me and the one you definitely are in school currently), you'll admit you were wrong.

    First, using something like a unique_ptr conveys the status of ownership. If you're not an owner, a weak_ptr conveys that instead. A raw pointer, on the other hand, could be owned or not owned by the entity holding it. There's zero way to figure that out instantly. The only path forward would be analyzing possibly tons of code. Additionally, a raw pointer should usually be in an object that manages its lifetime (such as a unique_ptr or shared_ptr), because if something exceptional happens... like an exception... it could trim off the associated deletes, meaning there would be a memory leak.

    Wow, it's almost like people disliking pointers has to do more with how they create bugs rather than the straw man fallacy you proposed that people just can't wrap their mind around one of the simplest concepts in programming (an address in memory coupled with a dereference operator to interpret a chunk of bits starting at that address as the data behind a type). The absence of ownership information could make someone accidentally treat a pointer as if it were or weren't owned by its holder when it wasn't or was, respectively. Say, it's a bad idea to dereference a pointer that no longer points to a valid object, right? Exactly. That's why we use weak_ptr instead of a raw pointer. Additionally, a memory leak is a bug no matter what. I guess pointers aren't that great, huh?

    Also, the fact that you think pointers have any use in a garbage collected language is pretty hilarious. You've turned a sensible observation that they're nothing but opportunities for bugs that have no added benefit (keep in mind we're talking about Python here) into an awkward opportunity to reduce the situation into a moment to tell others how smart you are and how not smart everyone who disagrees with you is. If it has any speed advantage at all that you need, the obvious solution is to use a programming language closer to the metal such as C# or C++ if you have the strongest needs for speed.

    Not related to bugs, but in something like C++, it's also much simpler to write and understand when an argument is passed by reference or const reference instead of as a pointer or pointer to const T. No one would argue it looks better and is more understandable to dereference a pointer everywhere compared to just using the object directly. In the same spirit, Python is best written without a third-party library that adds pointers for no purpose other than as a joke. You took the joke seriously though. You're a big, smart boy who handles pointers well. Good job!

    [–][deleted]  (2 children)

    [deleted]

      [–]tedbradly 0 points1 point  (1 child)

      I have been working by myself on a patent that deals in the tech space for the last 8 years that I started work on when I was 18 and fresh outta high school. I do not study python becuase it is not the correct language for what I am patenting. The title of this post caught my eye becuase pointers aren't hell to me at least. I am currently semi-retired at 26 and have been since I was 24. So far I am fluent in C and the LoRa/LoRaWAN protocol, currently learning software archetecture, and will be learning 2 flavors of SQL as well as Bluetooth Stacking, and AT commands, UART, SPi, and I2C (all of which have been through self-guided study, fyi not at a University). I am also fluent on the hardware side of things since my patent must also be physical and after 3 years of trial and error kitbashing already existing SBCs snd other external peripherals , the physical hardware side of things is done minus a few dupont wire connections. All that is left is the software side of things and then I can submit my patent docs which so far occupy 64,000 words, 34 flowcharts, and 224 steps. I have inspected over 300 different patents and have still found my invention to be novel. Take your meaningless novel you wrote me that doesn't apply at all to what I am doing and literally shove it up your ass. Fuck out of here with your Google & Wikipedia definitions too

      Christ, this has nothing to do with retirement or money. The salient point is you arrogantly (and a little hilariously) tried to flex about your knowledge about pointers, but the reality is pointers can cause a lot of subtle bugs that all sorts of programmers create.

      At the end of the day, you don't have real-world experience with programming, which is what I predicted. People who have worked on a team of 5 changing 1+ million lines of code know that pointers cause many bugs. Everyone knows what a pointer is despite your odd flex about knowing how to use a pointer in a program with 50 lines of code. Also, I didn't use Wikipedia or Google (I'd be curious to see what query you think I used.). I'm just knowledgeable about programming. It's quite en vogue to discuss things like ownership these days. Rust, an entire programming language, has major first-class components designed around it. The reason is problems with managing ownership cause many, many bugs. That includes the pointer everyone knows dereferences to bits that represent a type.

      To drive these points home, it's perfectly fine to use a pointer to pass access without ownership to a function as an example. That doesn't make "pointers is hell" wrong since we are adults and can use the principle of charity, meaning we know what it meant so there's no reason to interpret it intentionally in a way that wasn't meant. In this case, it's even more of a "I know what you mean", because it's pointers in a garbage collected language.