Hello, and welcome.
Let's talk about the c programming language.
We can finally start learning a little bit about c.
I want to provide overview and give you a little idea of how c came about.
So c is a general purpose imperative programming language.
It supports structured programming.
Now we talked about higher level languages and we described how
c is a higher level programming language, this just means that it's
easier and more efficient to use than writing an assembly language,
understanding instruction sets.
Specifically though, it's very general purpose and what this means is you
can write all sorts of applications in the c programming language.
Some programming languages are very application-specific
or domain-specific.
So for example in a programming language like cobalt, you
can really only use the right business applications.
A programming like matlab or a tool like matlab, you can only
write certain applications.
C, you can write operating system applications, you can
write general programs, all sorts of different types.
It's also an imperative for computer programming language,
which means that it's basically organized around statements,
variables, things like that.
If you were to study computer programming in more detail, you
would see that there are different types of programming languages,
things like functional programming languages or logic programming
languages, where that just means that the programming language
is organized a bit differently.
For example, like logic programming languages just have a set of
predicates and ask questions.
C is imperative, a set of statements, explaining what to do.
So you're going to use these statements.
You're going to write this line of code in your program.
And essentially, what it's going to do is it's going to change the state
of the code or the state of the data.
It's going to focus on how to get things done and you're going
to be creating variables and data and memory and algorithms
and using statements to do this.
It's one of the most widely used programming languages of all
time, and that's just a fact.
And that's one of the great reasons to learn it is because it's used
on so many different applications and so much different code.
It's been around quite a while as well.
It's a modern language.
And what I mean by this is it uses most of the basic control
structures and these are things like conditional statements, if statements
and features of modern languages.
So it has functions, it has variables, all this nice stuff
that most modern languages employ.
It's designed for top-down planning, which means you can start right at
the top and go down when you plan.
So you can start at the user interface level and then you can
go down to the lower level and actually implement lower level code.
It's organized around the use of functions.
So for you math people out there that that understand what
a function or module design is, this is pretty basic.
But functions are a way to organize your code.
We're going to give a lot of examples on functions in module design.
It's not important to understand this right now, but you should understand
that at a high level, c is going to be organized around this concept.
And it's very reliable and very readable.
Reliable means that when you write the code, it's going
to do what you tell it to do.
It's not going to just crash for no reason.
And readable means that when you look at it and you look at the source
code and the statements that you can kind of understand what's going
on if you understand the language.
You don't have to kind of guess and say what are they
trying to do here, what does that mean or it's not complex.
It's very easy to read to understand a c program when you see it and
after you understand the language.
It's used on everything from many computers, different
operating systems, mainframes.
Like I said, it's widely used, so very useful to learn.
It's the preferred language for producing word processing programs,
spreadsheets and compilers.
A lot of compilers are written in c.
We understood what the term compiler mean from our last lecture.
This is reminder, this is what takes the source code and translate
it to those that instruction sets.
So you can actually write a compiler, which is just a program
in the c language, very nice.
It has become very popular for programming embedded systems.
Embedded systems are things like microprocessors, found in
automobiles, cameras, DVD players.
Embedded has the the program has to be efficient.
It's running on not as much memory, not as much high level hardware.
So embedded is real time programming.
And it's become quite popular in that because it is so efficient.
It also continues to play a strong role in the development of Linux.
And when I talk a little about the history of c, you're going
to you're going to notice why.
But Linux is a very popular operating system for those of you not familiar.
It's similar to windows.
It's just a different way to interact with your computer.
It's used a lot.
It's the basis for the mac operating system, Macintosh.
And c has a big role in the writing of that operating system.
So again another important reason why you want to learn this language.
I mentioned earlier c programs are high level.
And that means they're more or less easy to modify and easy to adapt new
models or languages, another benefit.
In the 1990s, many software houses began turning to the c++ language
for large programming projects.
Now you may ask yourself why does that matter.
We're learning c, not c++.
Well, the reason that matters is because c is a subset of c++.
I told you, it's organized around functions, module design.
C++ is always around this terms of objects.
We're not going to study objects in this class.
But the reason I'm mentioning c++ is because if you learn c, you're
going to know a lot about c++.
And c++ is another really popular language.
So any c program that you write is going to be a valid program in c++.
So it's going to be great.
If you ever want to move on and you want to learn c++, you're
already going to know half the language because you're going
to know c, so very important.
C is a subset of c++.
C remains a core skill needed by corporations and it always ranks
in the top 10 of desired skills.
Again, another reason to learn it.
I use c every day at my job.
I work at Xerox.
I use it every day.
We program on Linux operating system and we write c applications and
we also write c++ applications.
It's not an old language.
It's never used anymore.
It's used quite a bit.
So if you sit in there thinking I don't want to waste my time
with c, I want to go learn something new and interesting
ruby or some even something even newer like go or something.
C is still popular and still widely used and still a skill that's
required by many, many industries.
So by learning c, you're going to have a very marketable resume.
You're going to be able to get a lot of different positions.
C provides constructs that map efficiently to typical
machine instructions.
So we talked about this idea of a compiler and machine instructions
are at the lowest level.
Because this mapping is so easy in c, it's often used by
programs that were previously implemented in assembly language.
And also for this reason it also is very easy to write operating
system or embedded programs, like I mentioned for this reason.
So it provides low level access to memory and it has many low level
capabilities, it can directly interact with hardware a lot of drivers.
Drivers are programs that interact with hardware, a lot
of drivers are written in c.
And it requires minimal runtime support.
And the reason for this again is because it easily maps
to assembly instructions.
Now a little history about c is it's an older language.
It was invented in 1972 by a guy named Dennis Ritchie of Bell Laboratories.
He was working on the UNIX operating system, which is a precursor to Linux.
It's basically an operating system that's running on different
hardware, Linux runs on PC hardware.
So it's older which is an advantage.
You think it may be a disadvantage, but it's older.
So it's been tried and tested it's reliable.
It was created as a tool for working programmers.
The main goal when designing a language was for it to
be useful, and for it to be easily readable and writable.
I mentioned readability is basically looking at the program and being
understand what's going on quickly.
So it's not that complex.
Writeability is being able to write the code quickly, efficiently,
be able to do things quickly.
So if you were to write some code, you don't have to write 20
lines of code to add two numbers, you write one line of code.
It's very easy to write.
So readability and writeability are important goals and important
advantages of programming languages and c easily meets this.
Some more history.
It initially became widely known as the development language
of Unix operating system.
And virtually, all the new operating systems that were in
written after 1972 are written in c or c++.
Again, very popular, very, very useful.
It evolved from a previous programming language named
B, that's why it's named c.
I guess they didn't weren't very clever.
They just said hey a b, b c.
There's also a language called d, by the way.
It uses many of the important concepts of b while adding some data
typing and other powerful features.
You might not have a clue what data typing is, don't
worry about that right now.
Know that it added some new features from b, mainly b
had this issue of typeless meaning data didn't have types.
And c improved upon that.
It's also available for most computers.
So this is an advantage meaning that if you want to write a c program,
you can write it on most operating systems, you can write it windows,
you can write it on a mac, you can write it on a Linux operating system.
And it's also hardware independent.
Another important factor when writing code.
If it's hardware independent that means it's more portable.
What that means is you can take the program, you can run it on
a different operating system.
So available for most computers means that you can write a c program,
it doesn't have something that's going to work unless it's portable.
So by being hardware independent means it may work on many other systems.
So by the late 1970, c had evolved into what is now
referred to as a traditional c.
This is what you're going to see in this class, traditional c.
The rapid expansion of c working on many different hardware
platforms led to many variations.
So I want to talk a little bit about the different variations of c and what
this really means is there's different standards, so just like there's a
windows 10, a windows a and windows 7.
There's different versions of c.
There's a C89, C90, C99 and C11.
And this basically represents the years, 1989, 1990, 1999 and 2011.
So they're standard versions of c.
A program written only in standard c and without any hardware dependent
assumptions will run correctly on any platform with a standard c compiler.
It's always important to have standards.
So what we're really just saying here is there used to be many
different variations of c.
And we started standardized in 1989.
And by standardizing, we can now run it basically anywhere.
We don't have, hey, Microsoft is going to release their version of c.
Google's going to release their version of c, we don't
have that problem anymore.
We standardized it.
If you have non-standard version c, it might not work on different operating
systems or different devices.
So standardization is important.
I mentioned this because I want to tell you what standard we're
going to focus on and tell you a little bit about the standards.
C89 is the first standard.
1989 it's supported by almost all the c compilers.
Most of the code you see out there today written in c is based on
C89, it has the basic constructs.
And so each standard may have new features of the language
and so forth, that's another reason that it's important.
But C89 since it's the oldest, it's the most widely used.
C99 was a a little revision where it expanded on some of the functionality
you see some of the capabilities.
It hasn't been widely adopted, and not all the compilers support it,
but we'll be focusing on mainly C99.
So the current standard is commonly referred to as C11, 2011, not
used as much, but it does have much a lot of cool features, a
lot of awesome different things.
We'll talk about all three standards, but we'll focus on C99.
And just describe a little the c lab compiler may not implement all the
language features mandated by the standard, that happens sometimes.
But we'll base our examples and concepts of c all three
standards, focus on newer concepts in C11 but mainly C99
which is the basic concepts.
So I mentioned this before, but again I want to reiterate.
For all the reasons I mentioned so far, this is why c is so important.
This is why it's important to learn and this is why it's popular.
And the reason for this is because people like it, it's
easy to write easily to read.
And as we mentioned earlier, Dennis Ritchie's goal was to
have it be used by developers, it's a developer language.
So in the past decade or two, you may have moved from c to
languages such as c++ objective c in java, but c is still important.
And again, I'm beating this to death but it is important.
By learning c, you can easily migrate to these other languages as well.
So for all these reasons, this is why you want to learn c.
A basic introduction, a little bit about the standards, a little
bit about the history and now we'll dive into more details
of the programming language.
Thank you.