Keith Devens .com |
Wednesday, October 8, 2008 | ![]() |
| Nonsense on stilts! – Derived from Jeremy Bentham | ||
|
| ← Class is over | I hate PHP → |

Simon Willison (http://simon.incutio.com/) wrote:
Keith (http://www.keithdevens.com/) wrote:
Some of that was very interesting... especially the thing about default function arguments being created at compile time and not function call time. But I don't think any of it taught me anything about Python's value/reference semantics that I didn't already know.
Sam Newman (http://www.magpiebrain.com) wrote:
I HATED pointers in C - well, let me correct that, I still do :-) 80% of bugs in C/C++ programs are down to 2 things in my experience - pointers and memory management. Java is fairly consistent when it comes to pointers and objects - everything is a reference, and nothing gets copied as a result of assignment. I'm not sure how it works with Python (I've only dabbled with it) or PHP (never used it), but I do remember pointers being one of the things that really annoyed me with Perl.
Adam Vandenberg (http://flangy.com) wrote:
Not to sound like a language advocate, but I've never had a problem with Python copying stuff or forcing me to copy stuff. Once I internalized "Everything is an object, all objects are passed by reference, numbers strings and tuples are immutable" things made sense.
Keith (http://www.keithdevens.com/) wrote:
Adam, I agree. Python usually just does what you mean and you don't have to think about it. But recently I wanted to take a pointer to a string so I could append to it later, but because I couldn't take a pointer to it I had to approach it a slightly different way.
But importantly, in Python or Java, even if something doesn't do what you want or expect, it's typically clear what's going on and you don't waste much time on it. PHP, to the contrary, has wasted so much of my time in this area that it's just pure evil.
Keith (http://www.keithdevens.com/) wrote:
One more thing that I forgot to mention. In languages like Java, Python, etc. it's impossible to point a function argument to a new place because they don't have the concept of a pointer. However, in all of these languages it's easy to return multiple values, so that limitation isn't so hard to get around. But this limitation also leads to kludges like passing in an array so that you can change the elements of the array and have them show up outside the function.
Raphael wrote:
I totally agree with your complain. I think that there was a real error of conception in all these modern langages (Java, Python, Javascript, Perl, Ruby ??) of getting rid of pointers.
I think that's because pointers are often understood for their "technical" need, instead of their "functionnal ones". The conceptors of these new langages just said : No need to use pointers anymore, as we handle memory allocation ourselves. Ok, that was the technical part of what pointers are used for ...
Ok, but we still need pointers ! Pointers are not evil. This can be done in a very consistent way, integrated with the type system, so that there is no risk of additionnal errors (as in Ada for example)
I liked the way that, in C/C++, objects are physically grouped in a structure, and how some fields are only pointers to other structures. When you copy, link or pass an object, you can figure out what it's exactly made of, and it gives it kind of "physical borders" : The granularity of an object is what's in the struct. Pointers are references to other objects.
Now, objects in modern languages are all mixed in a messy spaghetti graph of references. There is no more granularity or atomicity of an object.
For example, in Java, when you want to serialize an object, you have to take care of what is really part of your object : Not to export the whole world.
I agree to milit for the come back of pointers. What we need is a real new language. It is pointless to develop a bunch of same languages : Python, Javascript 1.5, Ruby : Are just copies of the same concept, with slight variation of syntax / implementations.
I would like a new scripting langage :
- Garbage collection
- Strongly typed, or at least with type inference (like oCaml) :
Developping large projects with weak typing is an utopia : It makes
you loose the time that you get with scripting langages.
- Interpreted, or transparent compilation
- Powerfull complex types (arrays, lists, tuples, dictionnary, ....)
- Handy and expressive syntax (like Ruby, or python : but no indentation driven)
- Explicit pointers and references
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):
Generated in about 0.127s.
(Used 8 db queries)

For a really good understanding of how copying / pointer type things in Python work, take a look at this and this.