Visual-based vs. Text-based programming languages
Visual-based vs. text-based programming languages?
We often get asked by people, “What are visual and text-based programming languages? What are the differences between them? Why do we as a company opt to teach kids a visual-based programming language like Scratch to begin with instead of starting them out on text-based ones?”
Why visual-based programming languages?
There are a number of reasons why we choose to start kids off with visual-based programming languages as opposed to text-based ones, but before we go into too much detail, let’s bring it right back and make sure that everyone is up to speed on the terminology that we’ll be using in this post.
First thing’s first, you’ll want to know that a program is a set of instructions that does something when you run it. This can be anything from a sudoku solver to a Hello World program (a classic program that programmers tend to write when starting out with a new language).
What’s a programming language?
A programming language is a formal language that is used to write all the different kinds of instructions that get a program to do what you want it to do. There are many, many different kinds of programming languages, each of which tends to have its own specific uses. The terminology and syntax vary from language to language, but the concept is really no different to our everyday languages.
Just like how “¿Qué hay de nuevo?” (Spanish), “Hur är läget?” (Swedish) and “What’s up?” (English) all carry the same basic meaning, so, too, do echo “Hello World!”; (PHP), print(“Hello world!”) (Python) and puts “Hello world!” (Ruby). Any one of these instructions would print the words “Hello world!” to the screen.
Despite being different languages, Spanish’s “¿Qué hay de nuevo?”, Swedish’s “Hur är läget” and English’s “What’s up?” all carry the same basic meaning.
Visual-based vs. text-based programming languages: What’s the difference?
The majority of programming languages are text-based, but there are also a great number of visual-based programming languages as well. Visual-based programming languages are ones that allow you to manipulate visual elements — e.g. drag and drop blocks — to make a program, as opposed to text-based programming languages, which have you write lines and lines of code to make a program. I’ll illustrate the general difference between them by showing you what a Hello World program looks like in Scratch (a visual-based programming language) and C++ (a text-based programming language).
An example of a Hello World program written in Scratch (left) and C++ (right).
You might be able to see already why we prefer to start kids off on visual-based programming languages like Scratch over the alternatives. Let’s just go over some of the main reasons:
For someone just getting started with programming, Scratch is a lot more readable. The blocks on Scratch tend to be much more straightforward, and it’s easy to guess what the blocks do, even if you’ve never touched or seen Scratch before in your life.
With the C++ example, it’s not easy to understand immediately what’s going on. You might look at the block of code and think to yourself, “What’s an iostream? What are all those funny symbols and what do they mean? What’s a main()?” It’s just not as straightforward as Scratch is.
Consider the above program written in both Scratch (left) and C++ (right)… which one is easier to read?
2. Ease of use
The way that you create programs in Scratch is by dragging together pre-existing blocks that carry pre-written instructions. So, for example, if you want to print the result of the equation 3 + 5, then you could achieve that by doing something like this in Scratch:
Block one: Displays the text “3 + 5 is…” for 2 seconds
Block two: Displays the result of the calculation 3 + 5 for 2 seconds
In C++, a program that does the same thing is more likely to look like this:
Not so simple, is it? It’s certainly not so easy to use for someone starting out with coding for the first time!
3. Technical knowledge
When you’re programming with text-based languages, it’s rather important to build up your knowledge of basic programming concepts first. Especially if you’re trying to teach yourself other programming languages, the pages that you’re learning from or the forums that you’re consulting tend to use programmer lingo — so if you don’t know what a loop, a Boolean or an array is, you might be in for a small world of misery.
For a slightly more complex programming language like C++, you should know about headers, libraries, functions, dynamic memory management, and much more before you get in too deep. But what do these words mean? How should I go about understanding these new and unfamiliar concepts? How do I explain these concepts to an 8-year-old child?
With Scratch, you’re not expected to know what half of those concepts are, let alone how to differentiate one type of block from another! For example, you might be having a grand ol’ time coding in Scratch, using Boolean blocks but not even realising it! (Fun fact: a Boolean is a truth value, i.e. a statement that evaluates to true or false; in Scratch, you can tell them apart from their triangular ends on their box.)
Some Boolean blocks in Scratch!
It’s easy to see that there’s much more typing involved in text-based programming languages. Just look at the C++ example of the Hello World program — it takes 129 characters to print two measly words to the screen!
With a lot of typing comes the potential for lots of errors, including:
- Typos: Laugh all you like — a single typo has the potential to break your entire program!
- Mixing up special characters: On the same note as typo, a single incorrect character can stop your program from working properly. Take care not to use “:” instead of “;”, or “<>” instead of “()”! There’s a big difference.
It’s worth noting that we are glossing over a few things here:
- Yes, Scratch is a great way for people to get started with coding if they haven’t had any prior experience, but not all visual-based programming languages are the same! Scratch just happens to be targeted at people who are getting started with coding.
- Yes, you can make some impressive things with Scratch, but it’s not a substitute for the things that most text-based languages can do. You’re not going to be able to make the next best composition software or the next social media platform using Scratch. Look at it as more of a stepping stone: it’s a great place for you to develop what’s really important — a solid programmer’s logic — without having to be in touch with all the excess technical knowledge, or worry about scrutinising every single like of code while you’re debugging, just to make sure that there are no typos in sight.
So why do we start newcomers off with Scratch?
We teach Scratch in our classes because it’s a great way to develop important skills associated with programming — like logic and debugging, for example — without having to be an expert on all the technical mumbo-jumbo, and without having to spend sixty years hunting down all the typos you made. It’s certainly not something you can use to write the next Sibelius or Facebook, but it’s a fantastic stepping stone into the wide and wonderful world of coding.
If you’re interested to see more contrasts between (Scratch) visual-based vs. text-based programming languages, check out this document that @CodeClubRik tweeted – http://bit.ly/2tfOyYv! It shows some Scratch blocks and their Python equivalents.
If you would like to join our online code clubs to learn about either visual programming or programming with Python, check out our free interactive online classes with our Australian-based tutors.
If you’re interested to find out more