Live data from Hacker News

The Software Developer's Sketchbook

prog21.dadgum.com

21–23 of 23 posts

Re: The Software Developer's Sketchbook

#21
post #13
post #12

For me, that is my ~/git/scratch repo (formerly ~/hg/scratch). I have a lot of experiments in there: different approaches to parsing; R/OCaml/Lua experiments; tests for interactions between Unix signals, processes, and threads; etc. One thing I've also found useful is: whenever you see a neat code snippet on Hacker News or a blog, download the code, and write a shell script to build and demo it. You don't even have t…

What do you mean by "write a shell script to build and demo it"? Pardon my ignorance.

I make a shell script to accompany all code; I basically think of it as an "executable README". A README or blog post often contains shell commands. So I just copy those into a script.

And more often than not I add my own tests and demos. Sometimes I write a main() program, if it's C. If it's JS, then add an HTML skeleton and a script that runs a web server to demo it (e.g. python -m SimleHTTPServer). If it's Python, install any deps necessary. And often you will want to run the same script with many parameters to fully demo it.

The idea is to basically prove to yourself that the code works, without necessarily having to understand everything about it. Then when you see it later, your brain knows you can go back to it. You won't feel lazy like "oh man I have to go back and find the web page I saw 3 months ago, download code, pore through instructions to figure out how to build it". That part is already done.

For example, here's a snippet I did when testing out cityhash. It's usually much messier/longer than this.

    run.sh:

    #!/bin/bash
    readonly CITY_SRC=~/src/cityhash-1.1.1
    download() {
      ...  ...
    }
    hello() {
      g++ -I$CITY_SRC -I$CITY_SRC/src -o hello $CITY_SRC/src/city.cc hello.cc
     ./hello "$@"
    }
    "$@"


    hello.cc:

    #include 
    #include   // strlen

    #include "city.h"

    int main(int argc, char** argv) {
      if (argc >= 2) {
        char* s = argv[1];
        unsigned u = CityHash32(s, strlen(s));
        printf("hash = %x\n", u);
        return 3;
      }
    }
Then I just check those two files into ~/git/scratch/cityhash. Then I can reproduce it on any computer with a couple short commands.

Re: The Software Developer's Sketchbook

#22
post #20

"Ideas are more important than code" -- Unknown Therefore, I'd rather have a sketchbook for ideas :)

Yes and no. Ideas solidify through code, and then form a solid basis for new ideas. If you never reduce an idea to code it becomes too hard to build one idea on top of another.

Re: The Software Developer's Sketchbook

#23
post #17
post #15

"To become the expert, you need more projects. They can be smaller, experimental, and even be isolated parts of a non-existent larger app." This is so true. A lot of the 'experienced' people I've met in the industry with 10 or 15 years behind them have done nothing but their jobs in that time to practice their art, and their 'experience' is therefore of such low quality that an exceptionally good junior with a few ho…

This is so laughable and a little typical of HN. I've worked with guys that have done nothing other than Spring and Hibernate for nearly a decade and they know those platforms inside and out. There's just no way someone junior with a few hobby projects are running rings around those guys in their areas. However, if you take something new, or something these guys haven't used, then yea.... rings could be run. Other th…

I dunno, I've experienced this a lot, although to be fair, with much larger areas of expertise than a particular product. I was thinking more about 'graphics', 'AI' or at the language level like 'C' or 'Java'.

I'll trust my experience over guesswork.

Post reply on HN