CommunityNews

CommunityNews

Horrible Code, Clean Performance

Horrible Code, Clean Performance - Johnny’s Software Lab.
A short tale of how horrible code yields clean performance.

Read in full here:

This thread was posted by one of our members via one of our news source trackers.

Most Liked

Eiji

Eiji

Well … that’s pretty hard topic … :sweat_drops:

On one side new Elixir developers are definitely surprised seeing a solution with for example the [head | tail] notation in a recursive function. On the other side using just pattern matching in function clauses we have tons of flexibility. :exploding_head:

What is a horible code or rather what is a good code? For me the code is clean when I can describe what it do after not touching it even for let’s say 6 months. There are good and bad practices, many hints/tips as well as gotchas, but many of them are pretty specific and does not decide if the whole final code is good or not. :thinking:

Let’s then list some more generic points … What makes a code clean without affecting performance? :rocket:

  1. Follow core and community conventions like Naming Conventions in Elixir documentation or Credo’s Elixir Style Guide :memo:

  2. Write self-descriptive code i.e. avoid one-letter variables, short and cryptic names :man_detective:

  3. Write a good documentation. From user perspective (wiki), developer perspective (issue) to implementation details (pull request) in contributing part and from module/function documentation, typespecs up to guides and code examples in release part :spiral_notepad:

  4. If you have some idea, but you are not sure how to write it then search for inspiration in popular projects. Nobody expects that you know everything from start, but you should be smart enough to find what you need :mag:

  5. Follow your intuition :nerd_face:

Too generic? Such advice are everywhere? There is no short way or rather it is, but in exchange you would have a horrible code. All you need to do is to practice and without any lie examine yourself. Everyone thinking that’s boring have a really small view perspective. It’s not about be boring or not - it’s about how you would make it attractive. Everyone have different type of learning. Search for challenges in places you feel comfortable. In that way when you would be really bored you would come back for yet another challenge! :heart:

There is always someone more experienced and there is no shame in it. That’s actually a chance for you to improve. I recommend to look at José Valim streams on Twitch. They are worth to watch even when not live! At the end no matter how much years of experience you have don’t assume you know everything. :owl:

jss

jss

First time I encountered this is in my first job, in C/C++, years ago.
There was a part in the codebase that was really hard to understand, and I asked a senior developer about it. He said that it was written that way for performance reasons.

dev

dev

A good idea was written at the end of the article. That if there is a bottleneck in the program, then it will be a reasonable decision to sacrifice the purity of the code. In other cases, this is the destruction of one’s own work, because then it will be impossible to maintain it, and it will not be easy to bring the project with this approach to production. Therefore, clean and readable code should be everywhere, regardless of performance.

Where Next?

Popular General Dev topics Top

First poster: bot
Site Fingerprinting google.com Yes youtube.com Yes Amazon.com Yes Yahoo.com Yes Zoom.us No Facebook.com Yes Reddit.com Ye...
New
First poster: AstonJ
:tada: Launching Fig I am excited to announce that, as of today, Fig is generally available to the public for download. With our public ...
New
First poster: OvermindDL1
You can now buy a 100W USB-C cable with a built-in power meter. They’re just $20 on Amazon, and they work!
New
First poster: dani
The pool of talented C++ developers is running dry. Highly sought after, rarely provided.
New
First poster: bot
openai-python/chatml.md at main · openai/openai-python. The OpenAI Python library provides convenient access to the OpenAI API from appl...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New
First poster: KnowledgeIsPower
Building a Slack/Discord alternative with Tauri/Rust linen <span class="hashtag-icon-placeholder"></span>blog. Introduction My name is K...
New
New
First poster: adamaiken89
Why Ruby on Rails still matters. An old tool endures in a Next.js world
New
First poster: alvinkatojr
There are countless articles why developers should not focus on Frameworks too much and instead learn to understand the underlying langua...
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New