CSC103 How Computers Work

Notes 9


Last Update:

Programming Languages

diagram

  1. History of Programming Languages
  2. Programming Language components
  3. Syntax: grammar for parsing
  4. Semantics: the meaning/function/action of each "statement" (sentence)
  5. Examples:
  6. Compiling/Interpretting: source code → byte code → machine language
  7. byte code: generic machine-like language
  8. Example:

    // Bytecode stream: 03 3b 84 00 01 1a 05 68 3b a7 ff f9
    // Disassembly:
    iconst_0 // 03
    istore_0 // 3b
    iinc 0, 1 // 84 00 01
    iload_0 // 1a
    iconst_2 // 05
    imul // 68
    istore_0 // 3b
    goto -7 // a7 ff f9

  9. Machine code, in machine language (CPU specific)
  10. Example:

    op | rs | rt | rd |shamt| funct]
    0 1 2 6 0 32 decimal
    000000 00001 00010 00110 00000 100000 binary

  11. Logo: Turtle graphics
  12. Scratch
  13. scratch
  14. Free download, easy install, works on all platforms
  15. Interface: Blocks Palette, Scripts area, Stage
  16. Stage: 480 x 360, origin (0,0) in middle
  17. Program the action of sprites
  18. We'll just use one, and draw pictures with it.
  19. Right-click on any block to get explanation
  20. Rounded blocks can fit in rounded positions, to, e.g., replace a number
  21. Comments added by right-click in script area
  22. Blocks: Motion, Pen, Control, Variables
  23. Motion
  24. Pen
  25. Control
  26. Directions
  27. Draw a square
  28. Draw a spiral


Return to CSC103 Class Homepage: