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.

4 480 3

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: Maartz
This Keyboard Lets People Type So Fast It’s Banned From Typing Competitions. A new peripheral lets you keep typing without ever lifting ...
13 1663 6
New
First poster: dpritchett
It’s not what programming languages do, it’s what they shepherd you to. How many of you have listened, read or taken part in a discussio...
50 1714 19
New
CommunityNews
Docker on MacOS is slow and how to fix it. Thanks to the DALL·E 2, we finally have a very nice graphic representation of the feelings of...
1 1111 1
New
First poster: bot
Raspberry Pi security alarm — the basics. In November last year — I started building a DIY security alarm system, using a Raspberry Pi a...
0 1924 0
New
First poster: dani
The pool of talented C++ developers is running dry. Highly sought after, rarely provided.
13 1017 5
New
CommunityNews
The First Social-Media Babies Are Growing Up—And They’re Horrified. How would you feel if millions of people watched your childhood tant...
0 931 0
New
CommunityNews
The Definitive PHP 7.2, 7.3, 7.4, 8.0, and 8.1 Benchmarks (2023). We tested the performance of 14 PHP platforms (WordPress, Drupal, Lara...
0 1299 0
New
CommunityNews
Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
0 5956 0
New
First poster: jkdiaz
Dark mode isn’t as good for your eyes as you believe. The shadowy display mode has leagues of fans claiming it helps reduce eye strain, ...
3 966 2
New
First poster: alvinkatojr
Infrastructure as code, but actually
2 73 1
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
476 5781 112
New
malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
54 3555 17
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...
36 5432 10
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
212 15008 90
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
49 5284 39
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
160 3807 49
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...
10 5256 6
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
7 3059 3
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
0 4367 0
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
31 3800 16
New