Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Optimizing Code for Humans
Search
Felipe Ribeiro
May 11, 2017
Programming
6
390
Optimizing Code for Humans
Felipe Ribeiro
May 11, 2017
Tweet
Share
More Decks by Felipe Ribeiro
See All by Felipe Ribeiro
[Draft] My tech career abroad
felipernb
0
24
JavaScript @ Spotify - JSConf Iceland 2016
felipernb
4
390
Other Decks in Programming
See All in Programming
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
100
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
470
MCP with Cloudflare Workers
yusukebe
2
220
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
快速入門可觀測性
blueswen
0
370
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
820
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
450
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Navigating Team Friction
lara
183
15k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Designing Experiences People Love
moore
138
23k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Embracing the Ebb and Flow
colly
84
4.5k
Transcript
Optimizing code for humans @felipernb !
“Any fool can write code that a computer can understand.
Good programmers write code that humans can understand.” Martin Fowler - @martinfowler @felipernb !
Simplicity is subjective (?) ! @felipernb !
“The purpose of software engineering is to control complexity, not
to create it.” Pamela Zave @felipernb !
“A C program with six 32-bit integers can have more
states than the number of atoms on the planet” Joe Armstrong - @joeerl @felipernb !
Programming is hard ! @felipernb !
Where does complexity creep in? ! @felipernb !
Algorithms ! @felipernb !
“Fancy algorithms are buggier than simple ones, and they're much
harder to implement.” Rob Pike's Rule #4 - @rob_pike @felipernb !
Searching // O(n) function linearSearch(arr, x) { for (let i
= 0; i < arr.length; i++) { if (arr[i] === x) return true; } return false; } @felipernb !
“Oh! But my array is always sorted, so I can
make this faster. Let's get fancy!” Developer ! @felipernb !
Fancy search // Sorted arrays only, O(lg n) function binarySearch(arr,
x) { let low = 0; let high = arr.length - 1; while (low <= high) { const mid = ((high - low) >> 1) + low; if (arr[mid] === x) return true; if (a[mid] < element) low = mid + 1; else high = mid - 1; } return false; } @felipernb !
“Fancy algorithms are slow when n is small, and n
is usually small.” Rob Pike’s Rule #3 - @rob_pike @felipernb !
Don't get fancy! ! @felipernb !
“Data structures, not algorithms, are central to programming.” Rob Pike’s
Rule #5 - @rob_pike @felipernb !
Performance ! @felipernb !
“Premature optimization is the root of all evil” Donald Knuth
@felipernb !
“If it doesn’t work, it doesn’t matter how fast it
doesn’t work.” Mich Ravera @felipernb !
“The cleaner and nicer the program, the faster it's going
to run. And if it doesn't, it'll be easy to make it fast.” Joshua Bloch - @joshbloch @felipernb !
“Measure. Don't tune for speed until you've measured, and even
then don't unless one part of the code overwhelms the rest.” Rob Pike’s Rule #2 - @rob_pike @felipernb !
Novelty ✨ @felipernb !
“Surprise is one of the most expensive things you can
put into a software architecture.” Adam Tornhill - @adamtornhill @felipernb !
Boring is fine ! @felipernb !
“Are you quite sure that all those bells and whistles,
all those wonderful facilities of your so called powerful programming languages, belong to the solution set rather than the problem set?” Edsger W. Dijkstra @felipernb !
Naming things ! @felipernb !
“There are two hard things in Computer Science: cache invalidation,
naming things, and off-by- one errors.” Phil Karlton + the internet @felipernb !
Descriptive names can replace //comments @felipernb !
doThisAndThatAndReturnThisOtherThing(); If it's hard to name it, it's probably doing
too much @felipernb !
// Double negation is confusing ! if (!disabledFeature) { //
it's enabled! } Avoid flag names with negative meanings such as disable and disallow @felipernb !
Personal taste ❤ @felipernb !
“I do not like semicolons.” Some guy closing a perfectly
valid pull request ! @felipernb !
“You can't always get what you want.” The Rolling Stones
@felipernb !
Strict style guides are good ! @felipernb !
The code should be consistent regardless of who wrote it.
@felipernb !
Automation can put an end to lengthy and pointless discussions*
. * Specially when we all know that tabs make much more sense than spaces. @felipernb !
When consistency is a given, you can focus on what
really matters. @felipernb !
The ! Enterprise @felipernb !
“Any organization that designs a system will produce a design
whose structure is a copy of the organization's communication structure.” Conway's law @felipernb !
Cargo Cult ✈ @felipernb !
“A significant amount of programming is done by superstition” Chris
Siebenmann @felipernb !
Be ! skeptical @felipernb !
Tech Debt ! @felipernb !
“If you want to go fast you take some debt.
But the misunderstanding was that people thought that you never have to pay it back.” Ward Cunningham - @wardcunningham @felipernb !
“Technical debt is hard to explain, but a picture is
worth a thousand words” Jedd Ahyoung - @Jedd_Ahyoung @felipernb !
How to keep things sane? ! @felipernb !
KISS ! Keep it simple, stupid @felipernb !
“Everyone knows that debugging is twice as hard as writing
a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” Brian Kernighan @felipernb !
Design patterns ⛩ @felipernb !
Design patterns are not about pigeonholing problems, but a tool
to efficiently communicate solutions with a common vocabulary. @felipernb !
Refactoring ! @felipernb !
“Software is messy because it reflects our evolving understanding of
the problem as we wrote it.” Sarah Mei - @sarahmei @felipernb !
Unlike the messed up Tetris game, you should be able
to take the time to rearrange the pieces in your code. @felipernb !
Code reviews ! @felipernb !
“My code isn't done until I've gone over it with
a fellow developer.” Jeff Atwood - @codinghorror @felipernb !
Peer review ≠ Pair programming @felipernb !
@felipernb !
Pragmatism ! @felipernb !
“Engineers are hired to say no.” Uncle Bob Martin -
@unclebobmartin @felipernb !
@felipernb !
Sometimes you have to say no to fun @felipernb !
Thank you! @felipernb !