Hello and welcome back.
In this lecture, I want to talk about some further
topics that you can study.
We're basically winding up the class.
We're wrapping it up.
And so we didn't get to cover everything.
Obviously, it's a beginner class.
So there are a lot of advanced topics that you can further study
for c to really, really become awesome at c programming, and I just
wanted to mention a couple of those.
So first off, we didn't get into typedefs.
I would have liked to have talked about that, but it is
more of an advanced concept.
We talked about enums.
And enum is a way of creating your own type.
But specifically in c, there's a keyword called typedef and you
can create your own data types.
This is very useful, more of an advanced concept.
You could definitely learn more about that.
There's a lot more information on the preprocessor that you can learn about,
specifically string concatenation.
The preprocessor remember that runs before the compiler.
We learned about the defined statement.
We learned about a couple other things here and there, but the preprocessor
can be a whole other section with a lot more information on it.
You can use it basically to optimize a lot of your code, so
that you can run it beforehand.
You can do inline functions that run in the preprocessor,
all bunch of nice concepts.
There's a lot more on void stars.
Void stars, remember, a lot of flexibility.
In particular, the malloc function returns a void star.
We could create functions take void pointers and pass the void pointers
around to make it more flexible.
There's a lot more we can study on that.
Static libraries and shared objects.
We didn't talk about this concept of a library.
We use libraries when we link.
Specifically, a lot of the libraries are defined in
the c standard libraries.
But you can create your own libraries.
We created programs.
Programs are processes that run in memory.
But libraries are actually other code that you can reuse in other programs.
So example, the c standard library.
If you've programmed in other languages, usually, they're APIs
that come with the language.
There's two types of libraries that you can create.
You can create a static library where you compile
all that code when you link.
And then you can also create a shared object where during the execution
of the program, you're going to look up functions and invoke them.
So static libraries are usually ended in a dot a and they get compiled in
at static time or they get compiled in when you compile the program.
Shared objects are dot so files or they're also you can kind of
think of them as dlls if you've ever heard of dynamically link
libraries and visual c plus plus.
But the shared objects are not compile time.
Again, it's a way to reuse code.
We could study these concepts and I could show you how to build static
libraries as well as shared objects.
Macros.
We didn't get the chance to talk about a macro.
This is an advanced topic.
This gets run by the preprocessor to mainly do substitution,
string substitution.
Some of the functions that we studied are actually written as
macros, like the assert macro.
Macros can be explored in much more detail.
Unions.
Unions will usually go along with structs.
It's a way to have multiple different types of data returned or different
types of member elements inside of a struct that represent the same thing.
So you could have a structure that has one member, but that
member can be an enter a float and you would use union to do that.
Other topics function pointers.
We talked about character pointers mainly, and even integer
pointers and double pointers.
But you can actually have pointers that point to various functions.
So as your program is running, you can execute one function.
And then the next time it runs, it could execute a different
function based on user input or something like that.
Function pointers are a whole other topic.
Advanced pointers.
There's a lot more to pointers than what we've discussed.
We discussed the basics of pointers, but we could talk about
pointers in much much more detail.
There are actual pointers to pointers, so there's double pointers, and
that is a more advanced top topic.
Variable arguments to functions.
These are referred to as variatic functions.
We use the printf function that has a variable number of
arguments, but we didn't define any functions that we had variable
number of arguments, we could explore that concept very useful.
Dynamic linking.
This is when you open up a library at time and it's a little
different than a shared object.
You can open up libraries at runtime and it increases
performance and it makes your executable programs smaller.
So dlm open there's an actual library call to do this.
Signals, forking inter-process communication.
This can all be explored inter-process communication is when you have two
programs they want to communicate.
There's a different ways that they can communicate.
They can communicate via files.
They can communicate via something called a socket.
They can communicate by using piping.
There's different techniques out there, but it's when two processes
want to talk to each other.
Forking is where you can create another process.
There's libraries to create other processes in your code.
If you were to create another process in your code, it would
have its own address memory space and it can make your program
a little bit more efficient.
And then signals, we didn't get into a lot of, but signals are used to for
debugging into generating different messages to different programs.
Threading and concurrency.
Another advanced topic that you want to study.
This allows multiple execution points inside your program.
It allows you to run code almost at the same time.
So it's an efficiency type thing.
If you have a long running task that you need to do in your program such
as monitoring data or waiting for data or maybe your task is reading
a huge file, you can create another thread to do that and then still
execute other parts of your program in conjunction at the same time.
Sockets.
Sockets are used for networking.
Sockets would be used if you wanted to connect to another computer and
get data from that other computer.
Networking is very very big because we have the internet and everything else.
So you can learn all about sockets and see as well.
There's two functions called setjump and longjump.
That's for restoring state.
We could study those in good detail more on memory
management and fragmentation.
This isn't just about malloc, but this is how you can manage your memory
and put it on the heap or the stack.
You can make sure that your program is a little more efficient, so you
don't have as much fragmentation.
Fragmentation is where you have memory in different locations, and it's not
sequential so it may be harder to take more time to look up that memory.
You can reduce fragmentation.
We can work on making the programs more portable.
In general, c programs are pretty portable.
But there are more techniques that you can utilize to make sure that when
you write your program once, it runs on many different operating systems
and you don't have to rewrite it.
We could essentially use some of the posix standards
that are available in c.
We can make sure that depending on what different version
of the c standard, that they work in multiple standards
by using certain conventions.
We could also write programs that directly interface with the kernel.
Remember, the kernel is the brains of the operating system.
The kernel contains all the drivers.
It contains all sorts of calls to lower level memory functions.
It does a lot of different information.
So the kernel has specific functionality where you can
interface with it in your c program.
This would be low level embedded stuff.
So we could use calls like IO controls.
We could create drivers to talk with hardware directly.
There's a lot more on the compiler and different flags that you
can pass to the compiler or the linker, which again makes
your program more efficient.
We didn't get a chance to talk a lot about a lot of
different various flags.
We mainly talked about the dash wall and some other basic ones,
but nothing more advanced.
We talked about the debugger and how to debug applications.
The debugger in code blocks was through the graphical user interface.
But the real advantage of a debugger is under the hood it uses gdb.
Gdb is the gnu debugger.
And we only talked about breakpoints and using it through the graphic
user interface, but you can actually do a ton more with gdb.
We could go through the gdb debugger from the console issue different
commands, do a lot more with the core file understanding how to
read the core file using gdb, a lot of nice advanced topics there.
Profiling and tracing tools.
We didn't get to talk about some static analyzers, some tools that
can analyze your code before you run your program to see if there's
any any dead code or if there's any bad programming practices.
And then tracing tools as well, s trace, d trace, g profile, those
are all important tools you can use to see to help you debug and
help you measure efficiency or how much memory you're using or
the performance of your program.
There's other additional memory debugging tools, such as valgrind.
This helps when you have like race conditions or you have
memory corruption problems.
A lot of times when you're managing your memory and you have buffer
overflows or memory leaks, it's very very hard to find those.
So there's tools out there that can help you find those such as valgrind.
And so there's a lot of different topics that you can explore
to become an expert in c.
We touched on the basics.
We touched on the really, really important stuff to get started.
But with these additional topics, you can become an expert.
Thank you.