- In this video, I'd like to refer you to a concept
that I like to call the engineering mindset,
meaning C and other programming languages
are fundamentally tools, designed to solve problems.
Whenever you're looking for a solution to a problem,
you need to have a plan.
You need to have something in mind
before you start writing code.
There is a reason why we are spending some time
in the previous video and this one just talking about C,
reflecting on some issues,
and we're not jumping straight into writing code.
The number one thing you have to take into consideration
before writing a program is you really have to ask yourself
what do you really want that program to do?
Sometimes you write a program because you just feel like it.
Sometimes you write a program
that somebody else asked you to do.
You have to make sure that you really know
what this program will do
and that the language you chose
is the most appropriate for the task.
Second, you need to have a plan.
What are you going to do first?
What will you do second?
And so on.
Writing code, it's not like playing the piano.
You just sit down and improvise and press some keys.
You really need to have a plan.
And before that, you need to have some grand idea
that's the heart of your plan.
Later on in this course, we will talk about formal ways
to plan for writing code, namely about algorithms
and flowcharts and other ideas and tools.
For now, we'll just say,
you need to know what you want to do
before you start doing it.
After you know what the program wants to do,
you can sit down and write your code.
Doing the IDE in this class would be Eclipse.
After the code is written,
there's a process called compilation.
The compiler is the heart of the IDE.
The IDE has many components.
Essentially, what the compiler does,
takes the piece of code that you write,
which is essentially just plain text,
uses another software that analyzes that code,
makes sure that it follows the grammar rules of C,
and converts it into ultimately binary code
that the computer can understand.
What's great about C is that you can type C code
in any editor and then take it onto any machine
that has a C compiler, end the code with run.
This is what we refer to as portability
that was really improved in C11.
Once you run a program, the compiler will let you know
whether it ran without errors or with errors.
Just because a program runs without errors,
it doesn't necessarily mean that it does
what you intended it to do.
So, it requires first a testing on your behalf.
Keep in mind that fixing errors,
it's a daily activity in every programmer's life.
In fact, it is guaranteed that you will spend
more time debugging and fixing errors
than actually planning your next great program.
So, if it's something that you really look forward to do,
then programming is for you.
If you dread being told that you're wrong
every few seconds by a machine
that's not really that friendly,
then you have to do something to overcome that
because there's no greater reward
and satisfactory feeling than fixing a problem
and getting something to work.
Then, right when you thought that everything is done
and your program runs without error, guess what?
You can do it better!
The second most frequent activity you'll be engaging in
after fixing errors is making everything better.
Never be satisfied that the program you created
is the final version of it.
If you spend any amount of time on computers,
you have noticed the frequent updates
from various applications you have.
Whether it's a browser, the word processor,
the spreadsheet, you receive almost daily notifications
of a better, newer version, which means programmers
either spend their time fixing errors
or spend their time doing something better.
And so should you.