3 ms·
So who does it right? Or at least good? And what is your hot take on what Python does?
by wodenokoto 3y ago
So who does it right? Or at least good?
And what is your hot take on what Python does?
- matheusmoreira 3y agoI think Python does it mostly right as far as dynamic languages go. Like Ruby, modules are programs which run from start to end, altering interpreter state as they go. Unlike Ruby, Python modules execute in a local context which provides isolation. Ruby libraries all share the same global namespace and can clash with each other. Python and Ruby have the same flaw in that they do not have export control. Everything that gets set also gets exported. Ruby excludes only local variables while Python relies on convention. Javascript's system is essentially the same as Python's but with require being a function that returns normal objects instead of an import keyword which magically sets the symbols. At least it was back then, new versions of the language transitioned to a dedicated import keyword. I found the reification of modules into first class objects to be an elegant design, not sure if they discovered problems with it or if they were severe enough to justify that transition. I think a mixture of both plus export control would be best. Syntax is friendly and good for most uses but a function that returns a reified module object is also important since it allows programmatic access to modules, allows creating plugin architectures and much more.