5 ms·
if you add unnecessary hierarchies in your code directories That's one of the things I've noticed a lot especially with open-source projects on GitHub, and it
by userbinator 5y ago
if you add unnecessary hierarchies in your code directories
That's one of the things I've noticed a lot especially with open-source projects on GitHub, and it absolutely does irritate me when what should really be a single-file or maybe at most 2-3 file project turns into a dozen files of little content spread out across a maze of deeply-nested directories. I wonder what compels people to do that --- is it a fetish for organisation, attempting to emulate other projects, or trying to make something look more complex and "impressive" than it really is?
I've heard it said that expert code looks like beginner code, except simpler and more correct.
- runawaybottle 5y agoIt’a funny that’s the first (and often simplest and most gratuitous) form of abstraction. What does compel people to start here? It’s like when you read about serial killers, the first thing you find out is that they started with torturing animals. I almost want to make a simple programming interview test (perhaps a Rorschach test) where the task is to take something simple and create a directory architecture - the more files the better. I’d only hire the person that doesn’t do the task. If you see dozens of files when the picture is presented to you, then I’m worried.
- d110af5ccf 5y agoRelated: FizzBuzz Enterprise Edition (https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...)
- runawaybottle 5y agoLol, the GitHub issues page is amazing for this: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition/issues https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris... https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition/issues/509 https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris... Also the latest PR: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition/pull/515 https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
- LAC-Tech 5y ago> I wonder what compels people to do that Two big reasons. It's enforced in Java that 1 class = 1 file. And it's highly encouraged in C#. Also encouraged in react with components. So what you end up with classes that are too big and files that are too small. This goes hand in hand with a lot of editors (vs code, sublime text, atom) having the ctrl-p shortcut to find files.
- userbinator 5y agoI see it in projects written in languages which aren't any of those. Even C.
- kryptiskt 5y agoEvery source file in C corresponds to an object file, and the linker can only exclude unused code if the entire object file is unused. So if you want to optimize your library to for size when linking it statically, it needs to be split up into many source files. See the musl libc for how that can look taken to an extreme: https://git.musl-libc.org/cgit/musl/tree/src/stdio https://git.musl-libc.org/cgit/musl/tree/src/stdio The opposite problem, that the compiler can't optimize over object file boundaries, was the impetus behind Link Time Optimization (LTO). But that could also be handled by pasting all the source into one giant file. See SQLite's amalgamation for one example: https://www.sqlite.org/amalgamation.html https://www.sqlite.org/amalgamation.html
- userbinator 5y agoThere are options to the compiler to allow it to remove unused functions, such as placing each function in its own section.
- account42 5y ago> The opposite problem, that the compiler can't optimize over object file boundaries, was the impetus behind Link Time Optimization (LTO). But that could also be handled by pasting all the source into one giant file. See SQLite's amalgamation for one example: https://www.sqlite.org/amalgamation.html https://www.sqlite.org/amalgamation.html Unity / jumbo builds are not that uncommon but they are not exactly the same as LTO: 1. You no longer have compiler-enforced private intefaces (ie static in C, anonymous namespaces in C++) as everything is a compiltion unit 2. As a consequence of 1. all names must be globally unique. This is less of a problem for new projects, but means you can't just turn on unity builds like you can with LTO. 3. With LTO, parts of the compilation (parsing and initial local optimizations) can be done for each source file and then cached so they don't need to be re-done when another source file changes, allowing faster incremental builds. On the other hand, unity builds allow the compiler to only parse each header once (and for C++ only instantiate templates once for identical parameters), which can significantly speed up (single-core) full builds. 4. Compilers traditionally were mostly single-threader and relied on compiling multiple files in parallel to make use of multi-core CPUs. This approach works with neither LTO nor jumbo builds but with LTO, compiler writers have been working on parallelizing the optimization process itself. The same could have been done with jumbo builds but if you are going to involve compiler modifications anyway, might as well build LTO to avoid 1. and 2. LTO with a linker plugin (or unity builds with -fwhole-program or equivalent) also covers your size optimization as the compiler can now see which functions go unused.