Overview
This lecture introduces the basics of computer programming, discusses programming languages and interfaces, and outlines a general approach for writing programs.
What is Programming?
- Programming means preparing a list of commands for a computer.
- Computer languages include BASIC, FORTRAN, COBOL, dBASE, SQL, Java, PowerShell, Alice, and mBlock.
- Languages have evolved in generations: early (e.g., BASIC), mid (e.g., dBASE), modern (e.g., Java), and block-based (e.g., Scratch, mBlock).
Types of Programming Languages & Interfaces
- Most languages use text editors for writing code except block-based languages like Alice and mBlock.
- Block-based languages use visual code blocks for programming logic.
- Programming models include procedural (recipe-like), object-oriented (model cyberspace objects), and set-based (query data sets).
- mBlock is a procedural, block-based language derived from Scratch (developed by MIT).
Programming Process
- Four main stages: Plan, Prepare, Execute, Assess.
- Plan: Understand requirements and identify unknowns ("new tricks") needed for the program.
- Prepare: Research new concepts and save your program frequently.
- Execute: Write small code segments and test after each step ("baby steps").
- Assess: Review if all requirements are met and test the final program.
Programming Considerations
- Computers are literal; programs must give explicit, unambiguous instructions.
- Forgetting outputs or steps can cause a program to run incorrectly or incompletely.
- Managing frustration is an important programming skill—persistence is key.
- Practical tip: snacks and energy drinks can help during long programming sessions.
Example Scenario
- A sample task: Write a program for a robot to change light colors and make noise for a CEO demonstration.
Key Terms & Definitions
- Programming — Writing a sequence of commands for a computer to follow.
- Procedural Language — Type of language where the program follows step-by-step instructions (e.g., mBlock).
- Object-Oriented Language — Language based on building interacting objects (e.g., Java, Alice).
- Block-Based Language — Programming with draggable code blocks (e.g., Scratch, mBlock).
- IDE (Integrated Development Environment) — Software for writing and testing code (e.g., mBlock interface).
Action Items / Next Steps
- Explore the mBlock IDE interface.
- Prepare for a step-by-step walkthrough of creating a robot program as described in the sample scenario.