Linked handout: 1. Motivation

IRF server room Photo: Daniel Kastinen/IRF

Why this course?

Why this course?

First some distinctions

  • Programming

    using a language to solve "problems"

  • Software development

    choosing what "problems" to solve and how to solve them for a greater goal

For example: Build a calculator

  • Problem 1: capture user input
  • Problem 2: parse input
  • Problem 3: perform computations
  • Problem 4: display/store result

This course strikes a ~70/30% balance between software development and programming

Why this course?

The classic: fast inverse square root implementation from Quake III Arena

                    
float Q_rsqrt( float number )
{
    long i;
    float x2, y;
    const float threehalfs = 1.5F;

    x2 = number * 0.5F;
    y  = number;
    i  = * ( long * ) &y;                       // evil floating point bit level hacking
    i  = 0x5f3759df - ( i >> 1 );               // what the f***?
    y  = * ( float * ) &i;
    y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//  y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed

    return y;
}
                    
                

Being able to do the above takes someone good at programming

Realizing that this was needed and creating the conditions where it could be done
takes someone good at software development

Why this course?

The classic: fast inverse square root implementation from Quake III Arena

                    
float Q_rsqrt( float number )
{
    long i;
    float x2, y;
    const float threehalfs = 1.5F;

    x2 = number * 0.5F;
    y  = number;
    i  = * ( long * ) &y;                       // evil floating point bit level hacking
    i  = 0x5f3759df - ( i >> 1 );               // what the f***?
    y  = * ( float * ) &i;
    y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//  y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed

    return y;
}
                    
                
  1. Alias the argument $x$ to an integer as a way to compute an approximation of the binary logarithm $\log _{2}(x)$
  2. Use this approximation to compute an approximation of $\log _{2}\left({\frac {1}{\sqrt {x}}}\right)=-{\frac {1}{2}}\log _{2}(x)$
  3. Alias back to a float, as a way to compute an approximation of the base-2 exponential
  4. Refine the approximation using a single iteration of Newton's method
    (finding root to $ \frac{1}{y^2} - x = 0 $).

Why this course?

      Ron Evans on The Changelog podcast, 2024-05-03

      We're cognition athletes. Don't athletes usually get a trainer? Instead we get a coffee and a donut and the product needs to ship next week.

      replace: product -> data/paper/simulation/...

      So here is a course and some training!

      Why this course?

          Lars Wirzenius - "40 years of programming"

          Interesting and significant software is beyond the capacity of any one person to build alone in a reasonable time frame. This means that the fundamental, crucial, core skills in building software are communication and collaboration.

          Why this course?

          • Learning collaboration
          • Practicing communication

            Lars Wirzenius - "40 years of programming"

            Even in the projects where I'm the only person, there are at least three people involved: past me, present me, and future me. Past me is a lazy and careless slob who always leaves a mess. Present me does superb work, but has to cope with all the stupid stuff done by past me, and needs to placate future me. Future me is an egotistic and opinionated snob for whom nothing is ever good enough.

            Why this course?

            • Learning collaboration
            • Practicing communication
            • Improving your past, present, and future self

              Monya Baker - "1,500 scientists lift the lid on reproducibility"

              More than 70% of researchers have tried and failed to reproduce another scientist's experiments, and more than half have failed to reproduce their own experiments.

              Why this course?

              • Learning collaboration
              • Practicing communication
              • Improving your past, present, and future self
              • Research ethics and reproducibility

                Just based on what was already said

                Why this course?

                • Learning collaboration
                • Practicing communication
                • Improving your past, present, and future self
                • Research ethics and reproducibility
                • Less useless re-inventing the wheel
                • Longevity and maintainability

                Would you rather contribute to

                or

                Why this course?

                • Learning collaboration
                • Practicing communication
                • Improving your past, present, and future self
                • Research ethics and reproducibility
                • Less useless re-inventing the wheel
                • Longevity and maintainability
                • Opens up for collaboration

                Why this course?

                • Learning collaboration
                • Practicing communication
                • Improving your past, present, and future self
                • Research ethics and reproducibility
                • Less useless re-inventing the wheel
                • Longevity and maintainability
                • Opens up for collaboration
                • Implmentation speed and reliability

                Be able to tackle any problem

                Hone your craft. Be an expert at your tools. Train and practice. "Yeah I could do that"

                Why this course?

                This is a very fine line to walk

                  Left side

                • You never get anything done
                • Projects seem too big to even start
                • Nobody benefits from your code

                Why this course?

                This is a very fine line to walk

                  Right side

                • Nobody, including you, knows if or how your code works
                • You are slowed down by your own code
                • Nobody benefits from your code

                Why this course?

                This is a very fine line to walk

                  Middle

                • You refine the critical parts - they can be trusted and maintained
                • You are accelerated by your code
                • Other benefit from your code

                Know thy self

                • Who are you writing code for?
                • Why are you writing the code?
                • When will the code be used?
                • What will it be used for?
                • Testing if a package does what you want - Be as sloppy as you like
                • One-off plotting script for paper - Version-control (VC) but otherwise meh
                • Simulation for paper (using library) - VC, input/output design, setup/dependency management
                • Analysis pipeline (using library) - VC, thorough output design, setup/dependency management, modular functionality, logging, performance
                • Simulation library - VC, packaging, CI, testing, modularity, documentation, readability, maintainability, APIs, performance, footprint
                • Real-time operational system - VC, CI/CD, testing, robustness, reliability, maintainability, documentation, logging, performance, control interface
                Some of the software I have written
                Project Descritpion
                sorts "Space Object Radar Tracking Simulator library"
                hardtarget "Radar hard target processing package"
                rain "ReseArch Infrastructure Network"
                pyorb "Kepler orbits library"
                pyant "Radar gain patterns library"
                runningman "Runtime Manager"
                dasst "Small-body dynamics simulations library"
                metecho "Radar Meteor Head Echo Analysis library and pipeline"
                ablate "Ablation model library"
                resordan "Space object data analysis library"
                allsky7station "Meteor camera station software"
                rebound-player "Simulation visualization app"
                MU radar pipeline "Meteor data pipeline"
                EISCAT radar pipeline "Space debris data pipeline"

                Some notes on learning

                • Write the code yourself - no gen-AI for this course
                  (see e.g. AI is Creating a Generation of Illiterate Programmers)
                • Don't be afraid of writing a lot of code thats gonna get thrown away
                  (Everyone who writes good code does so because they wrote bad code first)
                • Do the homework assignments, they are there to teach
                • If you get stuck - discuss with someone, e.g. classmates or me

                Homework

                Click the link above to get to the handout