[HN Gopher] Pointers and Memory Management in Python
       ___________________________________________________________________
        
       Pointers and Memory Management in Python
        
       Author : zerointensity
       Score  : 58 points
       Date   : 2022-03-20 17:36 UTC (5 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | [deleted]
        
       | gswdh wrote:
       | I don't understand the problem people have with pointers, they
       | are an amazing tool. And the negative attitude towards manual
       | memory allocation just seems like laziness to me and even
       | suggests a lack of understanding for both what you're doing and
       | how computers work.
        
       | MrYellowP wrote:
       | Wow! Thanks! :D
       | 
       | Please ignore the haters, they have little to no idea. :D
        
       | cuteboy19 wrote:
       | Ok now this truly awful                 print(1, 2) # prints "2
       | 2"
       | 
       | Pointers are bad but this implementation is broken. There is no
       | way to do this using pointers IRL.
        
       | faizshah wrote:
       | Cool project, did you learn anything interesting from
       | implementing it?
       | 
       | I think I see that the malloc functionality is provided by some
       | DLLs that you import:
       | https://github.com/ZeroIntensity/pointers.py/blob/master/src... I
       | haven't tried that yet any lessons learned on that or was it
       | pretty straightforward to import some DLLs and start using them
       | in python?
        
       | mkesper wrote:
       | Why not?
       | 
       | Because pointers are broken and harmful.
        
         | linkdd wrote:
         | Once compiled to assembly, every data is accessed via pointers.
         | Every data structure is represented with pointers. Almost
         | everything is a pointer.
         | 
         | According to you, all softwares are broken and harmful?
         | 
         | Programming languages can provide a safe interface to pointers
         | (just like Rust do with `Box<>`, `Rc<>`, `Arc<>`, or C++ in
         | some ways with `shared_ptr<>` and `unique_ptr<>`).
         | 
         | Also, "Why not?" here clearly means "I did it for fun" /
         | "Because I can".
        
           | lr4444lr wrote:
           | Cmon. In a good faith reading, he means as a matter of
           | developer access. And he's not wrong as concerns what 90+% of
           | devs have to get done at their jobs.
        
             | linkdd wrote:
             | Yes pointers are hard to get right. No, depicting it as
             | "broken and harmful" is not ok, even with good faith
             | reading.
        
           | artemonster wrote:
           | Its the same crowd that goes screeching when they see ,,goto"
           | _eyeroll_
        
             | linkdd wrote:
             | Wait until you see people saying "exceptions are glorified
             | goto".
             | 
             | Basically, every statement of the form "X is broken and
             | harmful" either don't understand X, or have read it
             | somewhere else without giving a second thought.
             | 
             | X exists because it had some use at some point. Y and Z are
             | implemented thanks to X. Now we no longer need to do X by
             | hand. This does not make it broken nor harmful.
        
           | aunty_helen wrote:
           | You could extrapolate this right down to the binary layer.
           | 
           | Are lower level technology's more dangerous, no.
           | 
           | Are they more difficult to get right? Yes.
           | 
           | Do we want to stop worrying about finicky correctness or
           | pointers and worry about building more complex things?
           | Probably yes also.
        
             | linkdd wrote:
             | > Do we want to stop worrying about finicky correctness or
             | pointers and worry about building more complex things?
             | Probably yes also.
             | 
             | Which is why I mentioned the safe higher-level interfaces
             | provided by programming languages.
             | 
             | Yet, I think it's important to learn about the lower level
             | technology to better understand the higher level
             | technology.
             | 
             | And definitely stop spitting on lower level technologies.
        
         | kmbfjr wrote:
         | I'll notify the kernel team of this development.
        
       ___________________________________________________________________
       (page generated 2022-03-20 23:00 UTC)