Browse Source

New chapter: optimization

master
Julio Biason 5 years ago
parent
commit
c18994f49c
  1. 1
      content/books/things-i-learnt/_index.md
  2. 2
      content/books/things-i-learnt/config-file/index.md
  3. 39
      content/books/things-i-learnt/optimization/index.md
  4. 2
      content/books/things-i-learnt/use-utf8/index.md

1
content/books/things-i-learnt/_index.md

@ -50,6 +50,7 @@ template = "section-contentless.html"
* [Start Stupid](start-stupid)
* [Always Use Timezones With Your Dates](use-timezones)
* [Always Use UTF-8 For Your Strings](use-utf8)
* [Optimization Is For Compilers](optimization)
* Making Things Go
* [The Config File Is Friend](config-file)
* [Command Line Options Are Weird, But Helpful](command-line-options)

2
content/books/things-i-learnt/config-file/index.md

@ -52,4 +52,4 @@ you'll find that you're half-way through it.
[^1]: In other words, they have a [time to
live](https://en.wikipedia.org/wiki/Time_to_live).
{{ chapters(prev_chapter_link="/books/things-i-learnt/use-utf8", prev_chapter_title="Always Use UTF-8 For Your Strings", next_chapter_link="/books/things-i-learnt/command-line-options", next_chapter_title="Command Line Options Are Weird, But Helpful") }}
{{ chapters(prev_chapter_link="/books/things-i-learnt/optimization", prev_chapter_title="Optimization Is For Compilers", next_chapter_link="/books/things-i-learnt/command-line-options", next_chapter_title="Command Line Options Are Weird, But Helpful") }}

39
content/books/things-i-learnt/optimization/index.md

@ -0,0 +1,39 @@
+++
title = "Things I Learnt The Hard Way - Optimization Is For Compilers"
date = 2019-07-15
[taxonomies]
tags = ["en-au", "books", "things i learnt", "optimization"]
+++
Let say you need more performance on your application. You may be tempted to
look at your code and think "How can I keep this same logic and still remove a
few cycles, so things seem to go faster?" Well, if you want performance, you
need to change your logic.
<!-- more -->
But before jumping into the code, you may have to check your compiler options.
Maybe you're not generating the optimized version. Maybe there is an option
that you don't use that you can remove from the compilation.
'Cause "optimization" is what a compiler is for. They _know_ where they can
extract most of the underlying architecture, and people have been finding ways
to make the compiled code more performance for decades. Heck, compilers can
even _delete_ parts of your code 'cause they can "see" that a piece of code
will always produce the same result and, thus, isn't necessary and they will
just put the same result where that piece of code was.
What you need to do is to think about a better _design_ for your code, not how
to improve the current code. And trying to trick the compiler by [messing with
the types](/books/things-i-learnt/data-types), although may produce faster
code, will really screw you in the future -- specially cause maintenance and
code understanding will take long and figuring out what went wrong will always
be harder.
Code is written for humans to read. _ALWAYS_. Optimization is what compilers
do. So find a smarter way to explain what you're trying to do instead of using
shorter words or messing with that your code is saying.
{{ chapters(prev_chapter_link="/books/things-i-learnt/use-utf8", prev_chapter_title="Always Use UTF-8 For Your Strings", next_chapter_link="/books/things-i-learnt/config-file", next_chapter_title="The Config File Is Friend") }}

2
content/books/things-i-learnt/use-utf8/index.md

@ -52,4 +52,4 @@ single character. Walking through the whole string would require traversing
the string character by character, instead of simply jumping straight to the
proper position. But that's a price worth paying, in the long run.
{{ chapters(prev_chapter_link="/books/things-i-learnt/use-timezones", prev_chapter_title="Always Use Timezones With Your Dates", next_chapter_link="/books/things-i-learnt/config-file", next_chapter_title="The Config File Is Friend") }}
{{ chapters(prev_chapter_link="/books/things-i-learnt/use-timezones", prev_chapter_title="Always Use Timezones With Your Dates", next_chapter_link="/books/things-i-learnt/optimization", next_chapter_title="Optimization Is For Compilers") }}

Loading…
Cancel
Save