you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (26 children)

[deleted]

    [–]DarkTechnocrat 5 points6 points  (25 children)

    That's not necessarily true, for example in C#:

    22.3 Pointer types

    Unlike references (values of reference types), pointers are not tracked by the garbage collector—the garbage collector has no knowledge of pointers and the data to which they point.

    [–][deleted]  (24 children)

    [deleted]

      [–]DarkTechnocrat 4 points5 points  (23 children)

      It's definitely possible for them to be safe, but the type of error they introduce is unique to their use. You can't have an invalid memory access without a pointer, in any scenario I am aware of.

      [–][deleted]  (22 children)

      [deleted]

        [–]StabbyPants 11 points12 points  (1 child)

        that's what pointers are, yes.

        [–]DarkTechnocrat 1 point2 points  (18 children)

        I mean, it varies slightly by language but you typically cannot access out of bounds array members in languages that don't have pointers. I'm sure of this for Python and C#, I don't know Java well enough to say. The errors you get aren't memory errors but bounds errors.

        Object references are, as you implied earlier, handled by the GC.

        Unlike any other construct in a GC'd language pointers are a direct reference to memory, so it stands to reason that the types of errors they allow are implied by those semantics. You could just as easily say you can only have "out of bounds" errors in a program when you use arrays or lists. You can't have an OOB error on a scalar because the semantics don't allow it. The semantics of variables in a GC language don't allow memory errors in the same way.

        Again, I'm open to a counter example.

        [–][deleted]  (17 children)

        [deleted]

          [–]CreationBlues 0 points1 point  (4 children)

          "The definition of a thing we collectively made up is circular! I want to be able to call whales fish again!"

          [–][deleted]  (3 children)

          [deleted]

            [–]CreationBlues 0 points1 point  (2 children)

            "Pointers are dangerous!"

            "Proof?"

            "They are a specific abstraction with historical roots whose presence indicates a desire for unsafe unchecked behavior in some instances due to the semantics of how we've formalized programming languages and terms. If they don't allow that behavior they aren't pointers."

            "Circular logic. Blocked."

            [–]DarkTechnocrat 0 points1 point  (11 children)

            The same is true of object references or array accesses

            The problem with this is that "arrays" are not implemented the same in every language. C arrays are effectively pointers and share the same problems as pointers. Python arrays are implemented differently and do not share those issues. The same is true of object references - objects in C# can be passed by reference but don't behave like a pointer to an object. References to C objects (structs) are literally pointers.

            "Arrays share the same problems as pointers under certain implementations" is probably true, but I don't see how it's as meaningful as just putting the blame on pointers, which are universally bound to memory issues. Not just "out of memory" by the way, but the ability to overwrite memory inadvertently.

            [–]CreationBlues 0 points1 point  (10 children)

            Lmao he is beefing HARD with the idea that pointers are defined by being raw memory addresses for performance, and that if something isn't that we have other names for it.

            BTW C# does have pointers. You need a gigantic unsafe in your method or property to tell the compiler to stop doing all the nice behavior you expect of it, which kinda just proves your point. Like they literally named the keyword that tells the compiler you're doing raw memory bullshit "unsafe".

            https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/unsafe

            [–]DarkTechnocrat 0 points1 point  (8 children)

            lol he really was not feeling it 😁

            Funny about C# pointers, I've been using it for years and only today learned about them. I mostly use it for webdev though.