Intro-to-Programming Outline
2012-12-23
This is a miscellaneous collection of notes about teaching programming to non-programmers.
Existing Resources
The first link is well-regarded, despite its intimidating title.
Introduction
- Computers: phones, netbooks, tablets, microwaves!
Building blocks
- Variables
- Loops
- Conditionals
- Math
- Functions
Variables
Loops
- For-each
- While
- C-style for:
for (i = 0; i < 5; i++) {}
- Do-while (aside)
Conditional expressions
- If
- Switch-case
Data types
int
vs.float
vs.char
- Arrays, lists, and strings
- C: terminate with
\0
, instead of passing around a count - Character sets and encodings: ASCII, Unicode
Bits
- 0 and 1
- 32-bit and 64-bit computers (architectures)
- Year 2038 problem, vs. Y2K bug
Languages
- Natural languages vs. formal languages
- Aside: Turing completeness, and equivalent power of expression
- Aside: Noam Chomsky
- Machine code, vs. assembly, vs. higher-level languages
- Tradeoffs of different languages
- Larry Wall's State of the Onion: some things are convenient to say in a language
- "Scripting languages" vs. "programming languages"
- "Coding" vs. "programming"
- Web vs. desktop vs. embedded: languages and programming (tradeoffs)
- Standard libraries: "batteries included"
- Compilers and interpreters: translation between languages
Don't Repeat Yourself
- Functions, vs. copy-pasting code
- Classes: associate functions with structured data and/or state
- Syntactic sugar
Security
- SSL and HTTPS
- Crypto: RSA encryption and big prime numbers
-
Vulnerabilities and exploits
- Debian OpenSSL + uninitialized memory (aside: open source security)
- 0-days, and responsible disclosure
- What is a bug?
- Web browsers have limited filesystem access
Portability
- Virtual machines
- Operating systems
- Assembly languages, architectures, and compilers
- The web: abstract away the OS, but variation between browsers
Standards
- Formal vs. informal conventions
- ANSI, ISO
- Language definitions: HTML, Python
- Separation of "language specification" from "language implementation".
- CPython2 and PyPy; Python 3; Jython; etc.
Servers
- What is a server?
- World wide web: HTTP requests/responses as plain text
- Networks and the internet
- DNS: the numbers underneath the internet
- Protocols: HTTP, SMTP, FTP, XMPP, etc.
Graphics
- GUIs and toolkits
- Color encodings; e.g., RGBA
- Pixels: drawing to the screen
- GPUs: 3D graphics, scientific computing, password cracking
Text vs. binary
- File formats, magic numbers
- .txt, .doc, .docx, .exe, XML, JSON, PDF, …
- Comparison: Unix vs. Windows
- Linux kernel binary blobs (e.g., wireless drivers)
Data interchange, file formats
- Binary compatibility
- Windows vs. Linux vs. Mac
- 32-bit vs. 64-bit for a single OS
Coding style
- Unix Philosophy: combine small, simple tools (pipes and input/output)
- Monolithic, universal: Windows registry
Databases
- What is a database?
- Data integrity, normalization, foreign keys (Don't repeat yourself)
- Relational, document, and graph databases: model your data
- Flat file databases
- Index to avoid linear searches: data structures
- Store data sets that are too big for RAM
- JSTOR
- Database servers like MySQL and SQL Server: SQL standard and implementations
Code quality
- Readibility
- Maintainability
- Refactoring vs. rewriting
- Technical Debt
Scientific computing
- Emphasis on get-things-done scripts, vs. "30-year enterprise"
- Python, C, C++, Perl, shell, Java?
Multi-tasking computers
- Multiple cores and processors
- Threading and multiprocessing
- Context switching for CPUs
- Vector and array operations: fast, optimized in hardware
Different kinds of memory
- RAM is faster, but more expensive, than hard disks
- Flash drives vs. hard disks
- Storing and representing objects that are too big to fit into RAM (or HD)
Algorithms, Data Structures
- The math part of computer science
- Real consequences for code: reduce CPU time or memory usage
- Big-O notation
- Often used heavily in interviews for developer jobs
Computational complexity => actual performance
- Premature optimization, and diminishing returns
- "Developer time" is a resource like CPU time, RAM, and hard drive space
- Like Costco's obsessive optimization of toilet paper production costs.
- Right tool for the job: when you have an optimization hammer, everything looks like a nail.
How to learn on your own
- Know how to ask search engines like Google
- site:google.com
- this -that
- "Once upon a time"
- Stack Overflow
- Choose wisely when entering a rabbit hole
Piracy and privacy
- Cute title, don't remember what my point was going to be
The Cloud: buzzwords
Ads pay for free services like Google and Facebook
- Targeted advertisements
- Tracking cookies
- Linking user profile information across services: Google Drive, Google Search, Gmail?
Abstractions
- Easy to understand, and to use
- Hide details that people don't want to know
- Perl saying: make easy things easy, and hard things possible.
Impedance mismatch; i.e., square peg in a round hole
- MATLAB for GUIs
- Strings in Fortran?
iPhone and Android apps, and app development
Making your own website
- Hosting
- HTML/CSS files vs. WYSIWYG editors
LaTeX: nice-looking typography
- Resumes
- Scientific papers
Domain-Specific Languages: slang, jargon, and concise representations
Embedded languages: Microsoft Excel's VBA (Visual Basic for Applications)
Filesystems
- Windows C drive, D drive
- Unix mount points
- Directory structure, and filesystem hierarchy/tree
- NTFS, FAT, ext3, ext4, ZFS
Computer literacy
- opening files
- Command line arguments
- Running out of RAM or hard drive space; "pegging" CPU
- Task manager
- Monitor resource usage
- Kill processes
- Start/stop services
- Windows fundamentals
- Web/browser fundamentals
- Email: clients and servers
- Microsoft Word and Excel
- The basics: cut-copy-paste, spellcheck, test formatting
- Intermediate: outlines, keyboard shortcuts
- Networking: connect to wifi
Intellectual property and software patents: technical and legal issues
- "Downloading"
- Torrenting
- MegaUpload
- Napster and Limewire
OS services, daemons, and local servers
Software, hardware, firmware
Back up data to external media: DropBox, Google Drive?
User permissions
- read/write/execute
- administrator privileges
- authentication vs. authorization
- Unix vs. Windows
Multi-user vs. multi-process
Automation: re-run experiments "for free" (simulations)
- Double-check complicated computations with one click
Separation of concerns
- Model-view-controller
- Separate content from presentation (HTML/CSS, vs. JS)
Programming paradigms
- Procedural programming
- Linear instructions (recipes)
- Step 1. Do this; Step 2. Do that; …
- Object-oriented programming: associate functions with data, and call them "methods"
- Functional programming: combine little pieces together - lambda calculus?
Automated tests: unit, integration, usability tests
Learning and using legacy tools, and legacy code
Web browsers
-
HTTP status codes: 200, 301, 302, 400, 401, 403, 404, 500, etc.
- Magic numbers, conventions, and abstraction
- What information does your HTTP client send?
- User Agent string
- HTTP Cookies
- Your IP iddress, and MAC address on smartphones?
- Browser cache: save bandwidth, HTTP 304
Routers: packet sniffing, wireless passphrases, MAC filters
The network stack
- Wires and switches
- TCP/IP
- WWW, compare web to internet
- DNS
- HTTP text requests/responses
- Servers
- Browsers as specialized HTTP clients
Operating systems, kernels, and userland
- Unix, UNIX, Linux, GNU/Linux
- Windows, Mac OS X, BSD, Solaris
- System calls
- Funny anecdote: Unix
creat
What happens when you press the "Enter" key?
- Keycodes
- Keyboard shortcuts
- Different things seem to happen at a terminal prompt and in an HTML text field
Cracking
- OWASP Top 10
- XSS, CSRF
- Database injection
- Buffer overflows
- Metasploit; john the ripper; LOIC; MAC spoofing
- Anonymous and Lulzsec
- War games
- Arms race: address-space randomization
- White, gray, and black hats
- 0-days and money
Security updates and the software lifecycle
Sharing software
- Code: FTP, GitHub, Bitbucket, and Sourceforge
- Pre-packaged: package managers, "app stores"
Version control systems
- Diffs and patches, vs. full copies
- Microsoft Word's "track changes"
- CVS, SVN
- git, mercurial
Software developer literacy
- Understand the historical context in which a decision was made
- Algorithms vs. heuristics, for humans and computers
- Traditional approach to Intro CS: teach a variety of sorting algorithms
- Most modern languages give you at least one by default
- I'd rather focus on fundamental low-level constructs, and general principles
Licensing
- Free (as in freedom/beer): GPL, BSD/MIT/etc.
- Proprietary code
- Creative commons, for content
- Anecdote: copyrighting
/bin/true
(an empty script)
Miscellaneous
- Windows shortcut anecdote: .lnk challenge