Coding For Kids
Beginners Guide with Fun and Easy
Activities to Learn Coding Step by
Step
Author
Simon Weber
© Copyright 2019 - All rights reserved.
The content contained within this book may not be reproduced, duplicated or
transmitted without direct written permission from the author or the
publisher.
Under no circumstances will any blame or legal responsibility be held against
the publisher, or author, for any damages, reparation, or monetary loss due to
the information contained within this book, either directly or indirectly.
Legal Notice:
This book is copyright protected. It is only for personal use. You cannot
amend, distribute, sell, use, quote or paraphrase any part, or the content
within this book, without the consent of the author or publisher.
Disclaimer Notice:
Please note the information contained within this document is for educational
and entertainment purposes only. All effort has been executed to present
accurate, up to date, reliable, complete information. No warranties of any
kind are declared or implied. Readers acknowledge that the author is not
engaging in the rendering of legal, financial, medical or professional advice.
The content within this book has been derived from various sources. Please
consult a licensed professional before attempting any techniques outlined in
this book.
By reading this document, the reader agrees that under no circumstances is
the author responsible for any losses, direct or indirect, that are incurred as a
result of the use of the information contained within this document,
including, but not limited to, errors, omissions, or inaccuracies.
Table of Contents
Introduction
Chapter 1: What is Programming?
Syntax - What is it?
Why is syntax so important in programming?
Where do we start?
Chapter 2: The Basics of Coding
Python: Just like normal speech
Ruby: Trust me, it is self-explanatory
Java: This is where the fun begins
Chapter 3: Let’s Start Coding
Video games
A Calendar
A clock
Chapter 4: Think Outside the Box
Use logic
Best way to tackle a problem
Asking for help: It is okay!
Chapter 5: Coding Part 2
A phone book
A Quiz game
A database of all your favorite movies
Chapter 6: Your Future
What's next for you?
Coding as a career
Resources for programmers
Conclusion
Introduction
This book is intended for children who wish to learn programming and
computing. In this day and age, computer knowledge, or literacy, if we may
call it that, is of huge importance for every person, from early childhood on
through to his or her adult, professional lives. Even in the preschool system,
children very often have tasks given to them by their teachers, which require
the use of computers to a certain extent. That is precisely the reason this book
would be of good use both for teachers and for children. Teachers will get
help on the topic of how to bring the computer closer to children, and
children get the opportunity to learn their first basic knowledge of computers
and their use. They also get their first clues on the benefits computers can
bring to them and their lives. For example, from an early age, children learn
to explore using computers. In this way, their curiosity and exploring skills
rise, which can later help them through the school system, and in their lives
as adult working people, because today, there is no profession not related to
computers in some way. From surgeons, who use the latest technologies
when operating and saving human lives, to the astronauts who use highly
sophisticated computerized equipment when preparing to go to space.
Technological developments in the last two decades have enabled us to have
great things. These developments have made our lives much easier but also
much faster-paced than ever before. Things have gotten so hectic lately that
we have to carry loads of information with us wherever you go, from the
earliest stages of our lives. Today, most every child carries a cell phone or a
tablet everywhere, and within that tablet or phone lays a huge amount of all
kinds of data, from their contacts to ebooks to video games. This means that
technology has “taken over” every single sphere of our life: from work and
driving automated cars filled with electronic and automatic devices, to our
free time, which most of us spend in front of a computer or other device
playing games or posting and chatting on social media sites. Even before
starting school, our children learn the basics of operating a computer. They
have to, because, even in preschool system they are required to use
computers. This is because they have to be prepared for the first school day
when they are going to enter a classroom full of computers and other
equipment, which they will have to be able to use if they want to keep up
with the other students in class.
For all the reasons mentioned above, "Coding for Kids" is intended to be a
useful book for children and teachers alike, and to serve as a guide into taking
the first steps to learning programming. Teachers get an idea of how to
approach children when teaching them programming, and children get
acquainted with how the programs that they use are made, and on how they
can make programs of their own that can and will be useful to them. This
should also enhance their creativity and imagination, which is of crucial
importance to their growth and development in childhood, as well as for their
lives as adult people. If they decide to go "in-depth," children can learn how
to do something more, beyond the simplistic. The scope of interest in
learning computer science depends on the needs and interests of each
individual, child or adult alike. If programming is presented to them in a way
that sparks their interest and curiosity, then the kids will start exploring the
world of computers, always searching for something new and exciting they
can make themselves.
As the computer world is very advanced and fast-paced, new solutions for a
particular problem appear every day. This means that kids interested in
computers have to follow the innovations and news in the field they want to
explore further, no matter what it is. For example, if they are interested in
making video games (which most kids initially use the computer for, even
before they are old enough to start preschool education) they constantly have
to follow computer science news or the innovations in the computing field
they are interested in, programming languages, and updates to programs and
languages used to create computer programs and applications. Imagine you
have coded a calendar. The basic one, where you have 12 months and 365
days and just a small space next to each day where you can note your
appointments and tasks for that day. This is good for today, but as soon as
tomorrow comes, a program with more advanced functions will appear on the
market. Someone else has found a way to put, for example, more space for
editing next to each day, or a clock is coded into the calendar. In this new,
advanced calendar, besides the date, you can keep track of time during each
day--or perhaps holidays are now included, or the ability to set audible
reminders in the calendar. This is the kind of innovation we are talking about
in this book. That is why you need to follow your chosen field very closely.
Every day you may see and learn new things, which were not available
yesterday. For some kids (actually, for most of them) always being better at
doing and creating things presents a challenge. In the modern world, things
move along and progress quickly. The world itself became fast-paced. So,
you have to follow the trends and stay up-to-date to be successful in anything
you do, whether it is computer science or something else entirely. Everything
is now computer-based and so, you have to keep track of technological
innovations daily if you want to keep up with the rest of the world.
The computer world is very competitive in the so-called “fun” part of the
field, too. This means that programmers are always coming up with
something new for their end users. For example, it is a matter of prestige to
create games with better graphics, more colors, options, more gaming
characters (if the game theme is character-based such as fighting games are).
Nowadays, many children show interest in programming from an early age,
and, as computer knowledge is very useful, in this way they make a good
head start for themselves pretty early on in life. Some preschool institutions
in Serbia and in many preschools around the world have some sort of
computing class or coursework integrated within their educational plan. This
means that computing, or computer science, as it is known, is of critical
importance and therefore, we need to learn the basics of it from early
childhood on forward. Whether for playing games or constructing a small
program of their own, computers are now a daily presence in almost every
child's life.
Programming also enhances logical reasoning skills, because for even the
simplest programming task, the use of logic is essential. Furthermore, this
logical way of thinking is good for developing children’s math and science
skills. Programming and the use of computers is also a science in itself.
The reasons mentioned here make programming one of the most useful and
beneficial skills for both children and adults alike to possess. As with most
other science-based disciplines, it is best to start learning early in childhood -
the sooner, the better. Therefore this book is written to motivate children to
start learning to code to enhance their imaginations and logic skills, and to
prepare them for their future adult lives. Today, computer literacy is
mandatory. This book can help you give the children in your life the tools
they need to be successful when they are grown.
Chapter 1: What is Programming?
Syntax - What is it?
Computers are machines and, as such, they understand only what we type if
we type it in the exact manner that the computer expects you to. This is a
basic must if you want your machine to work properly and to give you your
desired results. The expected way of writing in a computer program is called
syntax. This means that syntax represents a set of rules in spelling and
grammar both when using programs and also when creating them. This is, in
other words, the grammar of programming. Without the knowledge and
correct use of syntax, we cannot use any program, much less make one.
Programming syntax contains strings similar to words, somewhat similar to a
human language we use in our everyday lives. Correctly formed syntax
strings or lines result in syntactically correct sentences within a specific
programming language, in the same way that correct sequencing and use of
letters when you write them down form a word and correct sequencing of
words make a meaningful sentence. When we’re talking syntax, what we are
referring to is a collection of rules governing the structure of the language.
You’ll find that syntax rules are unavoidable in programming, as not
following the syntax of a language results in your program failing to run. In
the first case, the document is treated as source code, while in another case,
the document is essentially a set of data to be processed. The syntax of a
language defines its surface form, or, in other words, defines what it is that
we see when opening and using one particular program.
Lower-level computer programming languages are rooted in distinct
sequences of symbols. There are also some higher-level programming
languages, which often have visuals, which may be denoted by either text or
a graphical interpretation. Syntactically invalid documents are said to have a
syntax error. That means, for example, if we type an incorrect code or
command, the program will send us a notification that a syntax error occurred
and that, with an incorrect command, we cannot proceed without correcting
that error--an error that could be as simple as an overlooked typo.
Syntax is divided into three equally important parts: phrases, context and
individual words.
Words represent the so-called “lexical level,” determining how characters
form pieces of a line in a code, or the whole code;
Phrases, or the so-called “grammar level,” narrowly speaking, have the
function of determining and distinguishing parts of the code from phrases;
Context represents a function that is determining to which objects or
variables certain names refer to, if their types are valid, etc.
Distinguishing between these differences in this way allows us process each
level individually, rather than having to load up everything every time you
start up the application.
Why is syntax so important in programming?
Without syntax, no programming languages can exist. It is as if you have a
language but no letters. It would mean that we can speak in that language, but
we have no way of writing our thoughts on it. That kind of language would
not have any sense and would serve little useful purpose. Some of the factors
related to the syntax of a programming language are readability, writability,
and program expectations. In most cases, regardless of what their opinion is
on a particular syntax, programmers use any available syntax and enjoy
trying different things. Nevertheless, we have to ask and answer two simple
syntax-related questions: Why is syntax so important in programming? Can
syntax be easily changed?
The answer to the first question would be that the syntax is important because
it is directly related to many factors of programming. Some of these factors
are readability, writability, and program expectations. It is the grammar of a
computer program, after all, the very backbone of the code. In most cases,
you will like a given syntax or you will dislike it, but some programs may use
any syntax and in so doing, you will enjoy trying different things and seeing
what works best for you and for the children in your life.
As for the second question, my opinion is that we have to learn the syntax
before we get the idea of changing it. If we do not know the syntax well
enough (or we do not know the syntax at all, in some cases, as with
beginners) we cannot know whether it suits us. Before you aim to change
something, you should get to know the thing (in this case, a language) you
wish to change. However, being able to change the syntax of a given
programming language depends on the design and implementation of the
language. For example, in the programming language that is called the Ring,
the syntax can be changed very easily. For the other programming languages
this varies from language to language. Basically, they all have their settings
and syntax rules. Knowledge of the syntax rules of every programming
language is essential for their adequate and successful use in coding or
programming. But before getting any ideas about changing the syntax, we
have to consider how the codes are written. We should also have in mind
what a particular function or syntax rule enables us to do.
One important thing to note is that you can (most often during the run-time)
change the language’s keywords as many times as you want to and you can
create different, custom styles for your source code. Creating a custom style
(or changing the language keywords) can be useful in many ways. Let’s
explore a few examples to bring this into context:
This includes language translation from English keywords to Arabic, French,
etc. Most uses of this function are applied in translating programs and
applications that allow you to translate a given text from one language to
another.
Easy storage and updates needed for some of your old codes (in old
programming languages used at the time when the particular program was
made). This also means that you may not only store but also use the programs
written in older programming languages. The only condition here is that the
programs stored must be updated.
Freedom for different teams working on different subsystems in the project,
where each team can use their favorite style, is also very important for any
given programming language. Besides that, if more than one team is working
on one project, they can function and work separately. That means that no
team may interfere with the work of another.
Syntax changes are good for research and trying different styles before
choosing the syntax usage best suited to your programming needs. This has
an enormous practical value, since that way, we can test our changes in
simple things and programs, before trying them with more serious and
demanding programs, languages and/or projects. It is also a great way to
learn and to test our abilities, which is highly valuable for both adults and
children alike. Besides proving ourselves as good programmers, it is also a
way to design something new and unique, something we can call our own.
Just be careful. You might end up with something more complicated than you
intended. However, even this can be a great opportunity for growth as a
programmer. Changes, in general, are a good thing because there is always a
chance to create something better.
Where do we start?
When writing about the syntax of a programming language, the big question
is: Where do we start? Do we start within explaining what the syntax of a
computer programming language is, how we use it and what we need it for,
as well as their practical application, or do we start somewhere else? What is
the simplest answer to the question of what syntax is and what the importance
of syntax is for us?
Syntax can be described as a kind of bridge between the machine and you.
You and your computer are connected by the syntax your computer needs
you to enter in order for it to execute your commands. If the syntax is wrong,
the computer is unable to follow up and execute any given tasks or
commands. It “does not understand” (let me put it this way) what you are
telling it to do, because you have “told” (a better term here might be
“written,” since we write our codes) it in the wrong way - you have used the
wrong syntax, or, you have used the correct syntax, but in the wrong way.
Therefore, it is of huge importance to understand the syntax used in
programs, and in the process of making them, because the better you
understand how the program is made, the easier it will be for you to
understand the program itself and its usage. Lots of different languages have
many different styles of syntax, with some languages being harder to learn
than others. For example, the programming language named Perl is often
criticized for being complicated. That is because of the number of symbols
used by some features of this language. Other languages like Ruby are more
easily understood because their semantics are much more simple, and their
syntax is cleaner. Changing the syntax of any particular language
programming could become very complex. The complexity of the syntax
change depends on the type of parser the language uses, but thinking in
different syntaxes can be good and useful. This is because it opens a range of
possibilities for amendments and/or improvements to the program itself and
its features. It can also help to make a particular program easier to use.
Getting a feel for the syntax might seem strange at first, but with a little bit of
effort, it's usually easy to understand and has the added bonus of being easily
understood by the machine as well.
Chapter 2: The Basics of Coding
Programming is a good and useful skill, which every child should learn. In
later years, this skill may be used to create and develop great things. These
things may be intended for entertainment during the childhood and teenage
years. But, many of these things raise an interest in programming that can
later be a solid basis for a career in computer science, engineering, or some
other computer-related profession. These professions today are very popular
among young people. Programming basics are something that anyone who
will one day work with computers should have a good grasp of.
There are so many different programming languages, intended for creating
different sorts of programs. The general rule is that any language can be used
to make any kind of program. But, is it true? We will discover the answer to
this question in this book. Some of these programming languages can be hard
to learn, while others are as simple as the alphabet we learned as small
children. It is entirely up to you to decide which one will be the best to pick
for your students. Just keep in mind that every person (and this applies to
children also) is an individual. Not all of us have the same interests, so
consider allowing them input when it comes to deciding which of the
programming languages they like best. You should present them with a few,
for example Ruby, Python, and Java, explain to them what the advantages
and disadvantages are for each of them. Then, to keep it interesting, you
might give them examples of programs and platforms they are familiar with
and explain to them which programming language are they based on. For
example, if you tell a child who has an account on Twitter that this social
network was built using the Ruby programming language, they may become
interested in learning more about Ruby, because this language is what made
their favorite pastime possible. By learning about the programming languages
that made their favorite games, applications and social networks possible,
they will also learn how to behave safely when it comes to computers and
data they post on the Internet. So, this is another good thing that will come
out of the first coding course.
Python: Just like normal speech
Python is a very simple programming language. This language looks more
like normal speech than like a programming language in the common sense
of the word. That is why this program is very easy to learn and easy to use. It
suits beginners best but more experienced programmers can use it too. Let's
examine why is it so easy to use. Coding is simple, although it may not look
that way. That, in fact, is a common misconception about coding in any
language, including Python. If you know how to give detailed instructions on
how to do something (writing and sending an email to another person, for
example) then you can learn how to code using the Python programming
language. It’s as simple as that.
Installing Python is generally easy, and in this day and age, many operating
systems (Linux and UNIX for example) come with Python already installed
as an integral part of the operating system. Even some Windows computers
(especially those manufactured by HP) now come with Python already
installed. When it comes to learning how Python works, how to use it, and
what it can do for us, you have a variety of sources to choose from. You can
learn it all by yourself, reading books, or using help available on the Internet.
These could include online courses, ebooks and even blogs written by
experienced programmers who wanted to make things easier for you as a
beginner. When starting out, it’s wise to take a look at freely available online
information.
Furthermore, there are countless online tutorials available to move on to after
reading this book, and many of these tutorials are cost-free and intended
specifically for beginners. Nearly every program developer that has any level
of success in creating programs tends to share their success with the rest of
the world. This is done mostly through blogging and videos and tutorials
posted on YouTube. You can follow their blogs, or watch the instructional
videos they post on YouTube. That way you can easily learn the basics of any
programming language and its syntax, because, these people post very
detailed videos and/or texts, explaining every single aspect to the core. There
are also options to chat with them. That way you can ask them for an
explanation of Python's syntax if that is what you are interested in. If you are
working on a Python-based program or project, and you encounter difficulties
using it, you may ask some of these bloggers for advice or help in solving
your problem.
Another way of learning about Python and how it works is the search on an
Internet library with copious amounts of Python tutorials. This library or
database is called the “ActiveState Python Cookbook.” This is a certified
tutorial book collection available on the official Python website. There are
many instructional tools available (including videos for visual learners) there
which can be useful to you and the children in your life, and can easily be
paired with the other resources mentioned earlier in this chapter to create a
solid basis for getting started with coding in Python. In the end, the choice of
learning method is entirely up to you. Use the one that you feel it’s the best
for you and/or your students.
One important thing you should know about using Python is that it is free.
You are not required to pay any kind of fee to use it. Python is a part of the
so-called “open source concept.” This is a concept that has one goal: to bring
programs to you as end users, without demanding a charge for it. If you
download something that is “open source” this is completely free. This
allows us to use the latest programming innovations to our advantage and for
our benefit.
In practice, the choice of the programming language is often dictated by other
real-world factors. I have mentioned the so-called “YouTubers” posting their
video tutorials before. These people show you how one programming
language works by giving you instructions using a simple example for nearly
every field covered by a given programming language. If you are a visual
type when it comes to learning, then this is ideal for you. They show you
every step that needs to be taken and also explain the meaning of every word
and/or symbol used for writing code. You might want to explore what these
examples are and give them a try yourself. That way, you (or your students)
can learn from practical experience how to make programs, not just in
Python, but in any other computer programming language. Use the source
code on your system freely.
How do we download and install Python?
How do we start using Python? Let me show you how Python programming
works. The first thing you have to do with any programming language (and
program, as well) is to download and start running it. With Python, it is really
easy. Now, I am going to show you how it is done. The easiest way to run
Python is using a platform called the “Thonny IDE”. This Integration
Development Environment has the latest version of Python already installed
in it. So you don't have to install Python separately or additionally.
After you have downloaded it, install Thonny Integration Development
Environment on your computer. This is done in the usual manner you use to
install all of your other programs. The installation process is easy. You will
be guided through this process by a simple and efficient wizard. This wizard
will give you all the information and options that serve to set your program in
the way that is most suitable for you. Then you have to save the file with the
extension that reads “.py”. For example, hello.py, or any other file name, but
always with this extension at the end. You can name the file any way you
want to. However, the file name should end with .py. Write Python code in
the file and save it. Then use the option "Run" in your text editor, and within
that falling menu, select the option called “Run the current script” or simply
click F5 on your keyboard to run it.
See how easy it is? When you have completed Python installation and when
you type the word "python" in the command line this will automatically send
you to Python and enable Python functions. Then you then can type in
Python code directly. After you have completed your code, you have to press
enter to get the output. When you want to exit the Python mode, you just
have to type “quit ()” and to press the "enter" button at the very end of it.
When writing your code in Python, you can use any text editor. You just need
to save your files with the “.py” extension at the end, as mentioned earlier.
The use of an IDE can make your use of computer programming languages a
lot easier. An IDE is software that provides you with many useful features.
For example, suggesting helpful hints for a code, highlighting and checking
the syntax, file explorers, etc. for the program used for the development of
applications.
By the way, the opposite scenario is also possible. That means, when you
install Python, an IDE named IDLE is installed on your computer as well.
You can use it to run Python on your computer. It is good for beginners in the
programming world, but more experienced users can benefit from it as well.
When you open the IDLE, an interactive window called the “Python Shell”
opens. In this window, you can create a new file and save it with .py
extension. For example, hello.py. Write Python code in the file, and then save
it with the usual “.py” extension.
When you want to check it and see whether your code is working, you have
to run the code you have written in your text editor. To run your code and
check whether it is working, you have to go to the option named “Run” and,
when the dropdown menu opens, select the option called “Run Module” or
simply click F5 on your keyboard. That is how you run your codes. This is
important because if you have any mistakes in your code, the program you
made will not run. Instead, you will get an error report written in the place
where working program results should be. As you can see, everyone can use
it.
Now that I have shown you how easy it is, you may start exploring and
experimenting with it. In Python, you can make anything you want. Just keep
it safe, ensuring your code is not aimed at causing harm to your or anyone
else’s computer. It is used in small and large companies alike. Besides
Google Inc., many other explorers use it. Python is the language of choice for
many universities and schools in their computer science classes. One of the
reasons Python is so popular is the fact that it is so easy to learn. It is also
used for creating a website's backend code. This is the code that runs on your
browser and it is different from the code that runs on your phone, computer,
or other mobile devices that have the option of Internet use.
Besides what we have already discussed, this language is useful for research
and data analysis purposes. That is one of the first and most important steps
when going into the world of coding. But, first of all, they have to install it on
their computer. Python uses IDE, which is once again, short for Integrated
Development Environment. In this environment, you have pretty much
everything you need to develop a program. There is a nice editor in which
you can write your program, and the ability to run and check it to see if the
result is as you wanted it to be. There is also a debugger, which enables you
to remove all the bugs in your program, as quickly as they appear.
You can also use "Jupyter Notebook" for making programs in Python. This is
a programming environment that enables you to write and/or test your
programs quickly, and, being as it is, this environment is accepted and very
popular with the scientific community. It is widely used for data analysis.
Jupyter Notebook has two components - a server, that has the function of
being the core of the program, and a browser (it may be Chrome, Firefox or
any other). The server and browser in Jupyter Notebook are connected. The
browser is something of a user interface for Jupyter Notebook. There, you
can write and execute your code. You can download it through Anaconda.
With Python, students will have very few obstacles with regards to learning
how to program. They will be able to learn how to construct programming
ideas within their heads, turning them into code that their computers can read
and interpret appropriately. After they have turned their idea into a usable
code, then they have to focus on transferring these ideas into instructions that
the machine can interpret. This is the core of coding or writing a program, in
any programming language - the computer recognizes the given code, runs it,
and executes the command contained within the written code. Many of the
common functions that programmers need are already included in the basic
programming language. This is what makes Python a great language for kids
to learn. In practice, the choice of a programming language is often dictated
by other real-world circumstances such as cost, availability, training, and
prior investment, or even an emotional attachment as crazy as it may sound to
you. Python is a language suitable for complete beginners who haven't done
any programming before, but also for those among us who have some level
or degree of programming experience.
Let’s take an example involving the compilation of code: If the expression
a+b needs to be evaluated, then we’ll need to figure out what a and b are.
This is what we mean by compiling. During this time the computer does the
operations it needs to, which are defined by methods you input into the code.
The code is written using the "Jupyter Notebook" browser and is executed on
the Jupyter server. In this we can see the interconnection I wrote about
earlier.
To download and install the Jupyter Notebook we need Anaconda Cloud, a
package manager, which allows you to install many programs at once. This
package manager is used mostly for installing science databases and libraries.
So, when you install the Anaconda Cloud, it comes with Python and the
Jupyter Notebook already included. This means that you don't have to install
the Jupyter Notebook and Python additionally - downloading and installing
the Anaconda Cloud will give you all three of these things in one package.
You only have to go to the official Anaconda Cloud site (www.anaconda.org)
and select the platform you are using (Windows, Mac, Linux, etc). After you
have done this, you will get two options between two versions of Python
offered for you to download. Be sure to download the latest one, since it is
the newest version. When you have done so, complete the installation by
agreeing to all the offers you are presented with throughout the installation
process. When you are all done, save it on a computer or other devices such
as discs. This process will take a while, so please be patient. Once it has
ended, your computer will show you on screen that the installation was
completed successfully. Then you can get started!
To launch Jupyter, you first need to launch an application called "Anaconda
Navigator". When you open this application you will find the option to
launch Jupyter Notebook, and, when you do find it, go ahead and launch it.
Then you will get a window opened at localhost:8888. You are now all set for
creating your first program.
If you wish to do so and save your project, first, you select what file location
or folder you want to make it save to. You may select a place on your
computer where the program you make will be located. My advice for
beginners is to always put the new stuff on the desktop so it is easy to find
but before you do, you should create a folder there to store it in. I am giving
you this piece of advice so you avoid overloading your desktop since it
sometimes prevents the computer from working as fast as you need it to and
can also just look cluttered and cause confusion, defeating the purpose of
saving it there in the first place.
To create a new file, just click on the New option in the top right corner of
your Anaconda cloud window. Then, in the dropdown menu that appears,
click on the option “Python 3”. The new file is now created. I recommend
you to rename it, giving it the name of whatever program or database you are
creating. This is important so you don't get confused when you begin to make
more and more different programs. When you have created and renamed your
file, at its end, you shall see the abbreviation ".ipnb" written at the end. This
is just a shortcut, a sign that your file is in Python programming language.
The next thing is a set of cells or the boxes you write your codes in. There
you can write any Python code. For example:
print("Hello World")
print - a command telling the computer what do you want it to do.
The text that is between parentheses, in this case, "Hello World" is the text
we want to be printed or written on our computer screen. When we run the
code as it is, we will see the words "Hello World" written right below the cell
in which the code has been written.
When you run the cell you wrote the code in, using the Run button at the top,
it executes all the codes placed within the cell. The text in which the
command is written is called a string and it is usually placed between double
quotes, but lately, we can find it placed between single quotes as well. The
important thing here is that you have to type your command correctly if you
want it to work properly and to print your desired text on the screen. For
example, if you forget to close the parenthesis and/or to run the cell, you will
get an error message below. The same thing happens if you put the wrong
kind of parentheses, or forget to close the quotation marks. So, you have to
do it correctly for it to work properly. As you can see, coding in Python is
relatively easy. As with any programming language, you just have to be
careful when you write your code because if you miss something, your code
is not going to work.
The set of steps described in this example with the printing of the "Hello
World" sentence can also be used for printing numbers or multiple lines of
text. The procedure is the same for anything you want to print. Before each
line, you have to give a command ("print") and then in parentheses and
quotation marks, you write the desired sentence. Afterward, you have to click
the Run button and your text will appear on the screen, printed as you coded
it.
When talking about variables in Python things are not much different.
Example:
a=1
By writing this code, you assign the value 1 to the variable marked as "a". In
other words, the variable marked as "a" contains the value 1. You won't see
anything printed on the screen, but variable named "a" shall contain the value
we have given it, or, in our case, the value 1. You can check it by printing the
variable "a" in the way I have already described.
print(a)
Note that this time, there are no quotation marks around the "a" written in
parentheses. That is because in this case letter a does not represent a string,
but a variable. When you run this cell you will see the number 1 appear on
your screen, or the value we have given to the variable named "a".
As with text, here we can run multiple lines by giving a command ("print") at
the beginning of each line. Bearing this in mind, you can assign values to an
undefined number of variables using this method. When you run cells this
way, you will get a sequence of values assigned to each variable. In the same
way, you can use strings to attach them to variables, and, when you run the
variable instead of a number you will get a string as a value of that particular
variable. There is also a possibility of re-assigning the values to multiple
variables. You can also replace the value of the variable given as a number,
with the value given in the form of a string.
What are the functions in Python?
We may look at them as a collection of instructions, a collection of codes.
We also use comments in Python. We write them below the code we intend
to write. Comments in Python begin with a pound sign (#). This sign is
widely known as a “hashtag,” probably because of social media platforms,
where a hashtag means you have tagged or mentioned someone using the
same social network, or tagged a phrase used to encapsulate an idea. We
define functions with the command “def function1 ():” and then we make a
dropdown menu in the following way:
print ("text1")
print ("text2")...
You may have as many lines as you want to have on your menu. The
important thing that all the lines we intend to include in a function have to be
just four spaces inside. Only in this way will the function will work properly.
The lines inside the function will not be run until we use (or, as programmers
tend to say it, call) the function.
As you can see, Python is not a language oriented toward looks. It’s not
fancy; there isn’t much glitz or glamor. You have options for adding color or
contrast, as in any other programming language, but Python is more business-
oriented. Think of it as a sterile environment in which you can work and
create new things to be remembered by.
Ruby: Trust me, it is self-explanatory
Ruby has been present in the programming world for over 2 decades. Despite
this fact, there are still people who do not know how to use it. Ruby as a
programming language is suitable for use in a wide range of professions. It is
also relatively easy to learn and/or understand, even for beginners in the
programming field. There are also those people who, when they encounter
Ruby, actually take their first steps into the programming world. Ruby
became famous because it was the programming language of a well-known
social networking site called Twitter. Most everyone now has his or her
account on Twitter. When you learn about the programming language your
favorite pastime is based on, it is only natural that your curiosity and interest
for this programming language will be piqued, and that you will start
researching and exploring. Ruby is a language that any beginner can easily
read and understand. Learning does not take much time, and it is more than
useful when it comes to writing your first coding projects. Ruby may be used
even for coding complex programs, professional program systems for offices
and/or large companies. It is not intended just for learning and having fun
experimenting with the computer in your free time. It does, in fact, have the
capacity to be a much more serious language.
The great news for teachers is that instead of spending a lot of time
explaining the code which students are then typing into their machines, a lot
of it will become immediately clear to them once they see how a Ruby
worksheet looks. When you open the Ruby worksheet, all possible operations
and functions of it are right in front of you. Options are named in a simple yet
precise way. You know what each function is about simply by reading the
function name. Many of them in text editors have their corresponding
dropdown menus. When you click one of the options Ruby sets before you, a
dropdown menu with the additional or related options will appear. Students
will understand this programming language just by reading and following the
text of the program. This is an important factor for children who are still
learning and taking their first steps into the world of programming: what it
means, how is it done, and many other things necessary if they want to write
a computer program of any kind. Ruby helps students in performing given
tasks.
At the end of the day, children will need to learn the concepts of
programming if they want to write good scripts. This also means that the
children will have to learn how to use logic and thinking to achieve certain
goals and expected results. These are the first steps for them towards being
able to perform more complicated tasks. Ruby need not be used exclusively
for serious business, though. Since Ruby was the language involved in
creating Twitter, you can show students that Ruby is an interesting language
used for something fun, rather than just for creating school projects in class.
If they see it as something associated with entertainment, your students will
show much more interest in learning how Ruby works.
We can all see how much social media is affecting our daily lives. Kids as
young as 6-7 years old are using social networks in the modern age. By the
time they’re in school, they become pretty skilled at using social networking
as a tool that helps them to communicate among themselves. Thus, it is only
natural for them to want to understand how the social network they use is
built, what its advantages are, what its disadvantages are, and how the social
network they use works. For this reason, children will likely be interested in
learning about Ruby. If they know how their social network is built, if they
understand its inner workings, they have more insight into how to use it
effectively and safely.
We have said enough about the benefits Ruby offers as a programming
language, and what basic knowledge regarding Ruby means for us. Let's see
how Ruby works. Ruby is a programming language oriented on objects. This
means that every value represents an object, including classes and types that
many other programming languages regard as primitive (there are many
examples of this but the most obvious are integers, Booleans, and "null").
With Ruby, variables always refer us to an object. Here is a brief explanation
of what that means:
Classes and objects are very important in Ruby. Inside every class that you
have defined, you may put as many objects you want. If you add attributes to
your class, all the objects within that class shall have these characteristics or
attributes. Ruby is a programming language that allows us to use all kinds of
data inside of our programs. By this, I mean Ruby, and all Ruby-based
programs, as well as the ones created in this language. It does not matter
whether the Ruby-based program is a little project, for example a custom
made calendar or a clock (these two programs and their coding will be
described later on in this book), or a large social networking platform or a
program for a large company. Strings, images, floating point numbers,
Booleans, etc., are different kinds of data suitable for use in the Ruby
programming language. The problem is that not all things can be represented
as data in Ruby. You cannot represent everything with just a string, or just a
number.
However, one of the great things about the Ruby programming language is
that it allows you to create your data types or custom data types. That way,
you can turn an object from daily life into data that is usable and acceptable
by Ruby. This so-called custom data type you create for representing things
in programs made in Ruby is called a class. So, the class is a custom data
type that we can define. For example, if you create a class named "Novel"
you can represent all books in the Ruby program using this class. Also as an
example, you can create a class named "Adult." Read and follow the code
below.
class Person
attr_reader :named, :old
def initialize(named, old)
@named, @old = named, old
end
def <=>(Adult)
@old <=> Adult.old
end
def to_s
"#{@named} (#{@old})"
end
end
group = [
Adult.new("Bob", 33),
Adult.new("Chris", 16),
Adult.new("Ash", 23)
]
puts group.sort.reverse
When you create classes in Ruby, you have to write their names with the first
letter capitalized. When you create a class, you are modeling an object from
the real world and putting it inside your program. So, when you create a
class, you are giving this class various attributes. A class is a "blueprint" of
sorts for an object. Inside every class, we can define unlimited amounts of
attributes. Every object belonging to the same class will have these attributes.
Example
class Book
attr_accessor: title, :author, :pages
end
By typing this code, you have essentially instructed Ruby what attributes
every object belonging to the class "Book" should have. Now, inside this
class, you can create your books. The number of individual books you add to
your class is unlimited. There can be hundreds or thousands of them.
Therefore, out of a single class, you can make your own custom-made library
with all of your favorite books stored inside. Objects and variables in Ruby
are created in the same way. They are also considered as equal when it comes
to the data hierarchy of a programming language.
Example
class Book
attr_accessor: title, :author, :pages
end
book1= Book.new ()
book1.title= "Harry Potter"
In this example, you see how to add one book to the Ruby Book class. This
means that you have added an object to a class. You can add many attributes
to your objects. You can do so with the following code:
puts book1: pages
In our example, by typing this code you gave a command to Ruby that, when
you write the name of the book object, the whole book is shown. Everything
in Ruby is divided into classes or objects. Only these two categories of data
exist in Ruby. The number of objects you can create inside a class is
unlimited.
Everything written so far about Ruby makes it clear why Ruby is one of the
best programming languages for a variety of programs and can be used for
many different types of projects. The number of well-known program
platforms that are created with the use of Ruby is vast, and giving a full list
here would be virtually impossible. It is enough to say that many of the most
commonly used platforms are made using Ruby.
Every programming language is in some way, a world of its own. Class and
method definitions are marked by keywords. Attributes reader or, in the
language of code, "attr_reader" is an example of metaprogramming in Ruby.
You give certain preset characteristics to all the future objects that will
belong to that class. It should be noted that you cannot close a class.
However, what you can do is enhance the existing class using additional
methods. This principle will apply to all classes, ranging from built-in to
custom-made classes that come with different libraries (a subject which will
be discussed later.) You need to do little except make a class definition for a
currently existing class. Once you accomplish this, you can simply add as
much new content to the existing classes as you want through methods.
The best way to learn Ruby (or any other programming language, really) is
through examples. So, feel free to ask for help if you need it. Today many
tutorials teach you how to do things, so my advice is to explore tutorials and
come up with the simplest but most effective way of learning for yourself
and/or your students. One way to learn new things about Ruby is to read code
others have written about it. Programs, as well as programming languages,
develop very fast--in just a half a day, a new program could be made. This
means that the thing we learn today becomes “old news” tomorrow. That is
where the saying “yesterday's news” in fact came from. So, you have to be
quick about it and get a grip on as much information as you can. Today, we
have many open source projects, and coding challenge sites that allow you to
see the solutions from other developers once you submit your own. That is
the best way to learn to program and share your ideas with others. Later in
this book, I will show you why asking for help from others may be good for
you, no matter what your level of knowledge of programming is.
Ruby is easy to download. The best thing for you to do is to download it from
an official website. Avoiding infections of your computer with viruses, etc.,
is of extreme importance because, today, new viruses, ever more dangerous
for your computer, are made at a pace of nearly 10 per hour. Be careful with
downloading. You will also need a text editor. You can use any text editor
there is, but the one named "Atom" is recommended because it is an
environment programmed especially for Ruby codes. It is easy to install - just
follow through with the instructions given during installation on your
computer screen and a short while later, you are all set to go.
Python and Ruby function on a similar basis, as you can see. If so, what is the
difference between them? They’re also different in some critical ways. It’s a
common question, but also an important one.
The Ruby language is made to serve the programmers that are using it to the
best of its ability. The most popular platform for Ruby is Ruby on Rails. It
allows the programmer to do a lot of things that they otherwise wouldn’t be
able to do with just the “vanilla” (a term in the programming world meaning
the language without any libraries or add-ons) edition of Ruby.
On the other hand, this same simplicity can lead to a developer’s downfall.
This simplicity doesn’t easily lend itself to debugging. You can easily lose
hours and hours of work simply because of the way Ruby was designed. So
keep this in mind and make sure to stick with good coding conventions and
don’t lose sight of your goal.
The Ruby on Rails framework, which is ever-growing in popularity, is built
based on the Ruby programming language. On the other hand, Django, which
is also a popular and widely used web framework, is built based on Python.
This difference in frameworks between languages is where many of the
differences between the two languages originate. While one might find
similarities between these two languages in the looks department, you’ll find
that this similarity only runs skin-deep.
The Ruby language has been made with flexibility and ease of use in mind.
It’s basically English after all, or at the very least, the closest a programming
language will get to English. This is what enables the powerful Ruby on Rails
framework to do so much. This can be very good and useful, but flexibility
can also cause some problems to arise. For example, the same thing that
makes Ruby work so well in most instances can also make it very hard to
track down bugs, resulting in hours of going around through code in case
there is some mistake and the program does not work as we have planned it
to.
Let’s take a look at the flip side. Python takes a very straightforward
approach to programming. Its primary goal lies in making everything neatly
visible to the eye. While one could see Ruby as a language made to be clear
to everyone, Python is made to be clear to programmers. This comes at the
necessary loss of the elegance and unique design that Ruby possesses.
A great example that shows the difference is working with time in
applications you have created using one of these programming languages,
and then the other. Imagine you want to keep track of time one month from
now. Here is how you would do that in both languages:
Ruby
require 'active_support/all'
new_time = 1.month.from_now
Python
from DateTime import DateTime
from dateutil.relativedelta import relativedelta
new_time = DateTime.now() + relativedelta(months=1)
Neither approach is right or wrong; they emphasize different things. Ruby
shows the flexibility of the language while Python showcases directness and
readability. That is the difference between them, as shown in this simple
example. It is not my goal to confuse you in any way (or anymore than you
already are) and because of this, I have chosen to show you where the
difference is in the simplest possible example. You can use one of these
programming languages or both or other languages entirely. The choice is
yours alone. If you are into looks and the visual beauty of a program is
important to you, then I suggest you use Ruby, since this programming
language takes this into consideration. On the other hand, if you are more
business-oriented, pragmatic and not much interested in graphics and how the
program looks when you open it, then Python is an ideal choice for you to
make your programs in.
Java: This is where the fun begins
Java is one of the most popular and widely used programming languages and
platforms. Today nearly every kind of program can be designed in Java.
JavaScript is an environment that helps you develop and run programs
written in any programming language, but it is also fast, reliable and secure.
Java is used in every nook and cranny you come across. It is as if we can do
everything in Java. Therefore, Java is arguably a bit harder to learn than
either Ruby or Python, but choosing Java, as a first-time programming
language will make learning any subsequent languages a bit easier for both
you and your students. Many students have already thought about creating
their apps or websites because having your own website is not a prestigious
thing anymore. It is now commonplace to have one’s own website, and for
some professions, it is an absolute necessity. What is it that made Java so
famous?
Java became widely known and popular because it is a platform-independent
programming language. It means that Java does not depend on any type of
operating system. This is what separates the Java programming language
from others like C or C++. C or C++ is intended just for Windows operating
systems and can be used only on computers utilizing a Windows operating
system. On Linux, you cannot use C or C++ programming language.
Another layer was added between the operating system and Java: the Java
Virtual Machine or JVM. This is what made Java independent from operating
systems or platforms. It is upon the JVM that Java is built as a language, and
this enables it to be used across various operating systems. Java, then, can be
viewed as a more universal approach to programming.
Originally, Java was created for the development of applications for mobile
phones and other devices. Since all these devices have different operating
systems, a programming language suitable for them had to be platform
independent.
How to install Java
First, you need to install the Java Development Kit, also known as the JDK,
and the Eclipse IDE (Integrated Development Environment). Java programs
can be written in the Notepad text editor (or another text editor), but it will be
difficult to program. You need to remember the syntax and to resolve issues
if they appear.
To download the Java Development Kit, go to the official Java website and
download it from there. You can download it from other websites or sources,
but the official one is the safest for your computer if you want to avoid
viruses and the like. The official Java website will offer you many versions of
the Java Development Kit. You should download the latest version. This
version is Java Standard Edition 7. Together with the Java Development
Environment, you will also install the Java Runtime Environment or the JRE.
These two are mutually connected.
When you open the package you have downloaded, the first question during
installation will be to check the box next to the operating system you have.
Then you have to accept the License Agreement (many programs have these
and you must accept them if you want to install and use the program) and
decide if you have a 64-bit or a 32-bit operating system.
Once you have completed the download, you have to double-click on the
installation icon. The installation wizard makes things easy--you just read
through every message on the screen and then click the button "Next". At the
very end, the wizard will show you a text message saying that the Java
Development Kit (or the JDK) was successfully installed on your computer.
The next thing you need if you want to write programs in Java is the Eclipse
Integrated Development Environment, also known as the Eclipse IDE.
When you type the name of the IDE into Google, it will take you right to the
official site where you can download either the "Eclipse IDE for EE Java
Developers" or the "Eclipse IDE for Java Developers". The choice is up to
you. The only difference between the two mentioned Eclipse IDEs is that the
first one (Eclipse IDE for EE Java Developers) is a bit more complicated than
the other. This is understandable since the first one is essentially intended for
the development of Java software for engineering enterprises. For private
users, the second one, the Eclipse IDE for Java Developers, is more than
enough to get you started. You can also use the standard Eclipse IDE. All of
these files come zipped. This means that you first have to unzip them if you
want to install any of these files. When you install these programs, create
shortcuts to your desktop. That way, you will be able to more easily access
these programs later.
Java syntax
When we come to the syntax of Java, things look a bit complex. It is very
important to keep in mind the following features of the Java programming
language.
Java is a case-sensitive programming language. This means the identifier
"Hello" (written with a capital letter H, marking the beginning of a sentence
to be printed) and "hello" (written without the capital letter H) in Java would
each have a different meaning.
All class names should have the first letter written in uppercase. In other
words, the first letter of any given class name needs to be a capital letter. If
multiple words are used to form the name of the class, the first letter of each
inner word should also be in uppercase. This is the correct way of writing
class names containing multiple words.
Example: class MyFirstJavaClass
Method names, on the other hand, are written differently. Take note that all
the method names in Java should start with a lowercase letter. If several
words are used to form a method name, the first letter of each inner word
should be an uppercase letter. When you write this, it should look as follows:
Let us take an example: void aMethodForUs()
Now, it’s extremely important to note the following:
The name of the file in which the program resides must be identical to the
name of the class. If/when you save this file, then you should make sure to
remember that it is saved under the same name as the class, as well as paying
attention to the case of the letters, as Java is case sensitive. After you’re done
with that, you’ll need to add the “.java” extension onto the file, without
which it will not operate. If you find that the class and file names aren’t the
same, then your program will be unable to start up. This would lead to a
critical failure of the program and a complete inability for it to function.
When you open Eclipse for the first time, you will have an open window,
which is, in fact, your working space. If you want to make any program, you
first have to create a new project in which you will write the code. You do it
by clicking on the button "New" and then, from the dropdown menu,
selecting the option "Java Project."
After you have done this, an additional window will appear. In that window,
there are a few fields you have to fill out if you want to create a project. First
of all, you have to give your project a name. The next thing to do after you
have saved it is to open it by double-clicking. On the left side of the screen,
you will find a file named the "src". This means "source." This is the place
where all your Java projects will be saved and stored. You can try to write a
simple first project in Java. The simplest thing is to write a code for printing
out a message “This Is How You Make A Program Using Java” on screen,
using Java as your programming language. When coded, it looks like this:
public class OurJavaProgram{
/* This is how you make a program in Java.
* These are comments, denoted by (*) and this is how you print “This Is
How You Make A Program Using Java”
*/
public static void main(String []args) {
System.out.println("This Is How You Make A Program Using Java"); //
prints This Is How You Make A Program Using Java
}
}
Let's see how to save the file we have created, compile it, and run the
program we have made. In doing that, you should follow these steps:
Open your text editor and add the code as written above. Once you’re done
with that, save the file as OurJavaProgram.java. The next thing you have to
do is to open a command prompt window and check the directory where the
class you have created is saved. The best place for storing your first project
created using Java is the C partition of your hard disc. That is where your
most important files are, and also those files, which you open and use most
frequently. If you want to learn anything, you have to practice and repeat it a
couple of times. Learning a programming language is not in any way
different than learning any other subject. So, it requires a lot of effort,
practice and revision of the things you have successfully created. Those are
the reasons you should have your first Java program in the C drive--you’ll
want to come back to it often.
After you have saved your first program, type 'javac OurJavaProgram.java'
into your editor. The next thing you have to do is to press the "enter" button.
This will allow you to let your code “compile,” which means that it will load
the data from Java, and translate it into machine language. If you have come
this far, then, type ' java OurJavaProgram' to run your program. The text '
This Is How You Make A Program Using Java ' will be printed on the
window. If that is the case, your program is correctly coded. It means you
have made it! Output, in this case, should look like this:
C:\> javac OurJavaProgram.java
C:\> java OurJavaProgram
This Is How You Make A Program Using Java
Java has been around for two decades and in that time so many online
resources like online and YouTube tutorials have appeared, telling and
showing us how virtually anything can be created from the ground up using
Java. There are a few initial obstacles you need to overcome in order to get
started with Java. The very first thing you need to do is installing JDK and
gaining an understanding of how it works, but the setup of the programming
language makes it easy for students to understand and learn Java. Java has
many similarities with C and C++. One perk, though, of using Java is that
compared to C and C++, Java offers more functionalities, thereby enabling
the students to create larger and more expansive programs than the ones
programmed using C and C++. Java is much simpler to use and enforces a
different programming model than the ones in C or C++. Java-based
applications may be run on a single computer but they can also be distributed
between different servers and clients within a network, just like the
applications on the Google Play Store, or the Apple App Store. Now that you
know the so-called "Java story," let's see what Java can do.
For general purposes, high-level Java programming is a powerful software
platform. Although it is really a bit harder to learn than Ruby or Python, Java
enables you to do really great things. Feel free to explore and learn how Java
works and what you can do with it. You may end up surprised by the things
you will be able to create.
How to make a simple Java program
There are many tutorials related to this on the Internet. This is in part thanks
to Java’s popularity among both children and adults alike. Everyone wants to
use it for his or her projects, no matter how small or big. Whatever you want
to make on your computer, Java is the thing to do it with.
Make a note that, in case you do not have a public class present in the file,
then the file name can be different than the class name. It is also not
mandatory to have a public class in the file.
Example: Let’s say 'OurJavaProgram' is how we’ve named a class. In this
case, in order to make sure that it runs, we have to save it as
'OurJavaProgram.java' public static void main(String args[]) − When it comes
to Java, you’ll find that everything descends from what is called the main
method. The “main method” is the first and foremost part of any Java
application. Just as with a range of other coding languages, in Java you can
use classes and methods in a variety of ways. You can also change all of their
internal parameters. With that being said, bear in mind that Java has 2 kids of
modifiers: access and non-access modifiers. These are differentiated by the
former being private, while the latter are public.
There is something about Java that makes this language specific, different
from others. This is the Java interface. In Java language, an interface has the
role and is used as a sort of contract between objects that gives them
instructions on how to communicate with each other. What does this Java
interface do for us? The Java interface is used to define the methods and
subclasses that should be used; implementing these methods, however, is
dependent entirely on the subclass.
Another thing worth noting is that a line containing only space, possibly with
a comment, is known as a blank line, and Java ignores it. As with other
programming languages, for writing codes in Java, the first thing you need is
to open a text editor. You should first open your text editor and create a file
named “New text document” as if you were writing some text. After you
have created a new text document, save it with the “.java” extension. After
you have saved it, you can actually generate the program. The only problem
is it won't do anything. In fact, if you try to run the program as it is, an error
message will appear. That message says "Error: Main method not found in
class MyFirstProgram, please define the method as: " and then you will see a
specific line of code. This is because you have not written anything yet. You
should be writing in that line of code since it is an important part of the
program you have to understand.
As with most languages, Java has a very specific way of organizing and
expression. This organization must be followed or the program cannot be
generated by the compiler. What you have to do is to set up the basic
framework of the program. An easy comparison here is to think of classes
being an entire keyboard, whereas the methods are the individual keys on the
keyboard. Right now, your program is just an empty class (somewhat like a
keyboard with no keys). The compiler recognizes this because the first word
you type should say "class".
After reading the word class, Java's syntax dictates that you need to state the
program’s name (a label on the key), in this example, you should name your
program "MyFirstProgram". This program name is a good choice because it
is descriptive of what your program is. An important thing you should note is
that most programming languages will not allow spaces in the names of
things. This is because the use of space within the code helps the compiler
understand what the instructions you have given to the program are. The
compiler, reading the name of your class, expects you to show some way of
denoting what part of your file makes up the class itself, and to do this, you
have to use curly brackets ({ }) to determine the start and the end of the
class({). Open curly brackets indicate the start of the class, and the closed
curly bracket denotes the end of each particular class. When there is nothing
to show inside the curly brackets, this means that there is no class defined and
then an error will occur. An error message will be printed out on your screen.
The next step of writing a Java program includes a second line in your
program when you have to press the “tab” button on your keyboard and type
the following code:
"public static void main(String[] args)
{"
After you have completed this stage, press the "enter" button on your
keyboard twice, then tab again and type the following; "}". That way you are
actually “closing” the class.
This is the so-called "main" instruction for the making of any Java program.
The "main" method of a class is the same as the main instruction of a
program. When the "main" method is present in the class, it allows the
program to be executed, or, for that matter, to work properly. The reason for
this is the fact that when a Java program is run, the first thing a computer
looks for is a method named "main" and follows all the instructions within
that method. When there are no instructions within the “main” method,
running the program will cause nothing to happen. In front of the main
method's name are three words. These words describe specific attributes of
the method. The first word describes who can use the method, and since this
is the main method it must be available for everyone to use it. For this reason,
the main method always says "public."
The next word is optional and describes when the method can be used. The
specific details of this word require a piece of deeper knowledge. So, if you
are interested in the deeper meaning, feel free to investigate this matter
further. The last word describes what sort of object the method produces. In
our example, we do not want to produce anything so we put the word "void".
In this way, the computer “knows” that it will not be expecting anything at
the end of the instructions.
Next to the main screen, there is a left parenthesis that contains some code
and a left parenthesis followed by the curly brackets. The curly brackets, as I
have written earlier, describe where this part of the program starts and ends.
The code inside the parentheses denotes the inputs of the method or what the
method expects to receive from whoever is using it. In this case, it expects to
receive an array (denoted by the following signs: "[]") of strings, or
commands, which the computer will be running. In other words, the
computer expects to receive a list of words containing a command or an
instruction on what it needs to do. When the main method is called by a
computer, it puts all the words that are written after it into that list and hands
them over to the program.
The next thing to do is to write your instructions for the computer. This is
easy. On the empty line in the middle of the program press tab twice and type
the following:
System.out.println ("Hello, World!");
This instruction will cause the sentence "Hello, World!" to appear in the
place where you have chosen to execute your program.
The instruction part of any program is where you are telling the computer to
do something. The heart of programming lies in being able to give your
computer a command, which it will recognize, understand and to which it
will answer in the way you desire. Write this line of code and you've done it.
By doing this, you have made it - you have created your first Java program.
"System.out" is the first part of this instruction you need to understand. The
system is a class readily available at anytime, anywhere. Appending ".out" to
System allows us access to a class contained in a System. That gives us
access to the computer's output. Running the "println" method from "out" will
write (or print) the text passed to the method to the available output place. In
our case, this will be the command line.
When saving the project you have coded, use the option “Save As” in your
text editor. Then, choose the option “Save as type” from the dropdown menu
that will appear after clicking the button, and after that, select the option “All
files”. The very last thing to do here is to change the file name if you wish to
do so.
Through this simple example of writing code for printing the sentence
“Hello, World!” I have tried to bring Java a little bit closer to you. The truth
of the matter is that Java is more complicated than, for example, Python or
Ruby, but it also gives you a wider range of possibilities to get creative and
do really fantastic things.
Chapter 3: Let’s Start Coding
When we talk about the basics of coding, we think of the very first steps we
take into the world of programming. Luckily, there are some basic steps kids
can learn to do by themselves if they intend to learn how to code. It is
recommended that they start with coding simple things, like coding a clock or
a calendar, and then to proceed to code their favorite thing of all - video
games. In making and coding a calendar or a clock, they can create a useful
tool for themselves, to help them keep track of their to-do lists, tasks and
important events like birthdays, appointments, etc. These first steps can
enhance their creativity as well as their interest in computer science--the
science of the future.
Everything we do today is based on a click. Even things like elevators and
cars are automated now. Technologies advance almost daily. Having that in
mind, you have to learn fast and get a grip on things if you want to keep up
with the rest of the civilized world.
I have mentioned games. Well, just remember the old games you were
playing on consoles like Nintendo, for example. During the 1990s these
games were very popular. But a few years later they were forgotten, left
behind as PC gaming came into its own. Kids started playing other, more
vivid games on their computers. Today we even have virtual reality games
that allow us, with the use of a specific piece of hardware (VR goggles), to
have the feeling as if we were physically present at the place where the story
of our game plays out; almost as if we are really there, influencing the story
in person, not just by clicking or typing.
Knowing this, it is clear that technology has come a long way in a few short
years. That’s how fast it is developing. So, it is imperative to start learning
early, so the children of today can stay ahead of the game in the future when
it comes to fast-developing technology.
Video games
It is common knowledge that kids just love video games. Most of them, in
this day and age, spend a lot of time on their computers, phones or tablets,
playing video games. The game to have, in the 1980s, was “Super Mario
Brothers” created and developed by Nintendo. In that time, this game was the
best thing you could find. Today, when we even have the option of virtual
reality gaming, things are so much different. The market is full of various
video games, with many different themes. Kids love them all. But what if
they could learn to make video games themselves, with themes and functions
they like? It may sound complicated, but the truth is, it is entirely possible
given the tools we have to work with using today’s technology. No matter
what your skill level, you can make a game too.
Now, realize game development is like any other skill. That means you only
get better by trying, failing, then improving your knowledge and with it, your
results. To make a game, you must go through the stages of game
development: Design. Art. Code. Audio. Polish. Market. If you want to
design any video game at all, you have to be acquainted with computer
programming. In almost any field and/or segment of our life, writing
computer code is now practically a necessity. Computers are everywhere
around us and so, we have to know them to understand them and use them.
Knowledge of computer code--how to read and write it--is very helpful in
many areas of our lives. For making video games, knowledge of
programming languages and coding is a prerequisite without which no video
game could ever be created.
Now, it’s important to note that the more advanced the game you’re
developing is, the more advanced the code you require. Think about the
graphics in games like The Witcher 3. Those aren’t exactly simple to make,
and neither is the blood-pumping gameplay of Bloodborne. Even the days of
our early childhoods weren’t so simple, with games like Super Mario
Brothers requiring considerable knowledge to be created.
Generally, games come from an engine, and the engine is the “frame” from
which you can go on to develop the game. It lets you skip a considerable
amount of the development process, which is why engines are generally used
by bigger companies, pumping out games every few months.
On the other hand, it’s also possible to code a game from scratch. This is
generally used more by indie studios and independent developers. All in all,
while a more complex code doesn’t necessarily mean a better game, it
certainly can contribute to a game’s quality. It’s also important to note that
writing code from scratch is quite a bit more time consuming and effort
intensive, but it does allow for more control over the finished product.
Somewhat similar to making a cake or a dish - the more effort you put into it,
the better the result will be. When talking about video games, better results
can also mean greater success, both for the game that has been created and
for its maker. Of course, I am mostly referring to those who create video
games for a living (as a profession), but even hobbyists can earn profits by
utilizing their knowledge of coding, their ingenuity, and their creativity. Let's
see how they do it.
Software computer code programs a computer at the most basic level, giving
it the main functions necessary for its daily use. While this is impressive,
video game development requires even more effort than this. You need a
really masterful command of the programming language you’re using in
order to code a complex video game. This shows in pretty much all areas of
development, as gaming is slowly becoming even more popular, and game
development studios are hiring more and more highly competent coders.
Video game creators sometimes refer to the code the game is made in as "the
engine" that makes the game run, enabling you to play it. This code will
make many (we are talking about billions here) of calculations in an instant.
These calculations are needed if we want to create a game.
Looking at popular video games, we see that characters do a variety of things,
from shooting to collecting gumballs, however, all of this is governed by
calculations that the computer makes.
Video game makers use several different coding (or programming, if you
will) languages to create their games. There’s a variety of languages that can
be used when coding video games, Ruby and Python as well as among many
others. It means that almost all of the commonly used programming
languages are suitable for use if we want to make a video game.
Now, let's see how is it done, and how you can make your own video game.
The first thing you have to think of and to put on paper before you start
making a video game is a design. Is it going to be 2D or 3D? What kind of
game is it--is it a puzzle game, or a driving game, etc.? Once you get those
answers jotted down, the next question is: How do you capture this concept
and make it into a game? Write it all down.
Everyone has their own way of doing that in the best possible way they can
think of. Some people compose 60-page design documents. Other
programmers write a page of badly written notes, unreadable to anyone else. I
don't know what's best for you. But I can give suggestions on what to write
about:
Here are some ideas on how to decide what kind of game to make. In my
opinion, this is the most important - to write down your ideas. Once you
capture your ideas on paper, you can write down the next points much easier.
You need to answer a few questions first. What your game is about?
Fighting? Numbers? Scandals, perhaps? Is it putting a new twist on an old
classic? Maybe you want to bring in innovation, and try to do something that
nobody else has tried yet?
The next step in the making of your first video game is the mechanics. What
does your player do? And for what purpose? This is your gameplay. It can be
as simple as pressing in the game called “QWOP”, tapping buttons to chat in
the “Mystic Messenger,” to the tons of key combos in the game called the
“Dwarf Fortress.” These are just some ideas for you. Of course, you can
make a video game about anything you want, giving the players endless
choices of weapons, buttons, controls, etc.
The next thing you have to do is to think of a good story. What story should
players remember your game by? What emotions should they leave your
game with? Every game has a story. If the story isn't obvious, then it means
that the players can create it. An example of this is the Android game called
"Choices." In this game, you make up a story of your own. A story can be
created from the increasing numbers as it is done in the game called “2048,”
the rising of empires in the “Civilization,” and the silent interactions like the
ones in the game the ”Monument Valley”. Think about what story will be
found in your game. Be creative, make up a story of your own. You cannot
make a mistake in creating a story. Just try to make it as interesting as
possible so your players will like it. One game can also have multiple stories,
as is the case with the game “Choices” mentioned earlier. The very first thing
you have to do when you enter the game is to choose a type of story. Is it
going to be a love story, or something from college, perhaps? After you have
selected the type of story your game will have, you are presented with
situations that happen in daily life. Depending on your answer to a particular
situation, the next “chapter” in your story opens. Perhaps you can implement
something where for making some choices the player receives a bonus, while
for others they have to pay to be able to make that choice.
Another important thing to consider is the game’s mood and style. What
impression does your game make? What are the visuals? Sound? First
impressions matter. First impressions will keep the player interested--or not.
It all depends on how much effort you have put into things like graphics,
visual effects, and so on. Art is also an important part in the making of a
video game. You can choose to give your game a retro vibe with pixel
graphics and chiptune music, or you can give your game a modern, clean
look with flat geometries and popular instrumentals. It is entirely up to you.
Tastes vary, be aware of that. Not everyone will like your game, the same
way you don't like every game you see or hear about.
Once you've planned out your idea, congratulations! That's amazing! Now,
you can work on the actual game. If you don't know how to code, I suggest
you learn something about the programming language that you intend to use
when making your video game. That way, you will know how to code when
the time for coding comes. Nobody wants to create art that they will trash
later because they did not know how to code it and turn it from concept to
reality. On the other hand, if you do not know how to draw, use basics like
shape, color, and space, to make something nice. Think about how you can
make it unique. Your game might have a distinct color scheme, font(s),
shape(s), and icon(s). But it also has to function. Is important information
readable and obvious? Do the colors/fonts/icons distract from that at all? It is
important to find answers to these questions before you proceed to the next
stage of making your very own video game. When making 2D and 3D
animations you have two basic options: you can do it bone-based, or frame-
by-frame. I will now try to explain, as shortly as possible, what each one of
them is and how do you do it.
If you are using a frame-by-frame means of creating animation, you have to
draw out each frame of the animation. For this, you should use sheets with
TexturePacker (or Sprite Packer, if you make your game in Unity).
The other way of creating video game animation is called “bone-based.”
When using this type of animation creation, you have to draw each animated
limb, then animate the limb's position and anything else in the game. It can be
faster, easier, and save your computer some memory. If you're designing 2D
and using Unity, try to edit in Anima2D. This is an option for developers,
created to save them some time.
Here are some miscellaneous art tips that apply to not only art in games but in
other software as well. Tile patterned parts to create tiled images and save
memory. Use the “9-patch/9-slice” with un-scalable borders but a scalable
center. This function will enable you to create scalable images and save
memory. Make the dimensions of each part a multiple of 4 or a power of 2 to
save memory. Choosing which one depends on how you're compressing the
assets.
If you're using Photoshop, first you have to open the dropdown menu called
“File”. In this menu, you should select the option “Export” and then, from the
next dropdown menu you choose where to export (“Export to files”). By
using this combination of functions, you can quickly export each layer as a
file (e.g. PNG, JPEG, or any other file type you want).
After you take care of the art, design, and story you may proceed to code.
Your first steps in coding? Well, that will be no problem. Select the game
engine and an IDE (Integrated Development Environment, or, an app that lets
you code).
These basics should be enough to start. (All code examples here are in C++,
one of the main languages the Unity 3D game development framework uses.)
1) Data types and variables. At the root of every code is the data. That data is
stored in variables. You can declare a variable like this: int i = 0;
Explanation: int is the data type. i is the name for a particular variable. And
that = 0 assigns zero as the variable value. Some common data types: “int”
and “long” are integers, while the functions “float” and “double” are decimal
numbers. And the string represents a sentence. (Even an empty one — " "!)
I hope to have explained better through this example. Next steps will be
explained also through practical example since I find it more useful for
readers, adults and kids alike.
If statements. If statements evaluate whether a certain condition is true. If it
is, run the code that's inside the if statement:
if (true){ //true is always true!
Basic data structures. So, we have data, and we also have ways to evaluate
and manipulate that data. We can also store that data into some structure — a
data structure. Some data structures you should be aware of are arrays, lists,
queues, stacks, and sets.
If you do something wrong in your code, an exception might appear. They
look like angry red errors there to tell you that you have made a mistake
somewhere along the coding line.
Then, there are other things you should know when making your very first
and very own video game.
What language are you going to code in? C++? JavaScript? C#? Every
language is written somewhat differently and can let you do different things.
My advice is to get acquainted with the language you intend to write in
before proceeding with coding your game. It will make things much easier
for you, with fewer disappointments and mistakes along the way.
The API (Application Programming Interface). Once you know the basics,
you'll have to learn the specific API of your game engine. Application
Programming Interfaces are essentially a bunch of powerful tools wrapped in
simple classes and functions that you can use in whatever way you want.
Application Programming Interfaces make life easier when coding games. It
is a set of functions that enable you to do more things at once or connect the
things you have already created into one whole.
Consider checking out an example project in your chosen game engine.
Unreal and Unity both have a lot of free example projects you can use to
essentially practice coding video games. This will let you discover how
everything comes together to make a game. Plus, you can create your idea for
the game after reviewing the example projects.
Coding looks scary at first to most beginners. When you look at it nothing
makes sense, you see everything as a problem you may not overcome.
Coding can be challenging. It's understandable to feel insecure at first. So,
let’s try to make a 2D game using Java.
First, you have to know what the board is. The board is a panel where the
game takes place. When you code it the right way, using the correct syntax of
your chosen programming language, you can enter the rest of the elements of
your game. This is a great opportunity for you to get creative and let your
imagination do the rest. I am not explaining every element of the code here,
as we have already reviewed them in the previous chapter where we
discussed some of the programming languages, Java included.
It is hard to learn. Hard, but very useful for you at any stage of your life. It
just takes time, like any other skill. Later on, if you find that you are good at
writing and making video games, it can be a great source of income, and an
option for additional profit, later in life. So, have fun and learn, it might pay
out well someday. Some of us start coding for fun but end up choosing a
career in computer science. Those among us who do so are usually very good
at what they do. Creating video games for a living sounds more like fun than
a "real" job, and many people tend to look at video game creators and
developers as if they do not work at all, or as eccentric people who are unable
to settle down and be serious about their choice of career. This is a common
mistake people make. Video game creators are creative people, but they are
also scientists. Anyone who wants to create a video game that people will
like and play has to learn a bunch of things before they embark on their fun
game-creation project.
A Calendar
A calendar is a very effective tool that enables us to keep track of dates and to
plan our activities accordingly. In this day and age, where life is much faster,
and nearly everything functions "on one click," it is important for us to get
the information on dates and our plans for certain days fast--even instantly. It
is also important for us to be able to carry our date planner with us.
In days past, large-sized wall or table calendars were used. This was good for
visibility but not entirely practical, as we had to search for the desired date on
a large sheet, and it took time. Furthermore, we couldn't take this large sheet
or piece of paper everywhere with us. Getting the information we needed in
this manner was definitely not efficient. There was always a chance that the
sheet could destroyed by a spilled drink or lost for some reason, and, with it,
our plans and daily tasks would soon be forgotten, lost in the mountain of
information we operate with on a daily basis.
So, when everything started digitizing--when tablets, iPhones laptop
computers, and Android platforms appeared in our daily life--things got much
easier. Today, we cannot imagine a phone or a computer without calendars as
an integral part of each one of them. We process a lot of information daily,
and it is impossible to keep track of it all without somehow memorizing it.
Now, instead of having to commit things to memory ourselves, we can use
our computers and mobile devices to memorize the data for us. That really
makes things easier. We carry lots of data in our mobile devices, and date
planners and calendars are among them. Today even small children have
iPhones, tablets, and computers, so they can learn from an early age how to
keep track of their plans and to keep track of their daily schedule, to keep
tabs on what they have planned for a certain day. In childhood, we learn basic
skills that will guide us and be useful in our adult lives, so, as kids, we have
to learn to plan our time efficiently, to sort through all the information to find
the tidbit we need. And all of this is done in a very short time, in a matter of
minutes.
That is why the calendar apps are made - to help us carry and sort through the
information in the search for the precise piece of data we need. In a
technological race, this world found it involved in, it is a matter of prestige to
create ever more advanced software for tracking time and carrying our date
plans and to-do-lists everywhere we go.
As previously discussed, if we want to make anything having to do with
technology and computers, we have to have a certain level of knowledge of
coding, programming languages and their syntax. That is the way
applications and programs are made. In creating a new, advanced calendar
app we may add new options and functions to it, so we may carry more
information wherever we go.
How is that done? Calendar apps can be designed as simple or complex. That
depends on what we need. Before we start, it would be best to put our ideas
on a piece of paper and create sketches of how we want our app to look. This
will help us visualize our idea and make our task easier. Sketching out ideas
can help you find the best solutions to your existing problems related to
coding, and deliver the best experience to end users, both yourself and
whoever you may choose to make your app available to.
User interface (also known as the UI) sketching is so easy and yet, it can also
be very effective. It advises and instructs us to sketch out the basics of a user
interface before we get into the steps like wireframing, prototyping and
coding. UI sketching comes right after you have had the idea to create an
application or a website, and before the building of screen mockups with the
use of a wireframing tool. The UI or the user interface sketch is the first step
towards understanding (and solving) the issue at hand. A UI sketch should
simply be there to help you eliminate bad ideas and think of all those good
ideas about how to bring your proposed end product onto the screen. The
sketch should help you translate your idea to interface in the shortest time
possible.
The first step on your way towards making an effective UI sketch is to focus
on your ideas. Go through as many ideas and iterations as you can. It doesn't
matter if they are not great ideas, and it doesn't matter if your sketches are
unfinished and still “muddy.” Just figure out the best way to approach the
design within the project’s context. Sketching is about communication, not
aesthetics. You are communicating your solution to an issue in its basic,
initial form. A UI sketch actually means that you worked through all the
possible ways you could translate your idea in interface form. It gives you a
chance to play with all the possible outcomes freely and to think about how
to get your user from point A to point B. For children learning to use this
platform, it enhances their imagination and helps them get creative, and this
is good for them, not just in terms of programming and coding, but for their
other activities in life, as well.
After you have made some sketches, the next step in building a calendar app
is wireframing. A wireframe is one step beyond a basic sketch. In a
wireframe, you start thinking about the placement of UI elements, their
hierarchy, and size (although you are still not ‘designing' at this stage, at least
not in the common sense of the word). You will easily be able to see the
difference between a UI sketch and a static wireframe. A UI sketch should
have a real handmade feeling, while a wireframe is made up of greyscale
elements not visible to everyone.
After you have made some sketches, create a new mobile prototype in
Justinmind. When making a calendar app using Justinmind, you should read
the instructions given in their beginner's guide. There, all the initial steps are
well explained. You can choose the iPad, iPhone or Android from the
selection of devices. You'll be able to use a range of pre-built widgets, so
your prototyping should go very smoothly once it is underway.
When making a calendar app using Justinmind, you will need to use so-called
"dynamic panels." How do we use them? Here is an explanation: The first
thing for you to do is to drag a dynamic panel onto your canvas (in this case
your “canvas” is actually an empty text editor or working screen), ensuring
that it takes up enough space to fit one calendar month comfortably on the
screen. Within this panel, you have to add a table widget in which you will
later put the numbers of the days of the month and the month's name. After
this is done, replicate this process for each month of the year, or each month
during the period you are making this app for. Use a text widget for any copy
you are using and style it as you wish using the options given to you in the
Properties palette.
Next, inside every month, you can place an arrow widget so users know they
can switch between the months. Regarding the arrows, you want to use the
"Change Panel Event" so that when the user clicks on the arrow to go from
January to February, the dynamic panel changes following that action. Under
the main set of dynamic panels, you can also put another set of dynamic
panels, one of your own, perhaps. This is where you will put the information
relating to any entries in the calendar.
Calendars are great. They keep us organized and help keep track of your
daily plans and to-do-lists. So, if you don't find what you're looking for
elsewhere, take the initiative and make one of your very own.
One of the most popular new platforms that can be useful for creating a
calendar (and many other things, as well) is Ruby on Rails. This platform