Dang dude, I work as a software engineer writing fpga NIC drivers in C and I gotta say your content is legit. I have not seen any other content like yours, keep it up!
love these videos. advice is gold. 0:59 Don't jump straight into coding 4:04 Tip: Do the hardest things first 4:39 1) Create a git repo (or any version control) 5:24 2) Setup build system (e.g. makefile) 6:05 Example makefile 8:54 Why a build system is important 10:32 Automate anything repetitive My own requests / suggestions / ideas for videos: - How do you organize header files / source code when working on medium to larger projects? - What is your philosophy around commenting your code? - How do you think about having the "right" data structure for a project? - How do you write tests for projects? - How do you "jump into" a larger code base and start to slowly understand / contribute code? - What are common anti-patterns you see in C that students (or those new to C) often make? - What are some best practices for working in a team (e.g. how long do you struggle with a problem before asking for help, how do you ask for help, etc.)? - Things we can easily implement to make our C code more secure? Thanks!
Ok. I'll see what I can do. I'll have to be a little careful, since that's something I do as an assignment/project in my operating systems class. But, I'll see what I can do without giving them too much help. 🤔
Related: Directory structure. Separate dirs for debug and release builds. I have worked on years-old production code lacking these - very painful and inefficient.
As a developer for longer than I care to admit, I completely agree. I also carry around a Perl script (which predates cmake) that creates the Makefile for me from a directory full of source code. I also carry around a unit-test framework to formalize the unit-test which is probably the best way to ferret out bugs long term (with a Perl scrip that takes a .h file and generates a unit-test skeleton .h/.cpp files)
i always write shell script to build & test stuff cuz i dont wanna learn make lol. i use './b' for building and './c' for testing, and for building + testing it's './bc'. the thing is that u just use whatever ur most comfortable with
I wish there was more people like you doing this kind of videos, helped me a lot as an emb dev. I got a question, tho: as most (if not all) the IDEs I've used make and compile your files automatically, what are the advantages of doing it manually? I've personally never had any problems with the automatic approach for my projects (adding 10+ custom drivers/files and counting), but I'm still curious about this method. Again, thank you for your good work and keep it up!
If you don't use an IDE you'll need to know how, and if you change IDE's you may have to reconfigure things and knowing how it's done at a basic level can make it easier to finagle IDE settings.
I have a tip: I reasently created a set of functions in my .zshrc that allows me to automatically create new projects, or jump in to an existing one. The function that creates a new project initializes git, copies an appropriate makefile (I have one per programming language that I want to use) creates a README file and forces me to write an initial commit message. This saves me a ton of time when I want to start a new project and allows me to standardize things.
Dear Jacob Sorber, I would add some extra steps: a) Write unit tests just inside the code. Use Test Driven Development (TDD). b) Install locally Jenkins build server and maintain "on the float" different builds simultaneously c) For MCU project implement Bash-like UART console to launch unit tests, diagnostic and manual device control d) Implement bootloader for MCU device Regards, AB
I'm currently a Python dev coming into a complex C/C++ project. I have taken many C++ classes back in college, however, none of them prepared me to handle this project like your videos did. It's still hard going, but this made the experience a little less painful
Awesome video. I wish I had seen this when I was in school. lol I remember completing an assignment, printing out the hard copy source listing to turn in, and after I had the hard copy, I DELETED the source files. Fortunately, I didn't need to make any changes because if I did, I would have needed to re-type EVERYTHING from the printed copy. lol *sigh* Thanks for posting this very valuable advice!!!!!
Hi Dr. Sorber I was wondering if you could consider making a future video about more advanced Makefiles? In a recent project I was attempting to create separate src and obj directories but I couldn't figure out how to write the proper make rules. I desperately tried looking through make's documentation, RUclips, and other sites to no avail so I ended up with a less than ideal solution where I run a mv command to move my objects to my obj directory.
I think it would be great if he did an advanced make video. In the mean time however, I'm not sure which documentation you've already checked, but if you aren't already aware, "info make" will provide much more detailed documentation for make than the man page does, and it should provide detailed examples for what it sounds like you are trying to achieve. You might check there if you haven't already. The GNU website also has a lot of documentation as well, though there you have to hunt for it. Also, both No Starch Press and O'Reilly have entire books dedicated just for make, which are both great resources for learning make as well. I seem to recall one of them was free from the publisher, and I believe it's the one from O'Reilly, but don't quote me on that. But if I am correctly understanding what you are trying to achieve, it sounds like you probably just need to include the folder in the name ./src/source.c and ./obj/foo, or use ../obj/foo if you are trying to use the makefile from src. You can also use multiple makefiles, one in each directory, called from a main makefile and there are detailed examples for that in the make info page, for that as well, if that's what you're trying to do.
@@nunyobiznez875 wow I did not expect a response like this but thank you so much! But to answer your question I read through the man page and skimmed through the online manual, unfortunately I couldn't understand, but maybe I will now? Nonetheless, thank you so much for pointing me towards some resources! I really appreciate it :)
@@jacobkoziej Glad to help, and yes, I think you'll find the info page much more helpful than the man page. Also, it is the O'Reilly book that's free. It's called Managing Projects with GNU Make. It's under the GNU free documentation license and is available to read on the oreilly website, though you may need to google it, as it's hard to find there. They want to sell you the paper copy lol.
I NEVER ATTEMPTED TO LEARN MAKE ^^ Visual Studio just does everything for me xD my make is pressing F5. Mental Energy is limited thats for sure Mark Twain is right
Really great video to level up but sir it wluld have been better if you could explain it in short the setup of the makefile as it isn't able to recognise the path and the keyword
For C++ projects, I use CMake with an out-of-source build (source is in ~/src/foo/, binary is in ~/build/foo/bar where bar is the build type). How do you set up a Haskell project?
There's nothing to prevent you from doing that with `make`. Both the out-of-source build and using Haskell. Give it a try by adding to the Makefile, have it `mkdir build` and add build/ before the output "file name".
Definitely. Great tip. Or just make a template empty project and copy it over. You can usually make one that will work with minor tweaks for most small-to-medium sized projects.
Wait, the mistakes you mention are actually common? Damn, I guess I chose really decent workshops and courses then, because I was taught to do things (almost?) exactly the way you teach. Even when I was still using Windows, I cd'd into my projects folder, created a folder for a new project, set up a repository and run my code editor from that folder, and then when I got tired of coding I'd add changes, commit and push them to the respective repo. I honestly thought that was how everyone does this.
Little personal experience: I started a project a year ago that was supposed to be a pet project... The original cmake system I designed was very shoddy. Ling story short, had to spend the last 2 weeks revising the thing to make it compatible with multiple external libraries and languages (Fortran and c++). Now the whole thing is a template in a git repo that 8 just reuse every time I start a new project :) incidentally, mind doing a series on CMake? The documentation is confusing AF, but I think it's a great solution for gigantic and complex projects.
my junior design project desperately needed a git repo but i just didn’t have the experience that i have now. it would have saved me a ton of time with getting features done. i knew about git repos and i tried to set one up. but after i was like what now lol
I agree with your advice but I wouldn't bother to write the makefiles myself and use CMake instead. I can understand how it makes sense do know how it is done for educational purposes but I really like to rely on CMake doing the job better than me for production environments.
I’m coding a queue system simulation and I kinda struggle to understand it because there are too many information about it and it’s really vague to me would you please give some tips, make a video or direct me in a certain website. I would really appreciate that. Thanks in advance
I talked a little bit about it in my recent "Answering your Questions" video. Didn't go super deep, though. Let me know if you want a deeper more nuanced comparison.
Make part reminded me: Which compiler flags are important during compiling .o file and which are used only by linker (obviously all the -l are linker-specific, but i had questions about -g, -W... etc). I was able to find an answer, but not as fast as i'd like and i might have missed something (it all led to compiler manual, in which flags are separated by sections and stage on which certain flags are used is unclear). Also, is it harmful to have more flags than you need (when you have less flags, code won't compile, but do redundant flags change something).
Do you take bad stackexchange code examples and show how to debug the errors and warnings? As a beginner I expect code examples to function and not provide errors or warnings, something I can extend the functionality of. Building on a foundation that someone else has laid is difficult when you can’t identify when the foundation is in need of repairs first. Can you walk through some internet code examples and show how you would diagnose them? I was looking at Programming ascii art in C, I don’t understand the errors and warnings clang is raising.
@@JacobSorber stackoverflow.com/a/8587004 I am looking for a code I can play in. Something that has a basic structure I can alter attributes of while the foundation remains. The code this person contributed is full of errors and incomplete, so is nonfunctional.
Hey Matthew, can you make a vídeo about starting with basics arduino? I have a project in my list that is build a bluetooth rgb light that i can control with my phone, but i really dont know how to even start, any advice? :)
Not sure who Matthew is, but you could check out my embedded systems videos and see if they help. And, of course, let me know what specific topics you think I'm missing.
@@johnkeubler2927 Sure, if they like to use them, they are free to do it. But I think that Rust is a good contender for operating systems. Actually, there already *is* an OS, completely written in Rust. Thing is, that (according to Microsoft) about 70 % of all bugs arise due to memory issues of one form or another. And that is something that simply cannot happen in safe Rust. I don't want to start a religious war, C and C++ are definitely still useful, but Rust is catching up very quickly.
Yes I have seen the articles on os development with rust and it looks pretty cool. The os probably would be better if written in rust. How about Googles Go programming language?? It seems pretty cool too.
@@johnkeubler2927 I haven't really used Go, but to my understanding, it has quite a large runtime and is garbage collected. So it is probably not so good for an OS, even though it's neat for other systems programming cases due to the strong parallelization.
Some programmers dont rely as much on IDEs like visual studio. Preferring instead to use the terminal and a text editor. In this video, he actually is using an IDE (VSCode I think) with an embedded terminal. It is just a matter of what is comfortable and fast for you.
I've talked a bit about this in some of my older videos. In short, I think it's a good thing for beginning programmers to understand what they're actually doing when compiling and linking and debugging - IDEs often hide a lot of that from you, and when you're just getting started that can lead to significant problems in your understanding. Once you know what you're doing, I think it becomes more a matter of preference.
Why did this code fail?? I tried this same code on my phone with Online Compiler using only 1 C file, no linking, etc. and I got the same error. It happens at *p = 45;
Actually I thought about it and came to the same conclusion. To make it work for testing purposes without any real code, i got this to work. // global variable. int a = 2; // function. void *malloc2 (size_t size) { return &a; // return NULL; } // main. int main() { // sizeof(*p) int *p = malloc2(sizeof *p); // int *p = NULL; // p = malloc2(sizeof *p); printf("%p ", p); printf("%d ", *p); *p = 45; printf("%p ", p); printf("%d ", *p); return 0; } // prints out. 0x601030 2 0x601030 45 you can't use malloc() , free() because they are already built-in functions and you get warnings and wierd behavior.
Plz plz answer this question sir.. For passing multidimentional array to function how valid is to use void function(int x, int y, int array[x][y]); This worked fine on my system. I am himanshu sharma from india
paused at 10:32 because that "%.o" is bugging me, that's a REALLY bad thing to do, can't tell you how many times I've done that and regretted it later after spending hours trying to find out why make is trying to compile my makefiles into objects too only to then finally remember "oh right, make adds makefiles into goals against all that is sane" at which point I have to go change my "%.o: %" to "%.c.o: %.c" && "%.cpp.o: %.cpp" all because make recognises "%.o" as special goal instead of just matching it the dependencies given to it, it does not give a flying toss if that will f**k with your output and give you a false negative
love these videos. advice is gold. 0:59 Don't jump straight into coding 4:04 Tip: Do the hardest things first 4:39 1) Create a git repo (or any version control) 5:24 2) Setup build system (e.g. makefile) 6:05 Example makefile 8:54 Why a build system is important 10:32 Automate anything repetitive My own requests / suggestions / ideas for videos: - How do you organize header files / source code when working on medium to larger projects? - What is your philosophy around commenting your code? - How do you think about having the "right" data structure for a project? - How do you write tests for projects? - How do you "jump into" a larger code base and start to slowly understand / contribute code? - What are common anti-patterns you see in C that students (or those new to C) often make? - What are some best practices for working in a team (e.g. how long do you struggle with a problem before asking for help, how do you ask for help, etc.)? - Things we can easily implement to make our C code more secure?
Dang dude, I work as a software engineer writing fpga NIC drivers in C and I gotta say your content is legit. I have not seen any other content like yours, keep it up!
love these videos. advice is gold.
0:59 Don't jump straight into coding
4:04 Tip: Do the hardest things first
4:39 1) Create a git repo (or any version control)
5:24 2) Setup build system (e.g. makefile)
6:05 Example makefile
8:54 Why a build system is important
10:32 Automate anything repetitive
My own requests / suggestions / ideas for videos:
- How do you organize header files / source code when working on medium to larger projects?
- What is your philosophy around commenting your code?
- How do you think about having the "right" data structure for a project?
- How do you write tests for projects?
- How do you "jump into" a larger code base and start to slowly understand / contribute code?
- What are common anti-patterns you see in C that students (or those new to C) often make?
- What are some best practices for working in a team (e.g. how long do you struggle with a problem before asking for help, how do you ask for help, etc.)?
- Things we can easily implement to make our C code more secure?
Thanks!
Great suggestions. Thanks! I'll add them to the list and see what I can do.
@@JacobSorber please put the timestamps in the description for chapter makers :)
4:04 What if you’re french ?
I saw this video after taking a few days setting up CMake, git, all the dependencies before writing anything. Kinda reassuring :D
Glad I could reassure you. Your project setup will get quicker over time.
@artsi0m ; actually I find that cmake is not that bad, meson is a bit painful on windows and most IDEs
I would love to see a video on malloc and free implementation in future :)
Ok. I'll see what I can do. I'll have to be a little careful, since that's something I do as an assignment/project in my operating systems class. But, I'll see what I can do without giving them too much help. 🤔
YES!
Related: Directory structure. Separate dirs for debug and release builds. I have worked on years-old production code lacking these - very painful and inefficient.
I just copy msvc dir structure
Agreed. I guess I need a follow on video that provides a few more steps. Thanks!
@@JacobSorber If you do, please mention cmake.
Just want to say thank you for making these videos! They’re much appreciated :)
My pleasure!
This information is GOLD. Thanks for sharing your advice with the world and the ones of us whom care.
As a developer for longer than I care to admit, I completely agree. I also carry around a Perl script (which predates cmake) that creates the Makefile for me from a directory full of source code. I also carry around a unit-test framework to formalize the unit-test which is probably the best way to ferret out bugs long term (with a Perl scrip that takes a .h file and generates a unit-test skeleton .h/.cpp files)
i always write shell script to build & test stuff cuz i dont wanna learn make lol. i use './b' for building and './c' for testing, and for building + testing it's './bc'. the thing is that u just use whatever ur most comfortable with
I wish there was more people like you doing this kind of videos, helped me a lot as an emb dev.
I got a question, tho: as most (if not all) the IDEs I've used make and compile your files automatically, what are the advantages of doing it manually? I've personally never had any problems with the automatic approach for my projects (adding 10+ custom drivers/files and counting), but I'm still curious about this method.
Again, thank you for your good work and keep it up!
If you don't use an IDE you'll need to know how, and if you change IDE's you may have to reconfigure things and knowing how it's done at a basic level can make it easier to finagle IDE settings.
I have a tip: I reasently created a set of functions in my .zshrc that allows me to automatically create new projects, or jump in to an existing one. The function that creates a new project initializes git, copies an appropriate makefile (I have one per programming language that I want to use) creates a README file and forces me to write an initial commit message. This saves me a ton of time when I want to start a new project and allows me to standardize things.
Cool. Thanks. I do things like this for managing my courses. It's amazing how much time it can save.
Super tips. For anyone starting out, this is a great way to begin. I highly suggest you listen if you are a beginner. See you soon!
Dear Jacob Sorber,
I would add some extra steps:
a) Write unit tests just inside the code. Use Test Driven Development (TDD).
b) Install locally Jenkins build server and maintain "on the float" different builds simultaneously
c) For MCU project implement Bash-like UART console to launch unit tests, diagnostic and manual device control
d) Implement bootloader for MCU device
Regards,
AB
This video will change many lives. Thank You for the quality. 👏 . Remember to commit often!! REmember to Remember
This is great advice. Something that everyone should learn starting out.
right on, I endorse this, however I do those things in opposite order:
1. set up build environment
2. set up repository
Jacob your videos are awesome, thank you so much! Please do find some time to talk about building a custom allocator, that would be very interesting
Another useful think when starting a new project, make test.
Absolutely. Thanks!
I'm currently a Python dev coming into a complex C/C++ project. I have taken many C++ classes back in college, however, none of them prepared me to handle this project like your videos did. It's still hard going, but this made the experience a little less painful
Thanks for letting me know. I'm glad they've been helpful.
I love these videos as a student
Awesome video. I wish I had seen this when I was in school. lol I remember completing an assignment, printing out the hard copy source listing to turn in, and after I had the hard copy, I DELETED the source files. Fortunately, I didn't need to make any changes because if I did, I would have needed to re-type EVERYTHING from the printed copy. lol *sigh* Thanks for posting this very valuable advice!!!!!
Thanks!
Hi Dr. Sorber I was wondering if you could consider making a future video about more advanced Makefiles? In a recent project I was attempting to create separate src and obj directories but I couldn't figure out how to write the proper make rules. I desperately tried looking through make's documentation, RUclips, and other sites to no avail so I ended up with a less than ideal solution where I run a mv command to move my objects to my obj directory.
I think it would be great if he did an advanced make video. In the mean time however, I'm not sure which documentation you've already checked, but if you aren't already aware, "info make" will provide much more detailed documentation for make than the man page does, and it should provide detailed examples for what it sounds like you are trying to achieve. You might check there if you haven't already. The GNU website also has a lot of documentation as well, though there you have to hunt for it. Also, both No Starch Press and O'Reilly have entire books dedicated just for make, which are both great resources for learning make as well. I seem to recall one of them was free from the publisher, and I believe it's the one from O'Reilly, but don't quote me on that.
But if I am correctly understanding what you are trying to achieve, it sounds like you probably just need to include the folder in the name ./src/source.c and ./obj/foo, or use ../obj/foo if you are trying to use the makefile from src. You can also use multiple makefiles, one in each directory, called from a main makefile and there are detailed examples for that in the make info page, for that as well, if that's what you're trying to do.
@@nunyobiznez875 wow I did not expect a response like this but thank you so much! But to answer your question I read through the man page and skimmed through the online manual, unfortunately I couldn't understand, but maybe I will now? Nonetheless, thank you so much for pointing me towards some resources! I really appreciate it :)
@@jacobkoziej Glad to help, and yes, I think you'll find the info page much more helpful than the man page. Also, it is the O'Reilly book that's free. It's called Managing Projects with GNU Make. It's under the GNU free documentation license and is available to read on the oreilly website, though you may need to google it, as it's hard to find there. They want to sell you the paper copy lol.
There are plugging (C/C++) for VSC that allows to build and debug.
Nice tips! That's why Cargo is so awesome
What happens when the crates the cargo is packed in get rusty?
8:40 That's exactly what I keep telling myself.
you just gave me motivation to finish my project off, thanks
Glad to hear it! Good luck.
Great video!
Thanks. Glad you enjoyed it.
I NEVER ATTEMPTED TO LEARN MAKE ^^ Visual Studio just does everything for me xD my make is pressing F5. Mental Energy is limited thats for sure Mark Twain is right
Until the day you need to develop on a Linux platform ;)
All your videos an especially this one, told me to start with make files. And as you said it, it makes your life much easier. ;o)
I like your longer vids keep em coming
Me too. They take longer to edit, which is a problem, but I like being able to dig a bit deeper.
Would be cool to see more on integration between Makefiles and VSCode :)
you should add 'clean' and 'submit' to .PHONY so they get automatically created even if there is a file called 'clean' or 'submit'
I had no idea that's what .PHONY was for, thanks for the tip
Really great video to level up but sir it wluld have been better if you could explain it in short the setup of the makefile as it isn't able to recognise the path and the keyword
For C++ projects, I use CMake with an out-of-source build (source is in ~/src/foo/, binary is in ~/build/foo/bar where bar is the build type).
How do you set up a Haskell project?
There's nothing to prevent you from doing that with `make`. Both the out-of-source build and using Haskell. Give it a try by adding to the Makefile, have it `mkdir build` and add build/ before the output "file name".
Do you have videos about different build systems/configurations/generators and their strengths? Things like meson, cmake, ninja, etc.
Pro tip: eat the frog first and make a utility that creates your makefile, folder structure and version control for you.
Definitely. Great tip. Or just make a template empty project and copy it over. You can usually make one that will work with minor tweaks for most small-to-medium sized projects.
Or use a proper IDE like everyone else
@@maskettaman1488 fuck IDEs. I would like to build stuff and control on my own
@@maskettaman1488 They didn't like what he had to say, because he spoke the truth.
Wait, the mistakes you mention are actually common? Damn, I guess I chose really decent workshops and courses then, because I was taught to do things (almost?) exactly the way you teach. Even when I was still using Windows, I cd'd into my projects folder, created a folder for a new project, set up a repository and run my code editor from that folder, and then when I got tired of coding I'd add changes, commit and push them to the respective repo. I honestly thought that was how everyone does this.
Good tips
Little personal experience: I started a project a year ago that was supposed to be a pet project... The original cmake system I designed was very shoddy. Ling story short, had to spend the last 2 weeks revising the thing to make it compatible with multiple external libraries and languages (Fortran and c++). Now the whole thing is a template in a git repo that 8 just reuse every time I start a new project :) incidentally, mind doing a series on CMake? The documentation is confusing AF, but I think it's a great solution for gigantic and complex projects.
I would LOVE. a video on how to make your own malloc and free PLEASE PLEASE PLEASE
the game programming gems book has one chapter about it, forgot which series. it's a must in console game programming.
Ok. Thanks. I'll see what I can do.
+1, would love it. Thought it would probably be a 2-3 part video.
i am writing my own operating system and i would need to know how to do this too.
Thanks for great video!
Are you goin to make a video how to use cmake, google test?
To summarise... "eat frogs" 🐸
Joke aside, that was really good advices.
my junior design project desperately needed a git repo but i just didn’t have the experience that i have now. it would have saved me a ton of time with getting features done.
i knew about git repos and i tried to set one up.
but after i was like what now lol
I agree with your advice but I wouldn't bother to write the makefiles myself and use CMake instead. I can understand how it makes sense do know how it is done for educational purposes but I really like to rely on CMake doing the job better than me for production environments.
and: out of source builds!
Rumour has it that Jacob's daughter's first words said were Hello World.
I’m coding a queue system simulation and I kinda struggle to understand it because there are too many information about it and it’s really vague to me would you please give some tips, make a video or direct me in a certain website. I would really appreciate that. Thanks in advance
Can you please make a video on clang Vs gcc? This has been bugging me for a while!!!👐👐
I talked a little bit about it in my recent "Answering your Questions" video. Didn't go super deep, though. Let me know if you want a deeper more nuanced comparison.
Cmake + Ninja = ❤️
Heh, nowadays i use git for everything straight from the start. Even on my C64 assembler projects :D
Make part reminded me: Which compiler flags are important during compiling .o file and which are used only by linker (obviously all the -l are linker-specific, but i had questions about -g, -W... etc). I was able to find an answer, but not as fast as i'd like and i might have missed something (it all led to compiler manual, in which flags are separated by sections and stage on which certain flags are used is unclear). Also, is it harmful to have more flags than you need (when you have less flags, code won't compile, but do redundant flags change something).
Hey where can I buy that shirt?
teespring.com/stores/jacob-sorbers-store
Pen and paper so i know where I'm going and what states I need.
Do you take bad stackexchange code examples and show how to debug the errors and warnings?
As a beginner I expect code examples to function and not provide errors or warnings, something I can extend the functionality of. Building on a foundation that someone else has laid is difficult when you can’t identify when the foundation is in need of repairs first.
Can you walk through some internet code examples and show how you would diagnose them?
I was looking at Programming ascii art in C, I don’t understand the errors and warnings clang is raising.
Maybe. Do you mind pointing me at the particular resource you had difficulty with?
@@JacobSorber stackoverflow.com/a/8587004
I am looking for a code I can play in. Something that has a basic structure I can alter attributes of while the foundation remains.
The code this person contributed is full of errors and incomplete, so is nonfunctional.
heavy guy.
Proud to be the 128th like.
2 to the power of 6.
Excellent! Thanks!
Hey Matthew, can you make a vídeo about starting with basics arduino?
I have a project in my list that is build a bluetooth rgb light that i can control with my phone, but i really dont know how to even start, any advice? :)
Not sure who Matthew is, but you could check out my embedded systems videos and see if they help. And, of course, let me know what specific topics you think I'm missing.
I use Rust for my everyday coding, which comes with a build system and version control from the get-go. Why am I even watching this?
Yes, Rust and Cargo are amazing. I thought I loved C++ until I discovered Rust. Now, I would only touch C++ as a last resort.
Yes but some people still like to use C and C++ for fun and it is best for writing operating systems.
@@johnkeubler2927 Sure, if they like to use them, they are free to do it. But I think that Rust is a good contender for operating systems. Actually, there already *is* an OS, completely written in Rust. Thing is, that (according to Microsoft) about 70 % of all bugs arise due to memory issues of one form or another. And that is something that simply cannot happen in safe Rust. I don't want to start a religious war, C and C++ are definitely still useful, but Rust is catching up very quickly.
Yes I have seen the articles on os development with rust and it looks pretty cool. The os probably would be better if written in rust. How about Googles Go programming language?? It seems pretty cool too.
@@johnkeubler2927 I haven't really used Go, but to my understanding, it has quite a large runtime and is garbage collected. So it is probably not so good for an OS, even though it's neat for other systems programming cases due to the strong parallelization.
Why do people run code through a terminal? Like in visual studios all i need to do is hit run, but Ive seen many people on youtube using a terminal?
Some programmers dont rely as much on IDEs like visual studio. Preferring instead to use the terminal and a text editor.
In this video, he actually is using an IDE (VSCode I think) with an embedded terminal.
It is just a matter of what is comfortable and fast for you.
I've talked a bit about this in some of my older videos. In short, I think it's a good thing for beginning programmers to understand what they're actually doing when compiling and linking and debugging - IDEs often hide a lot of that from you, and when you're just getting started that can lead to significant problems in your understanding. Once you know what you're doing, I think it becomes more a matter of preference.
my 2023 resolution!
struct idea *from_dr_sorber = rethink(how_you_start_projects);
Why did this code fail?? I tried this same code on my phone with Online Compiler using only 1 C file, no linking, etc. and I got the same error. It happens at *p = 45;
Because the malloc function was not implemented so it tries to write 45 to an unallocated page, most likely the NULL address.
Once I thought about it I came to the same conclusion. He still should of mentioned why it failed.
He is assigning the value 45 to an unallocated memory address (NULL in this case)
Hey Jacob Sorber,
Would you please create a discord server?
someone should create a project manager that does all these things automatically
Eat a live frog in the morning, and nothing worse will happen to you for the rest of the day... or to the frog...
Me who codes in python and just makes cli apps: 😔
@artsi0m ; just fine! I made a terminal function to create a new venv with my preferred choice of python version
Actually I thought about it and came to the same conclusion. To make it work for testing purposes without any real code, i got this to work.
// global variable.
int a = 2;
// function.
void *malloc2 (size_t size) {
return &a;
// return NULL;
}
// main.
int main() {
// sizeof(*p)
int *p = malloc2(sizeof *p);
// int *p = NULL;
// p = malloc2(sizeof *p);
printf("%p
", p);
printf("%d
", *p);
*p = 45;
printf("%p
", p);
printf("%d
", *p);
return 0;
}
// prints out.
0x601030
2
0x601030
45
you can't use malloc() , free() because they are already built-in functions and you get warnings and wierd behavior.
Plz plz answer this question sir..
For passing multidimentional array to function how valid is to use
void function(int x, int y, int array[x][y]);
This worked fine on my system.
I am himanshu sharma from india
lol I thought this was obvious
Many things are obvious once you understand them.
first haha
paused at 10:32 because that "%.o" is bugging me, that's a REALLY bad thing to do, can't tell you how many times I've done that and regretted it later after spending hours trying to find out why make is trying to compile my makefiles into objects too only to then finally remember "oh right, make adds makefiles into goals against all that is sane" at which point I have to go change my "%.o: %" to "%.c.o: %.c" && "%.cpp.o: %.cpp" all because make recognises "%.o" as special goal instead of just matching it the dependencies given to it, it does not give a flying toss if that will f**k with your output and give you a false negative
love these videos. advice is gold.
0:59 Don't jump straight into coding
4:04 Tip: Do the hardest things first
4:39 1) Create a git repo (or any version control)
5:24 2) Setup build system (e.g. makefile)
6:05 Example makefile
8:54 Why a build system is important
10:32 Automate anything repetitive
My own requests / suggestions / ideas for videos:
- How do you organize header files / source code when working on medium to larger projects?
- What is your philosophy around commenting your code?
- How do you think about having the "right" data structure for a project?
- How do you write tests for projects?
- How do you "jump into" a larger code base and start to slowly understand / contribute code?
- What are common anti-patterns you see in C that students (or those new to C) often make?
- What are some best practices for working in a team (e.g. how long do you struggle with a problem before asking for help, how do you ask for help, etc.)?
- Things we can easily implement to make our C code more secure?