Earlier quoted context omitted.
Teaching. I had this problem with an overzealous junior developer and the solution was showing some different perspectives. For example John Ousterhout's A Philosophy of Software Design.
I tried this but they just come back with retorts like "OK boomer" which tends to make the situation even worse. How do you respond to that?
John Carmack on inlined code (2014)
181–190 of 402 posts
Re: John Carmack on inlined code (2014)
#182Earlier quoted context omitted.
Maybe "indoctrination" was a poor choice of word here. The problem with this maxim is that it welcomes moral relativism. This can be bad on the assumption that whoever is exposed to the maxim is not a proponent of "virtue ethics" (I use this as a catch-all term for various religious ethics doctrines, the underlying idea is that moral truths are given to people by a divine authority rather than discovered by studying…
> maxim suggests that no matter what your moral framework looks like, you should accept that under some circumstances it's OK to have child marriages You seem to have either misread the maxim, or misunderstood it. The maxim is not that an intelligent person -must- hold two contradictory thoughts in their head at once - rather, that they should be able to. Being "able to" do something, does not mean one does it in all…
The maxim is not used by religious people to its intended effect. Please read again, if you didn't see it the first time. The maxim is used as a challenge that can be rephrased as: "if you are as intelligent as you claim, then you should be able to accept both what you believe to be true and whatever nonsense I want you to believe to be true."
Re: John Carmack on inlined code (2014)
#183The clean code people are losing their collective minds reading that. lol
Re: John Carmack on inlined code (2014)
#184Earlier quoted context omitted.
I know it's overused, but I do find myself saying YAGNI to my junior devs more and more often, as I find they go off on a quest for the perfect abstraction and spend days yak shaving as a result.
Agreed. I’ve been trying to dial in a rule of thumb: If you aren’t using the abstraction on 3 cases when you build it, it’s too early. Even two turns into a higher bar than I expected.
Re: John Carmack on inlined code (2014)
#185Earlier quoted context omitted.
Visual studio doesn't do that inlining. And it is a significant problem, I have had to refactor my code into multiple functions because of it.
It might be a significant problem, but not in the code, but the compiler. Fair enough, you are working around a compiler issue.
Re: John Carmack on inlined code (2014)
#186There is actually a major problem with long functions - they take a long time to compile, due to superlinear complexity in computation time as a function of function length. In other words breaking up a large function into smaller function can greatly reduce compile times.
If you are willing to make code worse to micro optimize compile times (not even sure this is true) then you should not use any modern language with complex type checking (rust, swift, C#, etc).
Re: John Carmack on inlined code (2014)
#187Earlier quoted context omitted.
It means not using explicit functions, just writing the same code as little inline blocks inside the main function because it allows you to see all the things that would be hidden if all the code wasn't immediately visible. To the other point though, the quality of compiler inlining heuristics is a bit of a white lie. The compiler doesn't make optimal choices, but very few people care enough to notice the difference.…
Well there's also compiler directives other than `inline`, like msvc's `__inline` and `__forceinline` (which probably also have an equivalent in gcc or clang), so personally I don't think you need to make the tradeoff between readability and reusability while avoiding function calls. Not to mention C++ constevals and C-style macros, though consteval didn't exist in 2007
Re: John Carmack on inlined code (2014)
#188Earlier quoted context omitted.
Not according to jon carmack. He stated he switched to pure functional programming in the intro which is basically stating all his logic is in the form of unit testable pure functions.
I found this [] article of Carmack. While reading, I understood there is a large set of gray shades to pureness of "pure functional" code. He calls being functional a useful abstraction, a function() is never purely functional. [] https://web.archive.org/web/20120501221535/http://gamasutra....
Because if it were your program would have no changing state and no output.
What they mean is that your code is purely functional as much as possible. And there is high segregation between functional code and non functional code in the sense that state and IO is segregated as much as possible away into very small very general functionality.
Re: John Carmack on inlined code (2014)
#189I have a coworker that LOVES to make these one or two line single use functions that absolutely drives me nuts. Just from a sheer readability perspective being able to read a routine from top to bottom and understand what everything is doing is invaluable. I have thought about it many times, I wish there was an IDE where you could expand function calls inline.
It’s called “self documenting code” and the way you self document code it is by taking all your comments and make them into functions, named after your would-be comment. I’m not a fan either.
Re: John Carmack on inlined code (2014)
#190Earlier quoted context omitted.
Not according to jon carmack. He stated he switched to pure functional programming in the intro which is basically stating all his logic is in the form of unit testable pure functions.
Nothing about pure functional programming requires unit testing all of your functions. You can decide to unit test larger or smaller units of code, just as you can in any other paradigm.
In other paradigms do not do this. As soon as a module touches IO or state it becomes entangled with that and NOT unit testable.
Is it still testable? Possibly. But not as a unit.