Beginning Programming All-in-One For Dummies. Wallace Wang. Читать онлайн. Newlib. NEWLIB.NET

Автор: Wallace Wang
Издательство: John Wiley & Sons Limited
Серия:
Жанр произведения: Программы
Год издания: 0
isbn: 9781119884422
Скачать книгу

      FIGURE 3-1: Programming in Scratch means connecting visual building blocks together.

      Just keep in mind that Scratch is meant to teach programming principles, but it doesn’t let you create commercial applications. When you learn C or any C-derived language like C#, Python, or Swift, you’re forced to learn programming principles and language syntax at the same time. When you learn Scratch, you can just focus on learning programming principles so you’re learning one thing at a time.

      When you feel ready, you can take your knowledge of programming principles and then tackle the second problem of learning a particular language syntax. So, learning programming through Scratch is a two-step process, while learning programming through a language like C is a massive, and possibly overwhelming, single-step process.

      Programming robots with LEGO Mindstorms

      Kids love building things with LEGO building blocks, so to encourage kids to build actual working robots, LEGO released a LEGO robot-building kit called Mindstorms. Not only can you build a working robot with LEGO building blocks, but you can also program the robot using the Mindstorms programming language.

Snapshot of LEGO Mindstorms programming connects visual building blocks together to control a working robot.

      FIGURE 3-2: LEGO Mindstorms programming connects visual building blocks together to control a working robot.

      By using LEGO Mindstorms, anyone can figure out both programming skills and robot-making skills. Unlike other programming languages, LEGO Mindstorms lets you see your working program in action as a walking, rolling, or crawling LEGO robot.

      Learning object-oriented programming with Alice

      Nearly all modern programming languages support object-oriented programming. Unfortunately, figuring out object-oriented programming can be difficult, especially for beginners who already have enough trouble just figuring out how to program a computer.

Snapshot of an Alice program creates an animated character onscreen and moves it around.

      FIGURE 3-3: An Alice program creates an animated character onscreen and moves it around.

      When you write an Alice program, your commands create an animated character onscreen. Then you need to write additional commands to tell that animated character how to move to create a simple story. In the process of telling the animated character how to move, you wind up discovering both how to program and how to use object-oriented principles, while having fun in the process.

      Like most instructional programming languages, Alice programming uses plain English commands, like move forward or play sound. By using simple commands, Alice lets you focus on understanding the principles of object-oriented programming without getting bogged down in understanding the peculiar syntax of a specific programming language.

      Programming a killer robot

Snapshot of using a battling robot to study programming can make programming more exciting.

      FIGURE 3-4: Using a battling robot to study programming can make programming more exciting.

      After you finish your program, you can see the results by watching your robot battle another robot in a gladiator-style battle. Write a “good” program, and your robot can defeat another robot. Write a “bad” program, and your robot gets blasted into chunks of (virtual) charred metal.

Program Language Used Where to Find It
C++ Robots C++ www.gamerz.net/c++robots
Crobots C https://crobots.deepthought.it
Robocode Java https://robocode.sourceforge.io

      Whether you learn about programming using a simpler language or jump right in and start with C, you'll eventually need to learn one of the more popular programming languages based on C. This family of related languages is known as the curly-bracket language family.

      The curly-bracket language family gets its name because all the languages use curly brackets to define the start and end of a block of commands, like this:

       #include <stdio.h>void main(){ printf("Notice how the curly brackets\n"); printf("identify the beginning and end\n"); printf("of your commands?\n");}

      

Rather than use curly brackets, programming languages like Ada or Pascal use descriptive