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: HenryCost
I wired my tree with 500 LED lights and calculated their 3D coordinates… If you support me on Patreon at any point in December 2020 I wi...
New
First poster: bot
A field guide to help you recognize achievement, spot A field guide to help you recognize achievement, spot bottlenecks, and debug your d...
New
First poster: dyowee
Everyone seems to be striving for ‘clean’ code at the moment. You can’t read a blog post without the author telling you how clean their a...
New
First poster: bot
How a piece of advice became a lifestyle TABLE OF CONTENTS WHERE TO BEGIN… FIRST CONTACT PICKING EMACS FOR LIFE CHEATING ON EMACS SERE...
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: FatimaAdamu
Two US lawyers fined for submitting fake court citations from ChatGPT. Law firm also penalised after chatbot invented six legal cases th...
New
First poster: AstonJ
Jan | Rethink the Computer. Jan turns your computer into an AI machine by running LLMs locally on your computer. It’s a privacy-focus, l...
New
First poster: AstonJ
On the benefits of learning in public. Learning in public helps me grow as an engineer and seems to benefit others too. Here’s why I sho...
New
New
CommunityNews
Rendering Action Mailer emails with Phlex components and layouts: Clean, Composable, and Completely Ruby - Blog post by Camillo Visini
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
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
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
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
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...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
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
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New