Introduction to Programming


Introduction to Programming

Hope
Welcome back. This episode introduces chapter one and gives us a first taste of programming in Visual Basic. We’re going to define programming, look at why computers are different from many other machines, and then connect programming languages, object-oriented programming, development tools, and the programmer’s workflow.

Anna
Let’s begin with the big question: what makes a computer special as a machine?

Hope
Most machines are designed to perform one main task. An old-fashioned car engine takes in fuel, ignites it, and uses the resulting energy to move pistons and power the car. A sewing machine moves a needle and directs fabric according to its settings. Once those settings are selected, its job is still essentially sewing.

Anna
A computer is different because it can receive instructions for many different tasks. The same computer might browse the web, open Canvas, stream a video, or run a game. When it streams a video, for example, it requests the video, receives data packets, and sends the visual and audio information to your screen and speakers.

Hope
And computers are not limited to laptops and desktops. Smartphones are computers because installing apps gives them new functionality. Modern cars, sewing machines, and even pipe organs can contain computers that control their operations.

Anna
Why put a computer inside a device that may only have one purpose?

Hope
Sometimes it is simpler to place a computer in a device and give it instructions than to build a complicated electronic or electromechanical system for every function. So computers are everywhere, partly because their flexibility makes them useful even when they control a specialized device.

Anna
That flexibility leads directly to programming. Programming is the act of creating a set of instructions that gives a computer new functionality or teaches it how to perform a task. Installing a web browser, a Canvas app, or another application works because someone programmed instructions that the computer can follow.

Hope
A program is the set of instructions itself. When a computer runs a program, it follows those instructions to complete a task. Firefox, Chrome, File Explorer, a phone app, and a video game are all examples of programs. Software is a broad term that includes programs, while the word program often refers more specifically to a particular set of instructions or application.

Anna
Programs can also involve user interaction. On a scheduling website, for instance, you might type information into a form and click buttons. The browser reads what you entered and which buttons you clicked, then passes that information to the web server when you submit the form.

Hope
User interaction will be especially important in this class because the Visual Basic programs you create will focus heavily on allowing users to interact with them. And the person who creates these instructions is the programmer: a programmer writes a program so a computer can perform a task.

Anna
But computers do not directly read ordinary human language. At a basic level, they work with electrical signals that are on or off. Those two states are represented as binary digits, and groups of binary digits can represent numbers and other information.

Hope
Because computers understand binary, early programming required instructions very close to binary. Assembly languages improved that process by allowing programmers to write somewhat more human-readable text, which could then be translated directly into binary instructions for the computer.

Anna
There is one major advantage to working so close to the computer. If you write every instruction individually, you know exactly what the computer is doing and can optimize the program very precisely. Assembly is still used when a problem requires very specific optimization.

Hope
The disadvantages are substantial, though. Writing low-level instructions takes a lot of code even for something that seems simple, such as displaying an image, creating a window, or determining whether a mouse click happened in a meaningful location. The large amount of detail makes programs difficult to write and makes mistakes harder to find. It can also lead to physical strain such as hand or eye strain.

Anna
That is where higher-level programming languages help. They are designed to be more human-readable and use familiar words and structures. Instead of writing hundreds of low-level instructions, a programmer may write one easier command that represents many binary instructions.

Hope
The programming language processes what the programmer wrote and translates it into the appropriate binary commands. It is not as simple as writing an ordinary sentence like, ‘When this button is clicked, show a picture,’ but it is much easier to remember and use than binary or assembly. That convenience has helped programmers create complicated software such as web browsers and internet-based programs.

Anna
Some programming languages you may hear about are C, C++, Java, JavaScript, Node.js, Python, and Visual Basic. In general, the programmer writes instructions in one of these human-readable languages, and those instructions eventually become binary instructions that the computer can run.

Hope
There are different ways that translation can happen. A compiler can translate the code into an executable program before it runs. An interpreter can read the code as it runs and perform the instructions without completing the same kind of translation ahead of time. Either way, the computer ultimately runs binary instructions.

Anna
The chapter also introduces programming language paradigms. A paradigm is a style or way of thinking about how a programming language can organize solutions to tasks. One important paradigm for Visual Basic is object-oriented programming.

Hope
In object-oriented programming, we think of a program as a collection of objects that interact. Instead of only writing a long sequence such as ‘step one, step two, step three,’ we define objects and tell them how to work with one another. An application might contain button objects, and the application can position a button while the button can respond when a user clicks it.

Anna
So what counts as an object in a program?

Hope
An object is something that can be seen, used, or otherwise represented within the program. Objects have properties, they can perform actions or functions based on their instructions, and they can interact with other objects. Usually, actions in an object-oriented program are associated with an object performing them.

Anna
And where does a class fit into that picture?

Hope
A class is a pattern used to create objects. When programming in an object-oriented language, you define the properties that objects of a class will have, what those objects can do, and how other objects can interact with them. An individual object created from that pattern is called an instance of the class.

Anna
So if the class is a blueprint or pattern, the object is one actual thing created from it. Creating that object is called instantiating it. In Visual Basic, you might ask the language to create an object using the pattern defined by a particular class.

Hope
A teacher class could define that every teacher has a name and a list of classes they teach. A student class could define a name and a list of classes they take. An assignment class could represent an assignment and its relevant information. These are examples of classes, and the individual teachers, students, classes, and assignments created from them are objects or instances.

Anna
The example becomes especially useful when we connect the objects. A teacher object might have the CBIS 112 class in its list of courses. The CBIS 112 class can also have that teacher in its teacher property, along with a list of students and assignments such as a chapter one programming assignment or a quiz.

Hope
Exactly. When the teacher grades an assignment, the teacher interacts with a particular class, finds the appropriate assignment in that class’s list, and works with the submitted student information. Students also interact with the class object and its assignment objects when they complete their work. That network of objects interacting is the basic mindset of object-oriented programming.

Anna
Now let’s move from the ideas behind programs to the tools used to create them. An integrated development environment, or IDE, is a program that lets you create, run, test, and build a final application.

Hope
Before IDEs, programmers often wrote code in a basic text editor, manually ran a compiler or interpreter, and used separate testing tools to locate problems. An IDE brings those activities together in one piece of software, making development and testing more convenient. Visual Basic uses an IDE to support the process of building programs.

Anna
Another important term is GUI, which stands for graphical user interface. A GUI lets users see and interact with a program through a monitor, mouse, keyboard, touchscreen, or other input devices.

Hope
Your phone and laptop both use GUIs. You tap icons on a phone or click applications with a mouse on a laptop. A GUI is part of a program: the programmer writes instructions that create the visual elements and define how users can interact with them. Visual Basic makes creating GUIs relatively easy.

Anna
An application is typically a program with a graphical user interface. It has visible elements such as icons, images, and clickable controls, unlike a program that runs entirely through text in a terminal or shell.

Hope
Let’s connect these definitions to the programmer’s job. A programmer typically creates computer solutions for problems faced by a company or its users. That might mean building a tool for one company’s information system or workflow, or working with a team to create software that many other companies can use.

Anna
And the goal is not just to solve one isolated example. A programmer needs to create a general solution that handles all possible instances of the problem, such as different numerical values or different people with different details.

Hope
That is why programming is a form of problem solving. The programmer has to turn a broad need into instructions and a system that can handle many situations, rather than hard-coding an answer for only one specific case.

Anna
What does the programming workflow look like in practice?

Hope
First, the programmer meets with the people who will use the program. Those users need a voice in describing the problem, identifying what is missing, and explaining what the software should do. The programmer needs to understand the problem completely before deciding on a solution.

Anna
The next step is planning the solution before writing code. You identify the tasks the program must perform, break the problem into parts, and determine how each task should be solved. Starting immediately without a plan is sometimes called ‘cowboy coding,’ and it can make it easy to lose direction.

Hope
Once the design is understood, the programmer codes the program and tests it. Testing checks that the program works correctly and that it meets the users’ needs. Internal testing, often called alpha testing, focuses on whether the program functions properly and avoids crashes. Beta testing involves users and checks whether the program is actually useful and satisfying their needs.

Anna
The process may repeat depending on the development approach. In a Software Development Life Cycle approach, the stages may be handled with minimal repetition. In Agile, the team works in short bursts, tests what was created, gathers user feedback, and repeats the cycle.

Hope
The best approach depends on the people and workflow involved. Users may not always be available to test continuously, but the overall goal remains the same: create a solution, test it, make sure users approve of it, and deliver the finished product.

Anna
So the central idea of the chapter is that a computer is a device that can perform tasks based on instructions, without every capability having to be physically built into the computer’s original design.

Hope
And programming is what allows us to provide those instructions and give the computer new functionality. Without programming, we would be limited to the applications, operating system, and other programs that someone else had already created. By learning to program, we begin turning the computer into our own tool for solving problems.

Anna
That is also the purpose of learning Visual Basic in this class: not merely to memorize commands, but to learn how to build programs, create graphical interfaces, respond to user interaction, and develop solutions of our own.

Hope
Exactly. We’ve covered why computers are flexible machines, how programming and programs are defined, why programming languages translate human-readable instructions into binary, how object-oriented programming uses classes and objects, what IDEs and GUIs do, and how programmers move from understanding a problem to planning, coding, testing, and delivering a solution.

Ask anything
We've read this whole study set, so questions about it get the best answers.