Read SICP, learn about Erlang, look at FP features in Javascript and Rust. All super super worth it.
-
Show this thread
-
O.k. item FOUR ... check everything and bail on bad. What do I mean by this? I mean every time you call a function, a library routine, or whatever ... check for errors! don't mask exceptions. Anticipate "that shouldn't happen" errors.
1 reply 2 retweets 16 likesShow this thread -
If there are invariants that should hold in your program, check those too! You can pretty much never check things too much. And if things don't add up .... bail! Be very very defensive in your programming.
1 reply 1 retweet 8 likesShow this thread -
This also relates to a simple programming tip. It can be easy to fall into a pattern of ... if (condition1 == good) { ... if (condition2 == good) { ... if (condition3 == good) { do_something(); but this is bad and becomes dangerous.
1 reply 2 retweets 10 likesShow this thread -
Instead do: if (condition1 != good) { bail(); } ... if (condition2 != good) { bail(); } if (condition3 != good) { bail(); } usually makes context much clearer, avoids nesting confusion, and builds in that pattern of bailing!
1 reply 1 retweet 48 likesShow this thread -
o.k. last piece of advice and it is ... don't write "what" comments, write "why" comments. If you have to comment on what your program is doing, then the code itself was not readable! Instead use comments to provide context.
1 reply 2 retweets 29 likesShow this thread -
Use readable variable names that are nouns and meaningful function names that are verbs. The code doesn't have to be poetry, but it can absolutely be easy to follow. Give your future self an easier time. Code is written to be read.
1 reply 3 retweets 18 likesShow this thread -
Very very rarely there is code that can't be easily read; if you're using bitwise operators as part of cryptography or compression or something, for example. Comment those with a "WTF is this doing" ... be very very verbose. But that's the only exception I've found!
1 reply 2 retweets 9 likesShow this thread -
Which brings me to the $1000 programming contest! 3 prizes: $500, $300, $200 for the most readable, easy to follow, tested, Apache Software License 2.0'd, implementation of
@lemire's nearly division-less RNG.https://lemire.me/blog/2019/06/06/nearly-divisionless-random-integer-generation-on-various-systems/ …4 replies 35 retweets 71 likesShow this thread -
Where can I find details on the contest and what's the deadline?
1 reply 0 retweets 0 likes
It's at the bottom of the tweet thread :)
-
-
Whelp, I'm blind, sorry! Seems like a fun project. I'm not inherently a maths person so these kinds of challenges always excite me
0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.