111 ms·
I feel similar when it comes to non-OOP code. I don't like free functions and global variables just hanging there.
by skocznymroczny 5y ago
I feel similar when it comes to non-OOP code. I don't like free functions and global variables just hanging there.
- matheusmoreira 5y agoYeah, me neither. Names must belong to some namespace, it really bothers me when code starts binding common nouns in a global context. C lacks namespaces so I use prefixes instead. At least this solution doesn't screw up the ABI like in C++. I hate global variables so much it's one of the reasons I got rid of libc. Freestanding C turned out to be a superior language just because it lacks all the libc cruft. I ultimately dropped Ruby because of global state. It's such a wonderful language but it has one fatal flaw: lack of proper modules. The require method just executes Ruby source files, modifying the global state of the interpreter. It ceased to be a beautiful language once I realized this. Python's modules are superior, and the Javascript approach is the best one: just a normal function that returns a normal object containing exported data and functions. Javascript modules are c.ompletely reified.
- kristoff_it 5y agoOOP might have helped popularize usage of the dot notation, but namespaces are a different thing. Zig has no inheritance but everything is namespaced, including declaring functions inside struct definitions so that you can use them as if they were methods.