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.
My mum said I’m not pretty, so I better be talented…
that's wild bro, but i feel you
is she really your mother?
"If the women don't find you handsome, they should at least find you handy."
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.
I usually like his takes on things, but really you put it better than him
Something something accidental complexity vs essential complexity
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.
Screams in GCC C++ Standard Template Library implementation.
rainman.mp3
This is how an anime villain talks about ugly code.
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
Now I feel good writing ugly code
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.
Code is also big chunks of buffers that are being transformed over time
@@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
@@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.
@@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
@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.
"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".
Yes, biochemistry is also super messy but super useful. Have you seen the inner workings of a mitochondria for example
yes i did and it sucks 😔
You are like coders psychologist.
Me writing quicksort algorithm without any helper functions 💪
I do not write beautiful code. I write minimal and practical code that will be easy to replace or reuse
If it easy to replace and reuse, its probably beautiful code
that's the definition of beautiful code ...?
Thanks for the thoughts!
Debugging ugly code is easier than debugging good looking code that appears to be perfect while in realty is has a lot of bugs.
No, inheritance-based, pattern-obsessed OO code is ugly, and only sometimes useful.
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.
If your primary concern is readability or to make it look pretty then the code is clearly going to suffer.
👏👏👏👏 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.
Говорят, чистый и полезный код всегда есть у сына маминой подруги😅
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"
Just because something can be better or worse, does that imply that it can be good?
@@drdca8263 yes any system with a spectrum of better and worse can have defined regions of good and bad.
Reminds me of that life saving C macro that I made which looked fucking atrocious. But it worked and it did great.
Amen
Don't learn how to read bad code, just get a LLM to read it for you :)
I don’t think that will work very well.
because of entropy
Check Svelte's codebase, what a beauty 😌
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.
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.
Good take, honestly.
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.
Goated take.
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.
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.
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.
I really spend too much time watching this channel when I should be coding.
I agree with every sentence.
Use julia
what is the theme that he uses.
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.
I disagree with everything
this is not true. You can write js MUCH better, speaking as a js monkey
wow... 18 years of writing code and the guy didn't find time to learn how to SOLID. Чувак, ты можешь быть говонокодером хоть 60 лет подряд - это не отменяет существование нормальной архитектуры.
Поясни, что такое "нормальная архитектура". Надеюсь, ты не приведёшь пример с перетаскиванием JSON и крудошлёпством с контроллерами / сервисами / репозиториями.
@@xeno12321 нормальная архитектура - это когда у тебя есть корень композиции, интерфейсы для абстракции с последующими депенденси иньекциями и всем остальным, что описано в SOLID. Просто почитай, там же блин написано всё.