3 ms·
One thing I like about Python is that it is easy to determine where every token in a file came from (unless you use wildcard imports, but I suggest not doing th
by pabs3 6y ago
One thing I like about Python is that it is easy to determine where every token in a file came from (unless you use wildcard imports, but I suggest not doing that).
I wonder if there is any way to achieve that sort of thing with C/C++ and other languages.
- notemaker 6y agoI've thought about this too. C libraries usually have sensible prefices though, e.g. curl_, and if not a man-page. So for C specifically I don't have this issue. Ruby though... I really hate it. Overloading on numbers for example. Which module lets you do 5.some_verb? Where did you import it? In python and C you have imports local to the file or included headers. In ruby it doesn't matter as long as it's been imported somewhere in the same runtime?? Absolutely bonkers. PS: I am quite new to ruby so please enlighten me if I have it all wrong :)
- daemin 6y agoI think that's a key trade-off in duck typing and reopening classes and objects. You get immense power to do "cool", powerful, and useful things like that, but at the cost of debug-ability. It's been a while since I really used Ruby in anger but to discover where these things came from you need to just look up the documentation of your dependencies and their dependencies, and see where something got added to. For me most of it came from ActiveSupport, and I ended up using that library by itself in other projects than just Rails.
- notemaker 6y ago"you need to just look up the documentation of your dependencies and their dependencies" Exactly, which seems directly opposed to the Ruby ethos of happy developers. I do appreciate the magic of having stuff like 5.bytes or 8.days, but I don't see the reason for having runtime imports or at least warnings that you're using modules required elsewhere.
- teddyh 6y agoOn every #include line in C, I like to write a comment, listing every symbol used from that include file, in order of first use. I even wrote a Python script to help me re-generate the #include lines for such a C program.