Why Writing Simple Code is Painfully Hard!

Поделиться
HTML-код
  • Опубликовано: 17 янв 2025
  • НаукаНаука

Комментарии • 40

  • @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. "

  • @xtraszone
    @xtraszone 2 месяца назад +1

    A foolish admires complexity
    A genius admires simplicity

  • @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 Месяц назад

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

  • @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

  • @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

  • @baruchrevivo2966
    @baruchrevivo2966 2 месяца назад +1

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

  • @itskittyme
    @itskittyme 2 месяца назад +2

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

  • @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.

  • @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 27 дней назад

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

  • @rosendom3042
    @rosendom3042 2 месяца назад +1

    God, this video was so good!

  • @spiderfan562
    @spiderfan562 Месяц назад +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.

  • @rahuldsouza1985
    @rahuldsouza1985 2 месяца назад

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

  • @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?

  • @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

  • @dogsniffing2022
    @dogsniffing2022 2 месяца назад +1

    Thank you!! :)

  • @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

  • @flobbie87
    @flobbie87 2 месяца назад +1

    There is no paradox.

  • @rosendom3042
    @rosendom3042 2 месяца назад

    Less is less code to write too!

  • @kavinmanoharan8585
    @kavinmanoharan8585 2 месяца назад

  • @Gravybagel
    @Gravybagel 2 месяца назад

    I like your channel, but you should spend some time on your English pronunciation. Most is good, but a couple sounds are off, notably the “sh” sound. You turn these into “s” sounds and it’s quite jarring. Function should be funk-shun instead of funk-son. That sh comes from starting with a closed teeth s, then drawing the tip of the tongue up and back without touching the roof of your mouth. It should soften that s and get you to the right sound.
    Keep it up!

    • @edgeeffect
      @edgeeffect 2 месяца назад

      How many languages do you speak fluently?

    • @Gravybagel
      @Gravybagel 2 месяца назад

      Hmm, this is not really about me. I hope the best for codemunk. I do know that language barriers inhibit communication and limit reach. I’d like for his reach not to be limited by his presentation. If he doesn’t get any feedback of this sort, he won’t do anything about it. Problem is that native English speakers will notice it and will judge his videos on it. I’d prefer that didn’t happen. It’s literally just a couple small things because most of his pronunciation is perfect.