5 ms·
"I see OOP as a heresy in general" Rndm_access, I know everyone is entitled to their opinion, but can I probe a bit on this? Can you tell us about the largest
by schaefer 5y ago
"I see OOP as a heresy in general"
Rndm_access, I know everyone is entitled to their opinion, but can I probe a bit on this?
Can you tell us about the largest code base you feel productive in?
How about the largest code base you love?
How many lines of code are they? How many active developers do those code bases have (i.e. developers with weekly commits)?
Do you have trouble staffing new engineers?
Thanks for any reply given.
- throwawaylinux 5y agoI don't know what "heresy in general" means regarding a programming language feature, but I dislike OOP in Java and C++ code where I have encountered it. The largest code base I love and feel productive in is Linux kernel which is mostly C and assembly, medium sized project of 30 million lines, probably less than ten thousand active developers (although difficult to judge with the way development on certain features or functions can occur for years on private repositories before being merged), I would say relatively high rate of change for a project of the size.
- vgel 5y agoMy impression of the Linux kernel was that it uses a fair amount of OOP via manually-written vtables, though? For example: http://lxr.linux.no/linux+v2.6.39/include/linux/fs.h#L1569 http://lxr.linux.no/linux+v2.6.39/include/linux/fs.h#L1569
- throwawaylinux 5y agoIt frequently has structures containing objects of different types that have to identify themselves so they can be processed in different ways. This general pattern, and function pointers in C predates formal "OOP" of course, so I don't call it manually-written vtables. But yes it has this and it is a good technique. OOP languages which do this automatically for you is AFAIKS just a thin and often clunky layer of syntactic sugar on top of it.
- Const-me 5y ago> just a thin and often clunky layer of syntactic sugar on top of it. That sugar does help. C allows adding another function pointer to that structure, but not set that pointer. C++ compiler forces programmers to implement all interface methods. Forget to override a method, the code which instantiates the class won’t compile complaining about not being able to instantiate an abstract class. Code navigation is another thing. In visual studio, while the cursor is over an abstract method, F12 key looks up all implementations of the abstract class, and populates the “find symbol results” panel with a clickable list of the implementations of the method. With visual assist addon installed, Alt+G key does the same only presents the results in a popup menu instead of a separate panel. Both things are borderline useless for small projects, but IMO they help a lot for medium to large ones, especially developed by multiple people.
- throwawaylinux 5y ago> That sugar does help. I've never found it very compelling. As I said there are also downsides, inflexible implementation that is implementation specific (so it can be difficult to manipulate with low level assembly). > C allows adding another function pointer to that structure, but not set that pointer. C++ compiler forces programmers to implement all interface methods. Forget to override a method, the code which instantiates the class won’t compile complaining about not being able to instantiate an abstract class. Never found that particularly helpful if the code is structured well. You'd either allow for NULL implementations to be default or error not implemented at least until all subsystems are converted, or the initialization functions that all object allocations should call (because the code is well written) can verify all required fields are set. If you want to be even cleverer, you can probably do static initialization checks at least where your fields are constant and have those compile down to nothing just checked at compile time. > Code navigation is another thing. In visual studio, while the cursor is over an abstract method, F12 key looks up all implementations of the abstract class, and populates the “find symbol results” panel with a clickable list of the implementations of the method. With visual assist addon installed, Alt+G key does the same only presents the results in a popup menu instead of a separate panel. I can see how that might help a little, although surely with some minimal scripting a symbol browsing tool should be able to be taught about similar patterns like find all functions that are assigned to this particular member of a structure of function pointers. Although I don't use IDEs or any symbol tagging tools just grep usually, so maybe I'm a luddite. With a nice code base that follows reasonable conventions and naming, it's pretty easy to find e.g., if you have a structure-of-function-pointers style of thing then you can find all definitions of "struct address_space_operations" or if a function pointer member is called page_mkwrite, then you search for *_page_mkwrite and get ext4_page_mkwrite, xfs_page_mkwrite, btrfs_page_mkwrite, etc. (which are not always strictly enforced in Linux but at least if you are searching for \.page_mkwrite you can usually easily see non-confirming names). > Both things are borderline useless for small projects, but IMO they help a lot for medium to large ones, especially developed by multiple people. I don't see that it helps a lot, and even as syntactic sugar I don't see it being a big advancement in the scheme of things.
- GoblinSlayer 5y agoFile descriptors are fundamentally polymorphic, they can be files, pipes, sockets, signalfd, eventfd and the list is ever growing, everything is a file.