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
Developing Godot Projects with Neovim. When I started using Godot Engine, what surprised me the most is the built-in Language Server Pro...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
First poster: bot
Rewrite it in Rust by ridiculousfish · Pull Request #9512 · fish-shell/fish-shell. (Sorry for the meme; also this is obligatory.) I thi...
New
First poster: Korbin73
Whatever happened to Elm, anyway?. I see this question pop up quite frequently in lots of different arenas - folks are curious as to wha...
New
First poster: peterchancc
Why I like Clojure as a solo developer | Biff. Most of the reasons fall into a few categories: data orientation, the JVM, and the REPL.
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...
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, ...
New
First poster: dyowee
Software engineering job openings hit five-year low?. There are 35% fewer software developer job listings on Indeed today, than five yea...
New
First poster: joeb
The new frameworks will continue until morale improves.
/js
New
CommunityNews
GitSyncPad is an innovative micro keypad designed for effortless Git version control. Execute commands like git add, git commit, and git ...
New

Other popular topics Top

AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New