Useful Code Is Ugly | Tsoding

Поделиться
HTML-код
  • Опубликовано: 16 сен 2024
  • There is no such thing as Good Code.
    From the "Backend WebAssembly (Part 2)" stream.
    Tsoding Daily: / @tsodingdaily
    This channel is not affiliated in any way with the Tsoding Daily channel or any of the three owners of the main Tsoding channel.

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

  • @alst4817
    @alst4817 9 дней назад +125

    My mum said I’m not pretty, so I better be talented…

    • @oumardicko5593
      @oumardicko5593 9 дней назад +10

      that's wild bro, but i feel you

    • @khaledahmed2051
      @khaledahmed2051 8 дней назад +1

      is she really your mother?

    • @ashton7981
      @ashton7981 5 дней назад +6

      "If the women don't find you handsome, they should at least find you handy."

  • @taylankammer
    @taylankammer 8 дней назад +63

    Yes and no. Real-world problems that you want to solve with code are, indeed, often quite messy. And that messiness will necessarily be reflected in the code that's written to solve that problem. However, "good" code is only as messy as it needs to be, and not messier. There's a thousand ways to write code that's even more messy than the original problem you're trying to solve, and that would be called bad code.

    • @galzafar2943
      @galzafar2943 7 дней назад +2

      I usually like his takes on things, but really you put it better than him

    • @wimdetroyer3290
      @wimdetroyer3290 7 дней назад +4

      Something something accidental complexity vs essential complexity

    • @xealit
      @xealit 5 дней назад +1

      Exactly. There are idioms, data structures, etc that fit the problem better or worse. You can handle the real life mess better or worse. There’s no point to just give up and condemn yourself to just rummage in trash. At the same time, sure, there’s no point in being a puritan and discard any messy code.

  • @aniketbisht2823
    @aniketbisht2823 8 дней назад +49

    Screams in GCC C++ Standard Template Library implementation.

  • @yutoriotsu8848
    @yutoriotsu8848 7 дней назад +7

    This is how an anime villain talks about ugly code.

  • @itstoly
    @itstoly 4 дня назад +2

    I did, and I wrote some.
    You usually start clean, then things get real and code gets messy. This is a sign of incomplete design and/or wrong assumptions at the start of the project.
    And then, things get unmanageable, so you have to rethink and redesign the code to match new expectations without breaking compatibility. And this is the hardest part - backward compatibility code that doesn't make your brain melt when you read it. But it's totally possible, and I am the living proof of this, doing it in the real organization every day of my life

  • @pennti
    @pennti 4 дня назад +2

    Now I feel good writing ugly code

  • @ramsey2155
    @ramsey2155 9 дней назад +27

    Depends on what you mean by useful and pretty. I tend to rewrite a lot of things just for it to be more readable. Call it bad practice but it gets important when you want to expand your workspace. The best is probably to refactor after successfully building, this way you get the job done and can rescale it in the future. Though I absolutely agree with the job part, it's mostly unnecessary to get things pretty when you have a deadline.
    Also neural network's are not code they are big chunks of buffers that are being transformed over time.

    • @aaronspeedy7780
      @aaronspeedy7780 9 дней назад +6

      Code is also big chunks of buffers that are being transformed over time

    • @ramsey2155
      @ramsey2155 9 дней назад +1

      @@aaronspeedy7780 Nah, code is text. You can still store it in a buffer but thats still completely different than what ai models do. They have a purely mathematical buffer that enocodes meaning for different words. So they don't write their own code they just process the meanings of different tokens based on that buffer

    • @aaronspeedy7780
      @aaronspeedy7780 8 дней назад +4

      @@ramsey2155 Yeah one is a buffer of floats while the other is a buffer of ints, but it's all the same. Individual models are just weird non turing complete programming languages with smooth paths between different programs.

    • @ramsey2155
      @ramsey2155 8 дней назад

      @@aaronspeedy7780 Thats still irrelevant, you can call any stored data "chunks of buffers". A text file is chunks of buffers an image file is also chunks of buffers but that doesn't mean a text file is an image file

    • @MrHaggyy
      @MrHaggyy 8 дней назад +1

      @ramsey2155 i love people that put in the time for a readable refactor. If you get the same problem with slightly different mess around it it's a matter of hours, not days, to write the new code.

  • @user-dc9zo7ek5j
    @user-dc9zo7ek5j 5 дней назад +3

    "Learn to read bad code" This is such a good advice. Placing good and bad in abstract fields such as coding is misleading. What exactly is bad about it? It has too much logic, too cryptic names? Unreadable code is bad; but worse is non-functioning 1 thing per file type of code; or pretty code that has been hell-ed up with patterns, classes to appear simple but is very hard to get the big picture or debug. Code cannot be pretty or ugly, but design of the flow can be. Look at Zoran Horvat, although he is OOP zealot his ways of solving problems can be very helpful in understanding the core problem of "readability".

  •  8 дней назад +9

    Yes, biochemistry is also super messy but super useful. Have you seen the inner workings of a mitochondria for example

    • @gorlix
      @gorlix 8 дней назад +1

      yes i did and it sucks 😔

  • @Qqquuaa
    @Qqquuaa 8 дней назад +9

    You are like coders psychologist.

  • @p99chan99
    @p99chan99 9 дней назад +14

    Me writing quicksort algorithm without any helper functions 💪

  • @DEVDerr
    @DEVDerr 9 дней назад +13

    I do not write beautiful code. I write minimal and practical code that will be easy to replace or reuse

    • @buycraft911miner2
      @buycraft911miner2 8 дней назад +6

      If it easy to replace and reuse, its probably beautiful code

    • @alexkfridges
      @alexkfridges 4 дня назад

      that's the definition of beautiful code ...?

  • @vladislavkaras491
    @vladislavkaras491 4 дня назад

    Thanks for the thoughts!

  • @olafbaeyens8955
    @olafbaeyens8955 7 дней назад +4

    Debugging ugly code is easier than debugging good looking code that appears to be perfect while in realty is has a lot of bugs.

  • @ericpmoss
    @ericpmoss 7 дней назад +1

    No, inheritance-based, pattern-obsessed OO code is ugly, and only sometimes useful.

  • @giorgos-4515
    @giorgos-4515 8 дней назад +5

    Useful clean code for me is when there are separate functions, the control flow is intuitive, and the naming/documentation is good enough that the domain can be simply understood.

  • @Jeremyak
    @Jeremyak 7 дней назад +3

    If your primary concern is readability or to make it look pretty then the code is clearly going to suffer.

  • @redkotful
    @redkotful 4 дня назад

    👏👏👏👏 learning to read code ! fuck yeah ! thank you for stating one of the most neglected and one of the most important skills for working with software.

  • @ЕвгенийКрасилов-о9о
    @ЕвгенийКрасилов-о9о 8 дней назад +4

    Говорят, чистый и полезный код всегда есть у сына маминой подруги😅

  • @NihongoWakannai
    @NihongoWakannai 8 дней назад +5

    This kinda sounds like cope from someone who just doesn't want to bother writing code that others can understand.
    There are plenty of ways to write the exact same functionality in more or less understandable ways. Being lazy and writing a less understandable and less maintainable codebase just because "useful code is messy" is major copium.
    These are the type of people who write code with one letter variables and 5 levels of indentation and then try to tell you "nah bro, clean code is a lie"

    • @drdca8263
      @drdca8263 8 дней назад

      Just because something can be better or worse, does that imply that it can be good?

    • @NihongoWakannai
      @NihongoWakannai 8 дней назад +1

      @@drdca8263 yes any system with a spectrum of better and worse can have defined regions of good and bad.

  • @nzeu725
    @nzeu725 5 дней назад +1

    Reminds me of that life saving C macro that I made which looked fucking atrocious. But it worked and it did great.

  • @marcempunkt9737
    @marcempunkt9737 8 дней назад +2

    Amen

  • @ZM-dm3jg
    @ZM-dm3jg 8 дней назад +4

    Don't learn how to read bad code, just get a LLM to read it for you :)

    • @drdca8263
      @drdca8263 8 дней назад +1

      I don’t think that will work very well.

  • @carriagereturned3974
    @carriagereturned3974 2 дня назад

    because of entropy

  • @thelazycoder64
    @thelazycoder64 9 дней назад +1

    Check Svelte's codebase, what a beauty 😌

  • @fakt7814
    @fakt7814 8 дней назад +1

    Yes, I write it. Ok, I'll be serious, it depends on what you mean by clean or pretty code. Many if not majority of standards of code quality are either superficial and focusing on the wrong things, setting unrealistic expectations, or based on false premises. For example, it is believed by some clean code evangelists that methods should be no more than 20 lines of code. Generally you need more abstractions for code consisting methods of only 20 lines long than for a code that does not have that limit. So clearly this limit has it's own drawback. Abstractions make code less readable most of the time. IMO, abstractions is a greater danger for the code readability than the average number of lines of methods. Most of the time you can just use folds, it has almost all of the advantages and none of the disadvantages of abstraction. If that is what we consider a pretty code, than yes, useful code is not pretty, because a standard like this is not only based on a false premise, but simply setting unrealistic bar. At the same time, having as few control flow alterations and nestedness as possible most of the time is a good practice. It makes code more readable, more debuggable, with practice it's easier to write and validate than code that is a canyon of nested ifs and elses with uncertain control flow.
    I also disagree that neural networks are spaghetti code. Spaghetti code usually have very confusing control flow. Neural networks have a very trivial control flow, as if it was a code that had no IF statements at all. It's not even Turing-complete. In a way, this can be seen as a cleanest code possible.

    • @user-dc9zo7ek5j
      @user-dc9zo7ek5j 5 дней назад

      Abstractions produce less code if they are created and used properly. They help you delegate some of the responsibility to another logic that is very good at this task and this prevents errors and incompatability issues between code. However, they must be used as a glue and not for business logic. If they contain business logic they practically become single use case, and the worsening of its code is to add conditionals that are outside its responsibilities within. With abstractions I was able to reduce bugs for a project and after that it grew so big that I created a library which helped 5 or more projects.

  • @Aziqfajar
    @Aziqfajar 9 дней назад +2

    Good take, honestly.

  • @GameZONE-vn
    @GameZONE-vn 8 дней назад +1

    Yesn’t.
    Yes, if you are writing raw machine code and it always ugly.
    In my opinion (IMO), a big mess is a group of many problems. just need to break it down into smaller problems to solve.
    If you cannot break it down, it means you don’t understand it.
    Programming cannot be compared to life because we don’t understand life. However, we can understand math and code.
    Math and code should be binary.
    Life is undefined and unpredictable.

  • @Kaptime
    @Kaptime 8 дней назад +2

    Goated take.

  • @snatvb
    @snatvb 7 дней назад

    not really, I've seen it and I'm trying to strive for it.
    100% impossible to achieve.
    These are two extremes, and your job is to balance the two.
    In fact, beautiful code can be more confusing.
    but if you don't care about simplicity and “beautiful code” you will quickly run into support problems.

  • @Lynellf
    @Lynellf 8 дней назад +2

    Pretty is subjective. Ugly is subjective. Use formatters. Ugly code can hide flawed design at worst, introduce unnecessary cognitive overhead at best. Don’t write code without a formatter. Thanks.

  • @MrHaggyy
    @MrHaggyy 8 дней назад

    While you can have bad and good code that is functional identical writing good code is better. Most peoples life is already messy enough, no need to shuffle even more mess on their head.

  • @scottwilliams1902
    @scottwilliams1902 9 дней назад

    I really spend too much time watching this channel when I should be coding.

  • @albertoarmando6711
    @albertoarmando6711 8 дней назад

    I agree with every sentence.

  • @Spirit-DEV
    @Spirit-DEV 3 дня назад

    Use julia

  • @sujaljain8535
    @sujaljain8535 8 дней назад

    what is the theme that he uses.

  • @creativeimpulselab
    @creativeimpulselab 7 дней назад +1

    I'm afraid I have to disagree. I have seen both. I have seen more bad code written in safe languages than C/C++. I am not sure what the definition of good code we are referring to in this video, but I believe if some one cannot find good code in such long life span then its time to change the fellow developers.

  • @MynecraftCZ
    @MynecraftCZ 8 дней назад

    I disagree with everything

  • @xxcrypt234
    @xxcrypt234 9 дней назад

    this is not true. You can write js MUCH better, speaking as a js monkey

  • @user-lv6qm3fj2z
    @user-lv6qm3fj2z 8 дней назад +1

    wow... 18 years of writing code and the guy didn't find time to learn how to SOLID. Чувак, ты можешь быть говонокодером хоть 60 лет подряд - это не отменяет существование нормальной архитектуры.

    • @xeno12321
      @xeno12321 8 дней назад +1

      Поясни, что такое "нормальная архитектура". Надеюсь, ты не приведёшь пример с перетаскиванием JSON и крудошлёпством с контроллерами / сервисами / репозиториями.

    • @user-lv6qm3fj2z
      @user-lv6qm3fj2z 8 дней назад

      @@xeno12321 нормальная архитектура - это когда у тебя есть корень композиции, интерфейсы для абстракции с последующими депенденси иньекциями и всем остальным, что описано в SOLID. Просто почитай, там же блин написано всё.