Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python VS Java VS PHP

Name: Anonymous 2010-06-14 8:33

Hey /prog/

Which of the three is generally faster? I know there are some specific cases where one performs much better than it does elsewhere but I am speaking of the common situation.

Name: Anonymous 2010-06-14 10:48

>>10
No. If a language mandates that it should be possible to write some_module.sum = new_and_improved_sum and it would take effect on every expression in that module that used the builtin function sum, then all and every implementation of this language would be slow as fuck.
Not at all. You can do this in C by making the "sum" a function pointer, point it at "builtin_sum", and then change it later if you wanted a different sum.
You can do it on an object level as well, by making a copy-on-write function table in the object's struct that initially points at the functions as defined initially, and when that object's function is modified, build a new function table for it, and update that one function pointer to point to the changed function.
For threads, you'd either have to put a mutex around anything that accessed the function table, or mandate that anyone programming with mutable function pointers and multithreading needs to ensure that any function calls or changes to the function table is protected.
Speed has nothing to do with mutability of data; your argument is entirely stupid.

IHBT

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List