Statements
Introduction
A statement is the explicit command, the clear instruction that you pass to the computer to execute without hesitation. It is a line of code that commands the computer to perform a specific task, like saying in natural language: "Open the door," or "Write this text," or "Repeat this action ten times."
Simple statements are complete in themselves and need nothing else, like assignment statements that grant variables their values, function calls, or control flow commands in the program. As for compound statements, they are those that embrace other statements within them, like loop and conditional statements that organize the program's flow and direct its steps.
The fundamental difference between a statement and an expression is that a statement executes an action and doesn't necessarily produce a value, while an expression is evaluated and always produces a value.
A statement changes the program's state and creates an effect, while an expression computes and reports. A statement may contain expressions within it, but an expression does not contain statements - the statement is the commander who issues orders, and the expression is the advisor who provides calculations.
These documents are currently incomplete. If you're interested, please visit these documents on Github.
Conclusion
Statements are your commands to the computer, and the instructions that shape your program's behavior. From the simplest assignment to a variable, to the most complex nested control logic, every statement contributes to building the complete functionality of your program.
Understanding statements, how to organize them, and use them effectively is the foundation for writing clear, maintainable, and reliable programs. Use them wisely, organize your logic clearly, handle errors responsibly, and let every statement express your clear and explicit intent.
"A good program is not just one that works, but one that reads easily and is understood clearly"