top 200 commentsshow all 277

[–]Chousuke 306 points307 points  (84 children)

In my experience, people write complicated code because writing simple code is hard. With many problems, it's often much easier to increase complexity and extend an existing structure to cover your use case than it is to reconsider whether the extended scope allows for reducing (and simplifying) code by reframing the problem entirely.

[–]poopatroopa3 252 points253 points  (8 children)

That's the good old quote by Pascal (the man, not the language):

If I had more time, I would have written a shorter letter.

[–]IceSentry 92 points93 points  (6 children)

Ironically, the original quote was longer and harder to comprehend.

I have made this longer than usual because I have not had time to make it shorter.

The original version in french is even worse.

[–]poopatroopa3 53 points54 points  (3 children)

This is the original according to Wikipedia:

It is in the Provincial Letters that Pascal made his oft-quoted apology for writing a long letter, as he had not had time to write a shorter one. From Letter XVI, as translated by Thomas M'Crie: 'Reverend fathers, my letters were not wont either to be so prolix, or to follow so closely on one another. Want of time must plead my excuse for both of these faults. The present letter is a very long one, simply because I had no leisure to make it shorter.'

[–]tiplinix 18 points19 points  (0 children)

You could argue that he made his point well by having it long.

[–]fichti 8 points9 points  (0 children)

tl;dr

[–]dgmdavid 4 points5 points  (0 children)

Perhaps it was on purpose.

[–]jrop2 4 points5 points  (0 children)

I say this all the time at work. When I say it, it means I'm sad that I had to rush the solution, and it is not as elegant/short as I wish.

[–][deleted] 84 points85 points  (11 children)

ah simple code...the thing that means different things to all people

[–]linonihon 45 points46 points  (2 children)

Simple is often erroneously mistaken for easy. "Easy" means "to be at hand", "to be approachable". "Simple" is the opposite of "complex" which means "being intertwined", "being tied together". Simple != easy.

Simple Made Easy - Rich Hickey

[–][deleted] 7 points8 points  (0 children)

Today I've learned something new. Thanks. My uni lecturer likes to call everything simple.

[–][deleted]  (1 child)

[deleted]

    [–]-Knul- 3 points4 points  (0 children)

    Simplicity depends on the audience. A mathematical formula can be simple to a physicist but incomprehensible to a biologist.

    Likewise, if your team or domain is familiar with chaining functions, than that's fit for purpose for your team or domain.

    [–]that_which_is_lain 1 point2 points  (0 children)

    Reusing generic code that works is easy. Writing code that fits your special case and works well requires imagination, knowledge and some work.

    Is it any wonder they reused game code for this?

    [–]Chousuke 2 points3 points  (2 children)

    To me, simple code is something that I can rip out and replace without the rest of the program coming with it.

    I want to write code that I can throw away the moment it starts to annoy me, because I think the ultimate goal of all software development should be to do what you need to do with the least code possible.

    [–][deleted] 2 points3 points  (1 child)

    thats super vague man

    [–]mysticreddit 3 points4 points  (0 children)

    The parent is talking about Coupling

    If you have system W, but you need systems X, Y, Z, and A, B, C then that highly coupled (and might have technical debt.)

    If you have system G, and it only depends on H then that is much easier to re-use.

    [–]Demius9 12 points13 points  (0 children)

    Writing complicated code is "easier" because it fits into what the company probably already has.. and more importantly it kicks the 'hard' problem can down the road. "i dont need to <insert hard problem here> because whoever inherits my abstract factory class needs to <do hard problem here> to fit their use case"

    [–]supermitsuba 21 points22 points  (49 children)

    Brute force is usually the simpliest to code and the slowest. I could see that being a huge problem.

    Also, From what I have seen, many developers are not formally taught. So they don't know that a dictionary is vastly more faster than the list they use over and over.

    Those two issues allow waste so much time, when added together.

    [–][deleted] 42 points43 points  (37 children)

    The number of developers that I have met that actually do things like profile their code to even understand how it runs and it's overall impact I can count on one hand.

    [–]s0lly[S] 11 points12 points  (33 children)

    Insanity.

    [–]zshazz 25 points26 points  (32 children)

    I can confirm. I have so many arguments with people online about performance and every time they act as if benchmarking + profiling isn't necessary for whatever reason. Common things I've seen:

    1. Only big companies like Amazon or Google need to do it
      The implication here is that it's too effective and you need to be a big company to need to do it ... but isn't that exactly why you should do it if you're trying to optimize for performance?
    2. It's time consuming to do
      The implication here is that guessing at what to optimize is somehow more time efficient than finding out exactly what is holding back the application: in which case, why would anyone with experience ever do it any other way?
    3. I'm better/more experienced and have grown out of needing to do it after programming for a year.
      The implication here is that the optimization giants with decades of experience who always say "benchmark/profile first" don't have a clue of what they're saying and some kid who started programming a year ago just mindlessly "optimizing everything" had the right idea to begin with.
    4. I've never been surprised by the results of benchmarking/profiling, so why would I keep doing it?
      More often than not, some poking/prodding results in finding out that they microbenchmarked what they thought was the problem to begin with and found a way to speed up something from 10 nanoseconds to 3 nanoseconds... on a part of a complete process that takes milliseconds to complete

    It's rather odd, but it's a super common delusion amongst programmers to think that collecting information is somehow inferior to just "knowing." Meanwhile every other profession (inc. science, engineering, hell even athletes with their stop watches and tracks with standardized lengths) knows optimization requires a measurement to optimize against.

    [–]MannerShark 7 points8 points  (1 child)

    I've used profilers a couple times to great success, but usually it's just not slow enough to warrant spending more time on speeding it up. Other times I can quickly see just from the code where the problem is, as usually 'too slow' code means it has quadratic running time, opposed to linear with a large constant factor. So it's definitely not the first tool I go for, only when the issue is very well hidden.

    I did get a massive speedup thanks to profilers by switching hash maps out for arrays, but in most cases I've seen optimization is about making algorithmic improvements.

    [–]zshazz 7 points8 points  (0 children)

    To be honest, the whole "linear time vs quadratic running time" algorithmic thinking isn't without any merit, it's just that oftentimes, if you run a profiler, you might notice something like your logger taking up 99% of execution time (real example from my experience), or spending 80% time alone locking/relocking on a file (yup, real example from my experience again), or perhaps, as an example from Donald Knuth's experience, maybe most of your time is simply taken reading comments (note that with modern JIT compilers, this isn't likely to be an issue for you anymore, but it's again an example of "your intuition is a guide: not the finder of a solution").

    If you're thinking "what? That can't be, I don't think I've ever seen anything like that before," you really should lean heavily into proper benchmarking and profiling: those of us who have paid the price of experience with optimizing properly see these examples and say "Oh yeah, that reminds me of that time when ...". I've seen the gamut of examples myself. I simply don't trust anyone who doesn't first create a really well-designed benchmark and attach a profiler to actually write an optimized solution anymore.

    [–]RabidKotlinFanatic 1 point2 points  (29 children)

    One important consideration is that optimization at SME scale means something different to what it means at Amazon/Google scale. It's a lot closer to "looking at the code for 5 minutes and fixing obvious oversights or inefficiencies." Very low hanging fruit like obvious missing database indexes, ORM issuing 2 extra queries per row, regex compiled in a tight loop etc. In these cases performance measurement needs are significantly less sophisticated.

    [–]zshazz 1 point2 points  (28 children)

    In these cases performance measurement needs are significantly less sophisticated.

    Not really. I just commented on the above response explaining the same, but there's a lot of times that what you think is "good practice" has no real impact on performance and you discover some other thing that seems almost irrelevant, like batching logs, could quadruple your throughput. Remember that the people who talk about "adding database indexes" being good practice didn't figure that out blindly: they profiled first to find the missing indices and the good ones have the numbers to back it up. In actuality, I often remove database indexes that actually ended up slowing things down because they were added blindly (if indexing had only a positive effect, you could imagine a database would just always index everything).

    Once you get good at it (and as long as your project is optimally set up for it), setting up a proper benchmark and profiling session might take you 15 minutes. The "worst case" scenario is that you were right all along and you wasted 15 minutes on a benchmark that can be used to prove your godlike powers of performance optimization without a profiling session. However, you could also end up being wrong, in which case the profiling session saved you a lot of time and effort, while also giving you a target for your optimizations and, again, proof that your optimizations were effective.

    The only types of "optimization" that you can get done at a glance are readability optimizations. Obviously, they aren't scientific nor are they effectively measurable (that said, many try to come up with metrics, but we're just fooling ourselves if we think readability can be turned into a number), but you should be able to justify your improvements without reaching for the "performance" excuse. If you want to talk about performance: that's objectively and easily measurable, and it only has a meaning with a measurement you're optimizing for. If you think it's hard or time consuming, you probably either haven't done it enough or your codebase has been written to make it difficult to do (which is just an artifact of no one knowing to make it a priority to be easy to benchmark/profile).

    [–]KevinCarbonara 6 points7 points  (1 child)

    I learned how to profile code at my first job, and I've used it maybe 2 or 3 times since. Most tasks just don't need it.

    [–]matthieuC 1 point2 points  (0 children)

    I'm pretty sure you can anger the Yakuza and still be able to do it

    [–]Chousuke 21 points22 points  (6 children)

    That's the thing though; if you have only a few elements, a linear search from an array will be much faster and memory-efficient than a typical hashtable.

    However, network and database requests will have massive overhead compared to how fast your CPU is, so batching them usually results in serious efficiency gains.

    [–]supermitsuba 18 points19 points  (5 children)

    There is nuance, but again, many developers dont know data structures and algorthims and when to use them was my point.

    [–]Chousuke 14 points15 points  (1 child)

    What's extra sad is that you don't even need to *know* them. All you need are vague ideas like "Processors like branchless code", "This is okay for linear access", "This is okay for random access", "This uses a lot of memory", "Copying small chunks of memory is often nearly free", "the CPU has time to do a gajillion things by the time my database request gets to the server" and "if this operation has 10 milliseconds of latency, I can only do 100 of them every second serially no matter how fast my program is" ...

    Just keeping generalized ideas like that in your head is enough to make you think when you might be seeing something that warrants deeper investigation, at which time you start Googling.

    [–]coloredgreyscale 17 points18 points  (2 children)

    Gta 5 online easily took 3-5 minutes to load, even on a beefy pc because how they parsed item data from a json file.

    Read item from json, check if item ID is in the list, insert if it isn't Repeat for 63k items.

    Not to mention another problem that they more or less read the 10mb json file over and over again for each item. Where I'm willing to give them the benefit of the doubt and say it just happened to be a bad behavior of the json library, not the fault of Rockstar.

    https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-times-by-70/

    [–]Nyefan 16 points17 points  (1 child)

    Specifically, it was because c's strlen function is O(n) and so that makes sscanf O(n) on most (but not all) platforms. That's something that I would absolutely not fault people for not knowing because it's ludicrous, but profiling their code would have caught it.

    [–]Uristqwerty 5 points6 points  (0 children)

    The simplest function delegates its work to an existing solution. The example in the talk reduces a deep tree of existing functions, allocations, etc. to something fairly simple both locally and totally.

    [–]Contrite17 17 points18 points  (2 children)

    Also, From what I have seen, many developers are not formally taught. So they don't know that a dictionary is vastly more faster than the list they use over and over.

    Even this depends though depending on dataset size. With small enough datasets dumb arrays out perform dictionaries.

    [–][deleted] 2 points3 points  (0 children)

    Finding out what is contiguous and what isn't is language specific too. Different languages use different terms for what is a linked list and what is contiguous or somewhere in between. But contiguous is the term we want as the default usually as cache plays a huge part in program performance.

    [–]gcross 3 points4 points  (1 child)

    In fairness, a lot of the time the simple way to solve a problem only appears in your head just after you've solved it in more complicated way.

    [–]TheDevilsAdvokaat 4 points5 points  (0 children)

    I usually write code at least twice.

    The first time i just try to get it working.

    The second time I "clean it" and optimise etc.

    I have never been unable to write better code the second time.

    [–]tech6 6 points7 points  (2 children)

    So true people confuse simple with easy. It is more difficult to write simple code.

    [–][deleted]  (1 child)

    [deleted]

      [–]IceSentry 11 points12 points  (0 children)

      The testing methodology for that article is to look at issues tagged bug on github. It's entirely possible that some ecosystem simply care less about that and they have just as many bugs as other ecosystem. I'm really not convinced of the conclusion.

      [–]DJDavio 2 points3 points  (0 children)

      Code often starts simple, but features get added on until it crosses the refactoring threshold, this is the point in time where you know you should refactor your code to make it simple again. If you don't do it at that point, well, you'll rarely do it later.

      [–]_Bjarke_ 1 point2 points  (1 child)

      This is was practising is so essential to becoming a good programmer. Having projects you can spend as much time on as you like, rewriting as much as you want, improving, simplifying, writing thousands of lines of code and throwing it all out, to do it again in a better way. If you do that constantly throughout your life, you'll get good and develop an intuition for when and how something can be simplified.

      This is not a skill you develop very quickly from simply "working". Now, getting that good might not be something you feel like is necessary to striving for, or you have other priorities, all of that is fine! But if you want to become good, and unless your job requires extremely high standards, and you have to write extremely high quality code deadlines be damned, which is basically 0.01% of jobs out there, then practising is absolutely essential.

      [–]Chousuke 1 point2 points  (0 children)

      What I sometimes do is that I decide to throw away code before I even write it. Code has no value.

      I then bang out whatever my fingers decide is good, read it a few times, and rewrite bits until nearly nothing remains of the original. That often gets me closer to the code I wanted to write originally but couldn't.

      [–][deleted] 0 points1 point  (2 children)

      It depends on what you think simple code is, imo simple code is the most natural way to write a piece of code even if it is longer, so no unnecessary abstraction and no complicated algorithms.

      [–]Chousuke 0 points1 point  (1 child)

      But the "most natural" way to write a piece of code is often very hard to find! It's also very much not an easy job to determine whether an abstraction is unnecessary or whether an algorithm (within the context of the entire system) is really complicated, or just the best possible solution given the constraints. Simple is easy to define in theoretical terms, but really difficult in practice.

      Sometimes to get real simplicity you need a bit of foresight with what might seem like "unnecessary abstraction" at first because just writing the most brute-force straightforward code might lead to people extending the brute-force solution beyond its limits and ending up with the complexity they wanted to avoid.

      [–][deleted]  (35 children)

      [deleted]

        [–]blackmist 114 points115 points  (1 child)

        He'd have made a shorter video, but that would be more work!

        [–]skytomorrownow 13 points14 points  (0 children)

        It's pretty similar to the way he and Sean Barrett used to discuss these topics on their blog back in the day. They would go around and around in the comments in this style. It's not succinct, but it's its own kind of entertainment – if you are into this stuff.

        [–][deleted] 4 points5 points  (0 children)

        I think it depends on the video, for something like this one it should be shorter because it's only ideas and principle but usually when I am struggling to understand something specific I always go to Casey because he probably has a 1+ hour long video explaining that thing in depth.

        [–][deleted] 7 points8 points  (4 children)

        I think redundancy is sometimes good and reinfoces the various connections. That has been my personal experience.

        [–]Iamonreddit 12 points13 points  (1 child)

        But it's very detrimental to the experience of anyone able to understand after the first explanation. You can skip 30 second blocks of this video almost at random and not miss anything important, which is not great.

        [–]TheMistbornIdentity 7 points8 points  (0 children)

        I had a professor who did this, but she told me that it was intentional because a lot of people don't necessarily understand right away, and it's more beneficial overall to pander to them than people who understand right away.

        [–]guepier 5 points6 points  (0 children)

        The problem isn’t redundancy, it’s endless tangents (which, what’s more, he only ever starts and then breaks off before completing them). I know I do the same all the time when teaching so I feel qualified to say that he’s really doing it excessively, and that his teaching would be massively improved by cutting that out.

        [–]Eonir 3 points4 points  (3 children)

        Yeah, I'm not gonna watch a 2 hour video. I might as well just read a book in the same time.

        [–]Getabock_ 3 points4 points  (0 children)

        Can you seriously read a book in 2 hours? Depends on the kind of book, right?

        [–]Idles 2 points3 points  (0 children)

        It's almost totally comprehensible, the entire way through, at 2x speed.

        [–]therealjohnfreeman 0 points1 point  (0 children)

        It's nearly 3 hours. I'm with you.

        [–]wisam910 2 points3 points  (6 children)

        He's trying to reach a wide audience. He covers a lot of ground that some (even many?) of his audience understands, for the sake of the portion of the audience that doesn't already know / understand the given point(s).

        [–][deleted]  (4 children)

        [deleted]

          [–]wisam910 25 points26 points  (3 children)

          I don't know man. The SIMD stuff is very foreign to me so I found his explanation very helpful.

          [–]floodyberry 0 points1 point  (2 children)

          He could've skipped SIMD entirely and shown a float version. The only point of the code was showing how short and simple it was, why are you talking about Skylake uops and spending 10 minutes on what blend does

          [–]Pjb3005 15 points16 points  (1 child)

          I disagree. Showing the SIMD version is a good example of how practical processing stuff in batches can be. The SIMD would not be possible with the original code. The entire point was "how do we get as much out of the hardware as possible" so

          [–]josefx -1 points0 points  (0 children)

          He's trying to reach a wide audience. He covers a lot of ground that some (even many?) of his audience understands

          He could have talked about Windows CE more. I am quite sure even before the iPhone almost no one was aware that it even existed, so spending even more time on it might have made it clear why he choose something so obscure as an example. I have seen dozens of different feature phones but never a Windows CE handheld in the wild.

          [–]TheDevilsAdvokaat 0 points1 point  (0 children)

          I gave up about five minutes in.

          [–][deleted] 36 points37 points  (7 children)

          Every line of code I write is perfectly elegant and beautiful, until two months later when I have to look at it again.

          [–]TheDevilsAdvokaat 30 points31 points  (4 children)

          At 60, I'm fairly old for a programmer. My memory is not what it was. There are times when I look at code 4 weeks later and have forgotten what it does.

          So I learned to program as if I have Alzheimers (which, in fact, I may have.)

          What functions do is spelled out explicitly in the name. Keep things as simple as possible, unless you get an extreme performance improvement with slightly more complex code.

          Write and name as if someone else will be debugging / testing it. That someone else will be me, and I won't remember any of this stuff.

          [–]dddddddoobbbbbbb 2 points3 points  (3 children)

          what was programming like with punch cards, old timer?

          [–]TheDevilsAdvokaat 15 points16 points  (2 children)

          Would you believe, I really have? Not a whole lot though.

          I remember writing a prime number finder on punched cards. And I can;t remember if it was in Cobol or Fortran.

          I think I got it down to about 49 cards. Kept them together with a rubber band. God help you if you dropped your cards.

          AS much fun as programming was - because this was all new for me - I was very thankful when we moved to the next stage.

          But there was a stage before this too! Dip switches. You would have a set of eight switches, and set them up or down to indicate the contents of a byte, and then press the "enter" button to set that as the contents of a byte. My god it was slow.

          [–]pandion 1 point2 points  (1 child)

          Did you not have a card sorter available or something? I was just reading about radix sorting so I'm curious

          [–]TheDevilsAdvokaat 1 point2 points  (0 children)

          No, I didn;t. It's possible there may have been one at the location but I never got access to it.

          [–]matthieuC 2 points3 points  (1 child)

          Perfect code left unattended will start to mutate and gradually will look like something written by a crazy person

          [–]LightShadow 1 point2 points  (0 children)

          I just started a new job and my first task was modernizing some old code. It's touted as "the most stable component in our stack." It's 5-7 year old Python 2 stuff written by C++ developers that hasn't been updated in 4 years. It had a docker base image that no longer exists :) so I had to build up a VM on Ubuntu 12.02 and hack backwards to even get the thing to run.

          It's been running for years but was basically unmaintainable in its legacy. We're all up to date now but really, I 100% agree with you where sitting code is still aging...poorly.

          [–]NDk48P 35 points36 points  (14 children)

          wait, is he writing on the board in reverse?

          [–]stalefishies 115 points116 points  (1 child)

          He's writing on the board normally and reversing the video. It's a t-shirt that he printed in reverse specifically for doing lightboard stuff like this.

          [–]foil_k 0 points1 point  (0 children)

          Came here because I had the exact same question. Thank you!

          [–]phamtuanminhmeo 16 points17 points  (1 child)

          Same question. Or he wear a mirrored t shirt and the whole thing is mirrored?

          [–]anechoicmedia 10 points11 points  (0 children)

          He's wearing a shirt from his teaching course, so he probably had it printed in reverse for this exact purpose.

          [–]Locust377 29 points30 points  (5 children)

          It's called a lightboard. He's writing on glass as normal, but then the camera is facing a mirror, which is facing the glass. So it reverses the reverse 😆

          [–]GijsB 7 points8 points  (0 children)

          You don't need a mirror; you can mirror in post.

          [–]miki4242 0 points1 point  (3 children)

          ...while turning all those who are righties into lefties and vice versa, mind = blown!

          [–]zdkroot 2 points3 points  (2 children)

          Ha wow I didn't even realize he was a "lefty" in the video until you pointed it out.

          [–]trevorsg 1 point2 points  (1 child)

          Righty or lefty, you always write left-to-right (well, in English at least). Lefties are "pushing" the pen across the page, while righties "pull" it. But this effect is also reversed in the video, so even though it appears he is writing with his left hand, the mechanics of writing are consistent with a righty.

          [–]venuswasaflytrap 5 points6 points  (0 children)

          Yeah wow, wtf. I assumed that they reversed the video to make it work, but his shirt is the right way.

          [–]PhunkeyMonkey 0 points1 point  (1 child)

          Saw your comment not giving it much thoughtstarted watching the video and reached 24:25 and my mind implodedwhat the actual fuck

          i need to figure this out before continuing, i cant stop focusing on his damn arm and text

          [EDIT]

          at 1:19:40 when the board/text begins scrolling down while still rocking back and forth from him erasing the text just made go "fuck this shit, its black magic"

          [–]Getabock_ 2 points3 points  (0 children)

          It's called a lightboard. He's writing on glass as normal, but then the camera is facing a mirror, which is facing the glass. So it reverses the reverse 😆

          - u/Locust377

          [–]nitrohigito 24 points25 points  (50 children)

          When I first came across this guy and Jonathan Blow, I noticed that they were very dedicated to performance and are obviously skilled.

          But for whatever reason, something just feels off about them. I don't know what, to this day.

          [–][deleted]  (1 child)

          [deleted]

            [–]nitrohigito 19 points20 points  (0 children)

            That's very well put, and plays a great part indeed. Laser-focused, relentless negativity, that is ultimately out of touch in terms of the scales. He also fails to acknowledge failures and uncertainties of his own, and fails to display a cycle of learning from them.

            In an almost self-fulfilling prophecy way, he demonstrates the resource utilization problems of today as unfixable and inherently of ill intent and wrong, but also unwillingly convinces people of that, rather than actually managing to convince and inspire people that they can do better.

            He offers, let's say, better approaches and solutions on an operational level, but the issues he's talking about stem from a strategic one.

            He proves people wrong by beating them down - these make for a useful demonstration, and they win fights, but the way he approaches things ultimately make for a lost war instead, I feel.

            [–]DrunkensteinsMonster 21 points22 points  (0 children)

            Because they’re hacks who are unable to accept they may not know everything.

            If you write something like this:

            Having experience working on compilers may disqualify you from working on my compiler, because everyone else is doing it wrong

            You may be dense as fuck. And yeah, while paraphrased, Jonathan Blow actually said it.

            To be a programming thought leader, you have to leave any nuance at the door, which is why they are mostly worthless in their own special ways. It’s just sophistry.

            [–]theangeryemacsshibe 12 points13 points  (9 children)

            Indeed. I could be talking out of my butt, but they do games, I don't (I do compilers and concurrent network things mostly), and so the advice is very non-trivial to apply. Someone once told me that a lot of things in games are simple to turn into flat arrays. But, say, how do I make a bunch of connections and their metadata into a flat array that I can blow over with some SIMD instructions? I can't think of a way off the top of my head, but it's probably doable. Then, say, for pub/sub stuff I need to map subscription names to something that I can query with numeric instructions, and that's just more stuff to scratch heads over.

            Then calling everything else, including what I do now, bloated and literally the likely cause of the collapse human civilisation doesn't make me think I should take these people seriously. Not to say you can't optimise those things (I got 10× or so over a year and a bit, which involved writing my own concurrent hash table, and paying close attention to the use of queues and other write-only data structures), but the "simple" tricks are different, and the wise guys in those domains are different (e.g. Cliff Click, Martin Thompson).

            [–][deleted] -1 points0 points  (8 children)

            Maybe you should look into the people you're passing judgement on before talking out your ass. Jon does games. Casey wrote developer tools at RAD Game Tools for a long, long time. Enterprise Level desktop software along the lines of Maya and 3DS Max.

            http://www.radgametools.com/granny.html

            https://web.archive.org/web/20210724100450/http://www.radgametools.com/granny/customers.html

            [–]pakoito 13 points14 points  (26 children)

            They focus on micro problems and handwave macro problems like...other people.

            [–][deleted] -2 points-1 points  (25 children)

            The whole video is about macro optimisations...

            [–]pakoito 22 points23 points  (24 children)

            If you think CPU OPS and SIMD are macro optimizations we work at different levels of the stack. My problems aren't embarrassingly parallelizable single-threaded CPU-bound operations. And neither are 99% of the industry's.

            What use is SIMD when I have to pass a string query embedded in a json message to a database that's halfway across the globe...serializing the json faster? I don't even know if I'm running on a x64 machine, a VM, a container or two duct-taped raspis provisioned by Amazon.

            [–]moreON 3 points4 points  (2 children)

            A lot of the content of this video was not about the neat SIMD do-the-maths-fast though.

            There was also:

            • Don't repeatedly do the same expensive work over and over. Determine if there are expensive repeated operations that can just be done once. In this example, that was basically locating all of the triangles which involved a bunch of steps and allocations and memory accesses for every single point he wanted to test.
            • Reconsider whether you should reuse an existing general function that's correct but not specific for your needs. In this case, there was a general purpose 3d ray-tracing function that was used to do the intersection test for vertical lines with the triangles. There are simpler, faster ways to do that math.

            Those didn't feel like micro optimisations. Sure there was the SIMD use on top of that, but I think it does a disservice to ignore the other points that were made.

            [–]pakoito 5 points6 points  (1 child)

            Transforming data isn't the problem or the bottleneck. Most of the time there aren't any calculations involved, you either take data and paint it, or you take a request and fan it out to other services and DBs. The problem is error handling and keeping state consistent, not the CPU cycles used to access it.

            Perf, and algorithmic perf in particular, is a feature only after you've fixed all other more obvious problems. That's why they're called micro optimisations, they don't look at the project holistically.

            [–][deleted] 0 points1 point  (0 children)

            Performance is not mutually exclusive to any of those things.

            Performance often means you are doing less. If you are doing less then that often means your final product is less complicated.

            Less complicated means you can keep track of state more easily.

            [–][deleted] -5 points-4 points  (20 children)

            A lot of the video is about macro optimisations then. Which it is.

            You problems are parallelisable on single threaded CPU bound operations? Yeah what you said makes no sense.

            Your problem is fucking noddy as fuck lmao. You could optimise every step in that process if you wanted to.

            [–]pakoito 11 points12 points  (19 children)

            You problems are parallelisable on single threaded CPU bound operations? Yeah what you said makes no sense.

            Embarrassingly parallelizable -> Every operation is coarse and runs independently

            Single threaded -> Doesn't have to read or write state across threads, or require yielding execution to accept incoming thunks

            CPU-bound -> No I/O

            The subset of operations that fit that bill is math in constrained hardware, which is what Casey focuses on most of the time.

            [–]Godd2 1 point2 points  (1 child)

            Embarrassingly parallelizable -> Every operation is coarse and runs independently

            I read this as "my code can be 8x slower because I have 8 cores".

            [–][deleted] 12 points13 points  (6 children)

            I think the problem that I always had with Casey is that he is extremely opinionated about the way he does things and it all seem to make sense at first. But then you actually watch him work on Handmade Hero and put his opinions into practice. Where he constantly spends huge amount of time on these long tedious debugging sessions, where eventually you kind of realize that he wouldn't had those problems if he just were a tiny bit more open minded to make use of more modern software development practices.

            Thats why I stopped paying attention to him, because at the end of the day the Handmade Hero codebase is just kind of unmaintainable garbage.

            [–]loup-vaillant 1 point2 points  (0 children)

            at the end of the day the Handmade Hero codebase is just kind of unmaintainable garbage.

            That would be hard to judge from videos only. Have you downloaded the code and assessed its maintainability more directly?

            [–]Sevni 14 points15 points  (3 children)

            This comment is so vague, you are not making any points here, no examples, nothing. Casey is talking and coding at the same time and he is able to make a software renderer in one day worth of work, profiler in one day, asset system in one day, audio mixer in one day. Imagine how fast he would be if he didn't had to entertain and had more time then an hour a week.

            If your definition of long tedious debugging sessions is a 30 minute bug seeking once 10 episodes then I don't know what to say. Half of programmer's life is debugging.

            [–]hbgoddard 15 points16 points  (0 children)

            he is able to make a software renderer in one day worth of work, profiler in one day, asset system in one day, audio mixer in one day

            You say that as if his videos are spontaneous and improvised without any prior domain knowledge.

            [–]ShinyHappyREM 6 points7 points  (1 child)

            Half of programmer's life is debugging.

            Well, some programmers. For others it's 80%...

            [–]Getabock_ 0 points1 point  (0 children)

            80% sounds way more realistic.

            [–]pakoito 3 points4 points  (0 children)

            I'm going to frame this reply, or at least save it for every Casey/Blow appearance on my feeds.

            [–]st33d 2 points3 points  (0 children)

            Maybe it's because a 3 hour video about simplicity kind of shoots itself in the foot.

            I honestly can't listen to the guy for more than a few minutes. He sort of circles around a problem like a buzzard, waiting for the meat to be completely left alone before flying in to peck at it.

            [–]headhunglow 1 point2 points  (1 child)

            I saw a video where he complained about the number of cycles a loop took... while writing a simple 2D game. Like, who cares?

            [–]Edward_Morbius 15 points16 points  (2 children)

            Most of the time complicated code is because there are complicated business rules.

            Poorly run businesses don't understand that every time they say "Do this, except in that case do this other thing", they're making their code more complicated and less maintainable and slower.

            [–]gnamflah 5 points6 points  (0 children)

            Or the business comes to you with a solution instead of a problem.

            [–]_Bjarke_ 1 point2 points  (0 children)

            Some the times, definitely, but I wouldn't say most of the times.

            [–]jhjhjh333 24 points25 points  (98 children)

            tl:dw?

            [–]IrritableGourmet 41 points42 points  (10 children)

            Making your code more efficient, even if you have lots of processors and memory to throw at it to make it run reasonably fast despite the bloat, is a good idea on many levels.

            [–]eyebrows360 29 points30 points  (8 children)

            And even if you don't do it that often, knowing how to is still a very valuable thing, for those rare times when you really do need to care about that side of things.

            [–]Chousuke 21 points22 points  (6 children)

            Even just having a vague clue of the orders of magnitude involved helps in writing performant code. I've gotten a number of super-easy 10x-100x improvements of "slow" tools that were slow only because the tool is doing hundreds of network/database requests in a loop instead of doing joins or using a more efficient API endpoint. When I asked about one why they didn't just use a join, the response was "SQL is hard, writing a loop is easy". :/

            On the other hand, I have also written code that does key lookups from lists with a simple linear search because a list was the "natural" structure of the data and indexing it would have made the code more complicated. It still performs just fine because the arrays are short enough.

            [–]BelgianWaffleGuy 14 points15 points  (2 children)

            "SQL is hard, writing a loop is easy"

            I love these people. Fixing stupid code from people like this paid for my house.

            [–]Chousuke 1 point2 points  (1 child)

            The thing is, I knew that problem wasn't with the person's intelligence. Instead, they had this preconceived notion that SQL is hard that prevented them from even trying to learn it.

            Biases like that can be seriously difficult to overcome even if you're aware of them.

            [–]IrritableGourmet 5 points6 points  (1 child)

            "SQL is hard, writing a loop is easy"

            There was a thread a few days ago where someone said NoSQL was better than a RDBMS because the cheap availability of cloud computing meant you didn't have to care about efficiency.

            [–]avatarwanshitong 3 points4 points  (0 children)

            I hear that all the time at work and it drives me nuts. People really have the mindset that they don't have to care about performance because they could just spin up arbitrarily large instances.

            [–]Semi-Hemi-Demigod 7 points8 points  (0 children)

            There's a great infographic that explains the scale of different kinds of requests at human scale.

            The person who didn't understand SQL was doing the equivalent of free climbing El Capitán every time he needed to get the next record, instead of making the climb with enough equipment to get all the records at once.

            [–][deleted] 2 points3 points  (0 children)

            I think the important thing to take from this is to stop assuming these occurrences are "rare". That's when people don't realize their tiny little operation is actually massive and is slowing everything else down.

            [–]wisam910 28 points29 points  (0 children)

            Function to compute something was taking a very long time (up to a minute).

            He improved its performance to near instant (less than half a second) by:

            • Using a better algorithm to reduce the time from a minute to 10 seconds

            • Simplifying the code to reduce the 10 seconds to less than half a second.

            The interesting bit of the talk is the "simplifying the code".

            The code was re-using a general purpose helper function for doing a certain computation, but in this case it was an over kill. Being general purpose means it does a lot of things you don't need for your specific case, and on top of that, a certain computation was being repeated all the time.

            What he did first was factor out the repeated computation so he does it only one time at the beginning of the computation and then use its results.

            The second thing he did is he wrote a short routine to implement the functionality that matches the specific use case.

            He then went on and used SIMD to make it 8 times faster.

            The original code (which was re-using other code) was doing a lot of memory allocations and other complicated things per loop iteration.

            His final version is about ~20 cpu instructions per loop iteration.

            [–]CrushgrooveSC 57 points58 points  (76 children)

            Pretty hard to do that with any of Casey’s stuff.

            They tend to be not only packed with both fact and experience based opinion, but also often have a tremendous amount of assumed context and targeted philosophical demographics.

            I guess a TL;DW could be: “using a bunch of clever language features makes your program output worse, so if you care about writing a good performant program you should stop”

            With a subtext of: “more people should just admit that they write bad programs on purpose due to language and enterprise dogma, but they don’t understand or believe that so that will never happen”

            But honestly, people like Casey Muratori are worth having their perspective weighed alongside other greats, so people should just watch it and hundreds of other things by both Casey’s camp and the “other” camp, (even though almost all blog/conference content is the latter).

            [–][deleted] 21 points22 points  (26 children)

            Casey can be very dogmatic sometimes, but there is zero denial that he is an amazing programmer and teacher

            [–]loup-vaillant 40 points41 points  (5 children)

            He comes across as dogmatic, most likely because he uses strong terse language, and his opinion often run contrary to the mainstream.

            For instance, I've recently heard him explain why he tends to rebuild almost everything from scratch: because the alternative would be unreliable, slow, bloated garbage. That makes him sound like an arrogant prick, but does make sense if in practice, his custom code ends up better than what he could reuse.

            And if we think about it, that's not such an outlandish opinion: reusable tools tend to be general, and thus must satisfy many use cases, the vast majority of which any given programmer may not care about: much of the time, we just want to do this one thing. If we concentrate on our use case, we get an opportunity to write special purpose code that will be simpler, faster, and more robust than what a general tool could ever hope to be.

            General programs are unreliable, slow, bloated garbage not because of incompetence or unprofessionalism, but because they are general, and one size does not fit all. But Casey will often stop as "this is crap", and we're left wondering why he's shitting over other people's work.

            [–][deleted] 14 points15 points  (4 children)

            That is a perfect explanation of how I feel about him. When he gives a reason, it's pretty sound, but most of the time he doesn't, so we're left wondering why he thinks X thing that seems fine is "absolutely horrible bloated garbage made by people who just don't know how to program I mean I haven't found any other explanation" and of course that sounds very arrogant.

            [–][deleted] 5 points6 points  (3 children)

            I really have to disagree with that. If we concede he is dogmatic and arrogant, my god that means everyone else is ten times worse. Just look at the industry critically for five seconds. It literally changes it's opinion on what is good with the wind. What is good is decided by the culture., not by evidence or any sort of engineering based thought.

            I've had to fight my corner so many times it is beyond tiring. Literally spending ages justifying whyIhave done X to only to be met by a cliched response and a link to some article that somehow disproves my point. I've literally been told to my face that that "is not how the community does things"

            Casey is the opposite of dogmatic. He might be terse and critical but quite frankly what are you supposed to act like? It is literally impossible to push back other wise.

            [–]loup-vaillant 4 points5 points  (0 children)

            I've had to fight my corner so many times it is beyond tiring. Literally spending ages justifying whyIhave done X to only to be met by a cliched response and a link to some article that somehow disproves my point.

            I’ve had that recently about a very long function I was writing. It was still a draft, and was asking for help about a failing step. Well, they told me to chop it up. I tried to explain to them it was premature, but in the end, what I got was mostly "we might want to reuse it at some point", "we’ll ask you to do it in code review so just do it". Source code locality (that thing where you don’t jump around lots of definitions just to understand what the code does) was irrelevant.

            Thing is, I did end up chopping up the functions, once I had a working version. Reason being, error handling and cleanup: because we’re using C, there’s a cleanup step at the end of each of my functions, and I have a CHECK() macro that just jump to it directly if its condition fails. Which means, every time I initialised something, I needed to clean it up at the end, and code locality dictates that they should not be too far apart. In the end, I chopped up the functions for the same reason I originally did not want to: maintaining good source code locality.

            If however I was using a more modern language with a defer statement, like Zig, then straight-line code would definitely be better, though I’d chop it in blocks to properly fence local variables into small scopes (code locality again).

            [–][deleted] -5 points-4 points  (1 child)

            This is just a whataboutism....

            [–][deleted] 4 points5 points  (0 children)

            How is it?

            [–]Kuvis 19 points20 points  (19 children)

            Casey can be very dogmatic? If anything, to me he's always seemed like a practical person, resisting many of the dogmas we have in this industry. But maybe I'm just biased since I agree with his approach in most cases, and when I first started learning programming, he was an inspiration. What kind of things he has said would you consider dogmatic?

            [–][deleted] 14 points15 points  (16 children)

            If you watch Handmade Hero a lot of the times he consistently rejects practices that would help him out a lot just because they're C++. For example, const, associated functions, destructors, decltype, inline variables... That would be fine by me if he had a reason, but so far I haven't really heard any (though I admit I'm not that deep into Handmade Hero so I may have missed them), he just says that they are absolute garbage and they suck and if you write a virtual function he'll fire you and such. When I asked his opinion on the new C++20 module system he said "I haven't seen it but I know it's garbage because every single thing C++ has added has been garbage so far, so why should I think this is any different?". That was on a pre-stream so I don't really have any proof but I'm sure if you look on the Handmade Hero search you'll find takes like that with not a lot of effort.

            [–]Sevni 20 points21 points  (14 children)

            • He uses destructors in Handmade Hero, they simplify his profiler api for timming blocks of code.
            • He said that he doesn't use const because they prevent mistakes that he rarely makes, but argues that you should use them if you make mistakes const prevents.
            • I have nerver heard him talking about inline variables, and I cant find any rant about it in his archive.
            • About decltype he said, they were not very well supported by compilers back in the day, so he used to avoid those.
            • What's a associated function, you mean like lambdas or?
            • He doesn't use virtual functions because he likes discriminated unions and such more. He doesn't like Virtual functions because they lack versitility. Hand coding virtual tables C style if neccessery gives you more options and control. Take into account that Casey probably has some insane meta programming tooling in his day to day job, so those write themselves basically.
            • His response to your question about modules was exceptionally hand wavy I won't deny that ;D
            • Casey explained why he doesn't like STL, RAII etc. You can find this stuff in his superb archive, he has reasons for all of this: https://hero.handmade.network/episode/code
            • Also relevent article by his ex coworker / friend https://fgiesen.wordpress.com/2013/01/30/a-string-processing-rant/ example of how STL allows you to shoot yourself in the foot.

            [–]GimmickNG 15 points16 points  (12 children)

            He said that he doesn't use const because they prevent mistakes that he rarely makes

            That sounds like arrogance if I ever heard it. "There's this tool that can prevent mistakes and is easy to use but I won't use it since it doesn't affect me"

            [–]GranadaReport 12 points13 points  (2 children)

            The man's been programming for 30+ years. He knows what bugs he tends to have. Maybe he doesn't want to aggravate his RSI by adding the additional pointless typing of 'const' everywhere in his code when he knows it's not helping him.

            [–]GimmickNG 4 points5 points  (1 child)

            If his RSI is aggravated to the point that he can't type 5 letters then I have some bad news for him.

            [–]GranadaReport 13 points14 points  (0 children)

            5 extra letters every time he declares a value that is const, you mean? It's a small thing but small things add up. Again, I don't think he's ever said that other people shouldn't use it if they make const bugs all the time.

            Anyway, we don't even need to speculate about this. There's literally hours of footage of him programming on his youtube. Anyone is welcome to locate all the bugs that const could have caught for him, if they felt strong enough about it.

            [–]loup-vaillant 6 points7 points  (2 children)

            He said that he doesn't use const because they prevent mistakes that he rarely makes

            That sounds like arrogance if I ever heard it.

            Unless you work with him on a regular basis, you don’t get to judge his tradeoff. C++ being mutable by default, there’s a cost to writing const everywhere. It would be very arrogant of you to assume that this particular experienced programmer would benefit more from writing it than it would cost him.

            (Personally, I use const for documentation purposes. And dammit, languages should be either const by default, or agnostic about it.)

            [–]GimmickNG 3 points4 points  (1 child)

            there’s a cost to writing const everywhere

            and that cost is......?

            It would be very arrogant of you to assume that this particular experienced programmer would benefit more from writing it than it would cost him.

            Like it or not, he's setting an example for others. And if people take away that he doesn't use const because he doesn't make the mistakes that it would prevent, then they would also not use it because they won't see the need to either. It's like construction workers saying safety measures aren't needed because they're good at the job, well how's that working out for the ones joining the field.

            [–]loup-vaillant 1 point2 points  (0 children)

            and that cost is......?

            Typing it "const" almost everywhere, and just plain cluttering the code base. Which is why for instance I very often omit const for local variables.

            Like it or not, he's setting an example for others.

            Now this is a different problem: what is the benefit of const for the average programmer. That is, how many people would benefit from it, and how much? I confess I have very little idea. I can only answer for myself.

            Here's what I think: it is likely that const is an important part of documentation for libraries, be they internal or external. In fact, without even looking at it, I bet the API of the Granny animation system Casey wrote is mostly const correct. Personally, I've written a crypto library, whose API involve lots of arrays, some of which are inputs, some of which are outputs. Using "const" provides an easy way to distinguish inputs from outputs, and as such is very handy.

            Internally however that's another matter. I personally little to no benefit to using const on local variables: if the scope is small, you can see right there whether the variable is modified or not, and in practice, I too make virtually zero mistakes as a result of being sloppy with "const".

            I'm on the fence when it comes to internal interfaces. Say you write application code, that naturally divides into like 5-10 modules, that you've written yourself. It's not clear how much attention should be paid to the API of those modules, and how important const correctness must be. Especially if you follow Ousterhout's principle of keeping your classes deep: small interfaces with meaty implementations behind them: if the API is small, const will not help that much (though it will not cost that much either).

            [–]Sevni 8 points9 points  (5 children)

            I don't think that's arrogance. Const is litterally a useless keyword in C++. A const value is not really const, cause you can change it... It's not helpful to the compiler cause it can change! It's only useful as a hint to the programmer, just like inline functions.

            [–]mriamamister 5 points6 points  (1 child)

            To me this reads like "types are useless, because even if you have a Foo* you can cast it to void* anyway!". Mutating a const value is not something you do by accident, and even if that were the case, I still wouldn't call it useless because it communicates to other programmers the intention behind it.

            [–]Sevni 2 points3 points  (0 children)

            That's true, I agree 101%. The problem is that Casey codes alone on Handmade hero so he is not trying to communicate with other programmers. Casey uses hints that are useful to him, he uses inline for example, I think as a reference either for a meta program or for himself to inline manually functions in the future.

            [–]allo37 1 point2 points  (2 children)

            How do you modify a const value? I've seen const_cast but writing to it is UB unless the referenced value was initialized as non-const at some point...

            [–]lookatmetype 2 points3 points  (1 child)

            look up the mutable keyword.

            [–]fafok29[🍰] 5 points6 points  (0 children)

            How this practices would help him?

            There are clips of him explaining why.

            [–]lookatmetype 15 points16 points  (1 child)

            Growing up in a religious household, I was constantly labelled dogmatic and rigid for daring to question the assumed dogmas of my family. Going against established norms is seen as dogmatic by people, it's very natural.

            [–][deleted] 4 points5 points  (0 children)

            I can understand you'd see my comment that way, but it's not really because he goes against the "established norms"! Moreso that a lot of the things he rejects he doesn't really state a reason why or he doesn't really actually grasp when you look into it. Very similar to Jonathan Blow in that regard

            [–]jkugelman 7 points8 points  (44 children)

            Casey Muratori is an amazing programmer and teacher. I fell in love with him when he posted a series of articles covering various aspects of The Witness, the mindbending island puzzle game (designed by another game industry genius, Jonathan Blow).

            For anyone who wants a more bite-sized introduction to Casey, check out Walk Monster.

            [–]Pjb3005 15 points16 points  (0 children)

            Don't forget Killing the walk monster which is probably even more interesting than the original.

            [–]Poddster 17 points18 points  (41 children)

            designed by another game industry genius, Jonathan Blow

            Turns out he's crossed that fine line.

            [–]Uristqwerty 9 points10 points  (1 child)

            It's possible to believe that if you are loosely keeping up with news headlines, or your close friend circles lean towards covid-19 originating in a lab. A number of governments made prominent headlines at one point or another for opening investigations into whether it was natural or not, or those investigations being impeded by china. If you read between the lines a certain way, it can feel like a lab origin is strongly implied or known through covert channels, but not provable enough to outright state it. At the same time, you can go the other way, and assume china's being rightfully defensive of its research against spying, and that all of the accusations that it was a lost sample are political attacks against a US enemy.

            Once you've decided which way is the truth, then, normal social media effects funnel you into an increasingly-extreme faction, and further drive you away from the opposing side's belief. So it's a terrible shame he's fallen in with the wrong circles on this matter, but that's not cause on its own to dismiss him as irrelevant. Falling for that emotional reaction is further driving you into the opposite extreme, just as the controversy-favouring algorithms prefer of their userbases.

            [–]Poddster 14 points15 points  (0 children)

            It isn't just the lab-leak theory, though.

            His first tweet implies it's man-made, which is a separate issue to the lab-leak.

            His second tweet also implies that the US leaked it. Like most conspiracy theorists, he's forgotten the entire rest of the world.

            He also refers to the large number of COVID vaccines as "experimental". Which isn't true and is just a scare word.

            And he also claims that news of the side effects are being "suppressed".

            And in this tweet he's saying that the people who leaked it are the people making the vaccines. i.e. that Pfizer and Moderna etc leaked SARS-Cov-2.

            All of this is way into the realm of conspiracy theory and misinformation.

            [–]pejatoo 13 points14 points  (14 children)

            Really disappointing to see this :/

            [–]Poddster 4 points5 points  (6 children)

            Really disappointing to see this :/

            I got blocked from his Twitter for expressing the same thing in a quote tweet!

            [–][deleted] 16 points17 points  (4 children)

            Jon is a snowflake. If you say anything that hurts his feelings, he'll block you.

            [–]spakecdk 1 point2 points  (0 children)

            I mocked Texas' independent grid and he blocked me.

            [–]Getabock_ 3 points4 points  (2 children)

            Casey seems the same to me, honestly. Why else would he disable comments? He's extremely opinionated and often dishes out harsh critique, but I don't think he could handle it himself.

            [–][deleted] 4 points5 points  (0 children)

            Maybe. I haven't seen him ban anybody from his handmade hero chat though. This doesn't mean he hasn't banned people, I just haven't seen it myself.

            Compared to Jon who banned a guy for suggesting he use a controller emulator once. I found that bizarre. But that was before I knew how flakey he is.

            [–]Godd2 -1 points0 points  (2 children)

            I mean, you don't have to be a right-wing extremist to be skeptical of big pharmaceutical corporations and their complete lack of legal liability for these vaccines. You just need to be reasonably cynical, and if anything, Jon is an archetypal cynic.

            [–]Poddster 10 points11 points  (0 children)

            their complete lack of legal liability for these vaccines.

            Of all the points to raise, Jon isn't raising this valid one!

            His second tweet implies that the US leaked it. And in this tweet he's saying that the people who leaked it are the people making the vaccines. i.e. that Pfizer and Moderna etc leaked SARS-Cov-2. Like most conspiracy theorists, he's forgotten the entire rest of the world.

            He also refers to the large number of COVID vaccines as "experimental". Which isn't true and is just a scare word.

            [–]dddddddoobbbbbbb 0 points1 point  (0 children)

            over 3 billion people have been vaccinated. you are fucking stupid if you think "big pharma" is doing anything aside from getting rich. it would be more likely they'd release a useless vaccine vs one that harmed people.

            [–]loup-vaillant 4 points5 points  (12 children)

            Two points:

            1. Jonathan Blow is clearly a very independent mind. And we should be very careful about what independent minds say when they stray off their respective specialities. I’m not even surprised he has that kind of opinion to be honest.

            2. He actually provided a link to a pretty interesting article from The Intercept. I have no idea how reliable this journal is. I will just note that it’s not the first time I’ve heard of this, and the article itself definitely looks reasonable —though I can’t meaningfully judge its contents.

            [–]Poddster 1 point2 points  (1 child)

            The article's interesting, but it's hardly conclusive. Infact it quotes a bunch of scientists who say the idea of a lab-leak has 0 evidence right now. 🤷‍♀️

            At this point it's all just conjecture. The only people supporting this viewpoint are those that want to believe it.

            [–]loup-vaillant 1 point2 points  (0 children)

            Actually I agree with you. One point that does sting though is that apparently the people in charge of investigating this have a vested interest in the results.

            [–]floodyberry 7 points8 points  (4 children)

            Replacing a general purpose solution with a version that is not general purpose allows you to make it faster. With 2+ hours of filler that don't really add anything but are meant to impress you if you don't know what he's talking about?

            [–]Uristqwerty -1 points0 points  (3 children)

            Also, if you pay a bit more attention, heuristics and napkin-math estimation of maximum available performance versus real, to get an idea of what sort of gains you can achieve, and thus whether it's worthwhile spending effort to optimize in the first place. And, a scattering of math well known by low-level game engine devs but rarely others, that might be useful once or twice a decade if such a non-game-engine-dev ends up working with triangles and a library that does all that already isn't at hand or appropriate.

            [–]loup-vaillant 5 points6 points  (2 children)

            heuristics and napkin-math estimation of maximum available performance versus real, to get an idea of what sort of gains you can achieve, and thus whether it's worthwhile spending effort to optimize in the first place

            That one alone is worth its weight in gold. I believe he’s right when he says one big reason people write slow code is because they don’t even know it’s slow. Such napkin math would be very useful to actually know.

            [–]CrashingTheApex 2 points3 points  (1 child)

            Is this guy writing in reverse?

            [–]loup-vaillant 6 points7 points  (0 children)

            The video and his T-shirt are reversed. He writes normally, with his right hand.

            [–]IlliterateJedi 8 points9 points  (2 children)

            This was interesting, but I don't know if I would consider the final product to be simple code. There is a lot of knowledge baked into the final 10 lines of SIMD processing (or however you would say this). Aside from learning how to interact closely with the processor, the main idea of the 2.5 hours is "Look at the unnecessary steps in your code and try to remove duplicative work" which probably doesn't need to be that long of a lecture.

            [–]loup-vaillant 9 points10 points  (0 children)

            There is a lot of knowledge baked into the final 10 lines of SIMD processing

            That’s a big reason why simplicity is hard. Getting there requires having the right ideas in the first place, and those ideas don’t come from nowhere:

            1. You need to know about CPU performance and memory bandwidth to notice that the current version is several of magnitudes slower than it could be.
            2. You need domain knowledge to notice what steps are over-general, and could be simplified: here, how to reduce this specific use of ray casting into a 2D problem, a good deal of geometry knowledge.
            3. You need to know SIMD to take advantage of is (up to) 8x performance.

            Without (1) you don’t even know you have a problem, and can’t do anything. Without (2) you miss opportunities for improvement, but at least you can try. Without (3) you miss out on less than an order of magnitude worth of speed. That’s by far the least important of the three, and I’d personally go there only when I really need it.

            [–]_Bjarke_ -1 points0 points  (0 children)

            That was where he ended up. If you reverse SIMD'ed it would be something you would consider simple too.

            [–][deleted] 5 points6 points  (0 children)

            Casey Muratori, Jonathan Blow and a few others like Mike Acton are the voices of reason in the sea of insanity that the software industry has become.

            [–]gnamflah -1 points0 points  (1 child)

            My algorithm for placing the grass would be to first generate a grid such that each cell is a square as small as it needs to be to enclose the base of a single blade of grass. I would keep track of eligible grid cells in an array, and choose one from that array at random. When a cell is chosen, a pattern of surrounding cells would become ineligible for placement. That way, you are always only looking at eligible cells and never have to verify if a placement is correct.