Programming, Coding, Programming Languages, What Languages to Learn, Writing Code, Writing Software, Coding in “C”, July 25, 2018
Thoughts * Coding is Communication - Steve Gibson on why he carefully comments code * If I write some code in Lua, and if I am careful, I might be able to share it between Codea and the Mac * Pythonista, I can write portable Python code that will execute the same on Mac, Linux, Windows, IOS and Android * Small Subroutines! Very small. * Some of my best programs have used very small subroutines with good default rules. * Some people say that 2 lines are too much in a subroutine. * Its hard to verify a function that is 20 lines, let alone 100. Small 5 to 10 line programs. * Sometimes, you do need to write something as one big “thought”, but then you should go back and break it into little pieces. * "Our Documentation is like your Documentation, except that ours compiles." -- Dan Sabo * This makes one authoritative source for documentation. * Sometimes when the problems seems overwhelmingly difficult the solution is to attack it a very small chunk at a time. * Dan's Theory on how to make re-usable software - "Find some software and re-use it." * Commenting code should not be the focus, making the code readable, understandable, is the thing I need to do. * Do more with less code and in less time * Good code seems to be the union of minimizing the number of lines in a subroutine and minimizing the number of API calls. * When you see big loops and bit flags, that should be a warning * Programming is like exercise, you have to do it everyday to be good at it. * Solving problems in programming * Often you have to get rid of the problems you know about and then see what is left * I don’t think many are going to agree with me, but I think I write my best code when I use the artistic method. It’s like carving a statue, you step back and look at it and think, I don’t like this part, and you work on that for a while and step back and look at it again. * I do like the Agile Manifesto * I think the Agile Manifesto conflicts with Scrum * I still enjoy coding * Attention to detail * I want to write as much as I can in a safe stateless way * I want to write as much as I can in a thread safe way
Languages to Learn * I need to make a IOS app * I think Python Tkinter is the right thing to learn * Python, PythonQt is portable across Windows, Linux and Mac Python can be Byte Compiled into a standalone executable * Python Tkinter comes with most of the default installations, Linux, Mac, Raspberry Pi * Haskell • Lua
Rob Pike's 5 Rules of Programming
* Rule 1. You can't tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don't try to second guess and put in a speed hack until you've proven that's where the bottleneck is. * Rule 2. Measure. Don't tune for speed until you've measured, and even then don't unless one part of the code overwhelms the rest. * Rule 3. Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.) * Rule 4. Fancy algorithms are buggier than simple ones, and they're much harder to implement. Use simple algorithms as well as simple data structures. * Rule 5. Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming. Pike's rules 1 and 2 restate Tony Hoare's famous maxim "Premature optimization is the root of all evil." Ken Thompson rephrased Pike's rules 3 and 4 as "When in doubt, use brute force.". Rules 3 and 4 are instances of the design philosophy KISS. Rule 5 was previously stated by Fred Brooks in The Mythical Man-Month. Rule 5 is often shortened to "write stupid code that uses smart objects”.
* A theme related to my "When you delete code you are doing God's work" meme. And Dan's zeroth law of writing reusable code. * If you want reusable code, find some code and reuse it.
Might quibble in a few places but he has a lot of good nuggets that I plan to steal.