Why Writing Simple Code is Painfully Hard!

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ม.ค. 2025

ความคิดเห็น • 37

  • @SimGunther
    @SimGunther 2 หลายเดือนก่อน +12

    0:31 An idiot admires complexity, a genius admires simplicity

  • @asagiai4965
    @asagiai4965 2 หลายเดือนก่อน +5

    3:35 being one liner and multiple lines sometimes have nothing to do with code complexity.
    Also just because one use loops and the other uses recursion. It also doesn't say anything about complexity.
    But yes if you overengineer something it always tend to get more complex.
    "Complexity is not really about what type of coding someone use, but how someone use it. "

  • @arashgudarzi2623
    @arashgudarzi2623 2 หลายเดือนก่อน +5

    as a Cybersecurity specialist, gatta tell you, don't mistake simple code for vulnerable code. always have your input validations there. sometimes you need to cover all the possibilities. write simple, but also watch out for the part that can be broken by malicious fellas out there

    • @Stiffsen
      @Stiffsen 2 หลายเดือนก่อน

      Agreed. Some early returns for checking state and arguments never hurts.

  • @somerhaha1687
    @somerhaha1687 2 หลายเดือนก่อน +4

    The factorial example isn't great since recursion is more prone to bugs and is harder to debug. Also making it a one liner is bad for readability

  • @xtraszone
    @xtraszone 2 หลายเดือนก่อน +1

    A foolish admires complexity
    A genius admires simplicity

  • @DreySF
    @DreySF 2 หลายเดือนก่อน +7

    Train youself in test driven development and you'll have simple code not just for trivial functions.😢 And tdd is not about tests btw.

    • @Kitsune_Dev
      @Kitsune_Dev หลายเดือนก่อน

      then what is it about?

  • @Daniel_Zhu_a6f
    @Daniel_Zhu_a6f 2 หลายเดือนก่อน +38

    0:50 this is a ridiculous code example, it is reductive beyond any measure.
    3:40 you've made code much slower (and harder to step through in a debugger) by converting iteration into recursion.
    this is terrible advice

    • @jeffreyjdesir
      @jeffreyjdesir 2 หลายเดือนก่อน

      Tail call optimization and memoization help with recursive algorithms …it’s almost all subjective but comes down to what have you actually made 😮

    • @321varga
      @321varga 2 หลายเดือนก่อน +9

      I was thinking the same. While I agree with the message of the video (keep things simple) the example at 3:40 is a bad one. I personally like recursion but it can easily make the code harder to read and debug. There's a reason why it's banned at NASA for example.
      Just because a piece of code became less lines it doesn't mean it's simpler.

    • @Daniel_Zhu_a6f
      @Daniel_Zhu_a6f 2 หลายเดือนก่อน +5

      ​@@jeffreyjdesir it's not subjective when you need the code working.
      i wouldn't say a thing if it was directory scanning or some parsing, because it can rarely get more than 20 frames deep. but in recursive math functions this is actually a practical consideration.
      Edit: i've checked and factorial(21) overflows uint64, so in reality stack depth is not even a top concern here.

    • @krzysztofbulicz416
      @krzysztofbulicz416 2 หลายเดือนก่อน

      I hate when someone does things like in 3:40, it's like writing a design, without an enter button.

    • @saaah707
      @saaah707 2 หลายเดือนก่อน

      that code will optimize into the same exact loop, so in practice it's not slower.
      the main reason to avoid recursion is because of weak devs who spent their whole careers avoiding recursion for no reason other than being scared to think, when they encounter it, their eyes go wide with disbelief, shock, and fear

  • @peddivarunkumar
    @peddivarunkumar 2 หลายเดือนก่อน

    Loved the video❤

  • @ioannischristou2362
    @ioannischristou2362 หลายเดือนก่อน

    if the engineers at OpenAI followed the "simplicity argument" the ChatGPT program would probably be the following code:
    def chat(input_dialogue):
    print("Hi, I'm ChatGPT. I may not know how to reply to '"+input_dialogue+"', but my source code is really simple to read. Just try it.")
    Hey, I just created the simplest AI in the world...

  • @west221b
    @west221b หลายเดือนก่อน

    "Build simplicity, then add lightness." --Colin Chapman, founder of Lotus

  • @spiderfan562
    @spiderfan562 2 หลายเดือนก่อน +1

    Yeah but sometimes you just have to check for possible scenarios. If you are paid to make an app and don't put some code to check if the user actually inputs a number and then the product is published, all the users who will not input a number will get errors. There will probably not be many of them but still your product would not be as good as if you had written just 2 more lines of code.

  • @baruchrevivo2966
    @baruchrevivo2966 2 หลายเดือนก่อน +1

    “Make it as simple as possible, but not simpler”
    Albert Einstein

  • @rosendom3042
    @rosendom3042 2 หลายเดือนก่อน +1

    God, this video was so good!

  • @lukasjetu9776
    @lukasjetu9776 2 หลายเดือนก่อน +2

    >be me
    >be 12
    >try to write a program to use as a template for all my other projects
    >get stuck at the fps part
    >be stupid
    >calculate fps as the {sum of 1000/ms in each frame}/totalFramesCounted
    >leave it
    >wonder why am i getting -2³¹ fps if higher than a certain number
    >leave
    >enter, now a 13 year old
    >read my code
    >realizes I could've just used totalFramesCounted
    >realizes i was just dividing n² by n
    >realizes i was literally counting the frames in a second
    >fix it
    >leave
    >enter, now still a 13 year old but older
    >click on a video
    >it's about programming
    >gets the idea to type my encounter i had
    >types it out as a comment
    >pure satisfaction

    • @blossoms2u
      @blossoms2u 2 หลายเดือนก่อน

      Can you name it simple 😅

    • @lukasjetu9776
      @lukasjetu9776 2 หลายเดือนก่อน

      @blossoms2u nah that's impossible

    • @o_glethorpe
      @o_glethorpe 2 หลายเดือนก่อน

      They teach programming in kindergartens now dude, nobodys getting impressed by your age anymore

    • @lukasjetu9776
      @lukasjetu9776 2 หลายเดือนก่อน

      @@o_glethorpe why would you think I'm trying to impress someone by my age?? anyways do they now actually teach programming in kindergartens or was that just some sort of an ego destroyer?

  • @itskittyme
    @itskittyme 2 หลายเดือนก่อน +2

    0:18 that dude is literally what I had and did a few hours ago xD

  • @asagiai4965
    @asagiai4965 2 หลายเดือนก่อน

    My take is simple code is easy to write, hard to think of.
    My code is always simple.

  • @nevergonnagiveyouupnevergo3263
    @nevergonnagiveyouupnevergo3263 2 หลายเดือนก่อน

    Where ?? I dont get it, what engine does it use to program?

  • @asagiai4965
    @asagiai4965 2 หลายเดือนก่อน

    I try to avoid complex things what do you mean

  • @rahuldsouza1985
    @rahuldsouza1985 2 หลายเดือนก่อน

    Jack Dorsey said "To make something simple is not so simple"

  • @glorytoarstotzka330
    @glorytoarstotzka330 2 หลายเดือนก่อน

    I think complex code is an intermediary step towards reaching simple code, and that's a bit in contradiction of what the video implies, the video implies that we pick complexity, not as a necessary evil (or an intermediary step) but that's just because we think is better
    I personally tried to write simple code from the very start and I'd just spend like x3ish the time to write the same end code because I would really wanna avoid complexity, but avoiding complexity as a middle step is fundamentally avoiding exploration and therefore understanding the problem becomes much slower

  • @dogsniffing2022
    @dogsniffing2022 2 หลายเดือนก่อน +1

    Thank you!! :)

  • @flobbie87
    @flobbie87 2 หลายเดือนก่อน +1

    There is no paradox.

  • @rosendom3042
    @rosendom3042 2 หลายเดือนก่อน

    Less is less code to write too!

  • @kavinmanoharan8585
    @kavinmanoharan8585 2 หลายเดือนก่อน