This is an excellent educational project. The code is clean and easy to understand. I probably wouldn't actually use it in production, cuz there's no checking for overruns, Etc. But as a way to learn what's actually involved in a web server I haven't seen a better example. I especially liked the binary search/ map
Well, obviously it is not anywhere near ready for being used in production. I just wanted to make this because it's a cool project and I learned a lot from it. I'm still learning and trying to improve on it. Thanks a lot for your support. It really means a lot
@ThatGuyJamal i have been learning rust recently and I have to say that openAI's chatGPT AI is really good at answering programming questions. I can copy paste errors I don't understand there and it will tell me what exactly it means, or I can ask it how to do something and it will provide a code snippet. Honestly has made learning like 5x easier.
Lvl 0 programmer: oh X is the best programming language because of reasons A, B, C Lvl 1 programmer: you should use the best tool for each job and not be dogmatic about any particular programming language Lvl 10 programmer: write it in C anyway lulz
I mean, everything I program is in C because I did not bother to learn another language and have other things to do in my life. Nice to hear that it makes me a lvl 10 programmer in your view though, haha.
That was the first exercise for the course operating systems in my Uni. We built a multithreaded server from scratch in c, utilizing pthreads, signals, sockets, mutual exclusion for the db, and synchronization of the incoming requests using a FIFO queue. One of the best projects actually!
Good programmers choose the right tool for the job. Good programmers use an IDE, because they do understand the importance of using a debugger, so they can check the value of a variable without having to log it to the console, use watches, change values on the fly, debug step by step. Noobs use vim because they think it's cool and they believe programming is about how fast you can write the code because you can keep your hands on the keyboard. Also C in 2022 is a bad choice for anything, included low level programming, where C++ and Rust and Zig are a much better choice. Just a free advice from someone with 25 years of experience in the industry.
@@imraninfrarote in us uni they have networking and db. Indian syllabus has only algorithms and basics. I'm guessing you're Indian from geeksfromgeeks page.
The cool thing will be to get to a point where you can run a performance benchmark against stuff like apache iis and node express. Or even that new rust framework leptos
Pretty nice 🙂It remembers me the old days where we had to create lots of programs using C and C++ and we didn't have a nice editor with all the syntax highlighting and code completion... *sigh* But it was a lot of fun 🙂
If I had to implement route mapping I would suggest using a Trie. It is simpler than a balanced BST, has better time complexity and extending it to support common features like catch all routes (/catch-all/*) and slugs (/products/:slug:/p) is very straightforward.
Great Video! Well if you want to try this again, but with an easier to use API, C has GLib+GIO (spun off from the GTK project) which you can use to write all of this in Pure C. GLib can provide pre-built data structures (yes, it has Hash Maps), and GIO which provide a high level File and Socket API including streams, all in Pure C. (Note, GLib and GIO DOES NOT depend on GTK, you can import them independently).
i worked as a software developer in Embedos Engineering in Mumbai India, here we use to make IOT edge devices with SBC's and Microcontrollers. We used Esp32 and wrote our own code in C from scratch created web servers to achieve 2 way communication between the device and the end user for device configuration and data visualization, can connect to the device once in the same network just get the IP of esp32 it serves html files stored in it (esp32).
This isn't just a learning project. As a backend developer (who loves C/C++ More than any other language) i am about to write my own web server using C++ (i use C++ instead of C just for tge OOP i don't use the STL i hate it) That's because most used web servers are open source and available for everyone, so hackers can download and start pentesting the webserver, potentially detecting an RCE vulnerablitity which puts all servers using this web server at risk. When we write our own PERSONAL web server, we'll avoid all types of server attacks (because our web server isn't available for hackers to pentest) and pentesting requires debugging, analyzing the source code, and so on.... This video is like a push to me to create my own web server that serves files, and execute backend scripts such as python, php, and javascript.
The reduction in penetration testing stops being so valuable when the server is running scripts, because of the increased chance of unsafe inputs slipping into the interpretter.
@@absalomdraconis 100%, That's Why Im Going to mirror user input through multiple input validation bridges inside the server itself before throwing it to the interpreter.
If we were in the old days, we wouldn't be using C as you did but instead through a superserver, like inetd, and you could easily make a server using printf's, read() and write() to stdin/stdout (you could make a webserver with AWK or Shell script like this). Second, if you are already using unix sockets, you can use unix/posix functions, and there's regex in posix c. Fun fact: Even the UNIX "fathers" didn't like sockets (that came from BSD, not UNIX) but their solution was only done in Plan 9 through the /net directory, and they had to reinvent how file system works to make it work (and in the process they created private namespaces, which somehow creeped to linux as mount namespaces, and in linux the mount namespace is as powerful as private namespace of Plan 9, but everyone uses as only a gimick for isolating environments like chroots. This is sad, to be honest...)
The beej network guide is great for this if anyone wants to try or learn it. It's a good overall guide for new people. Now just need to learn parallel/concurrent programming...
In my experience, the best way to learn a programming language (or programming in general) is to simply build stuff with it. It doesn't have to be the next big thing. When I started coding I went nuts and built tons of questionable programs.
Jesus Christ, not only is he writing C code in VIM but he is also using Linux, not any Linux distro, but an RPM based distro. 👏🏾👏🏾👏🏾 a fellow man of culture, Based.
Really So much impressed brother and i myself like C Language and want to make my FYP project in C. The C Language is best for beginners that wants to learn programing. Actually from C or C++ you understand and learn alot of basic concepts of programing which i think most of the programers still dont understand clearly and that is the reason for their poor cpde quality. Looking forward for more informative videos from you :)
Really fun video, mate! I am subscribing! Liked how you forget to regord once and at the begining as you said that you didn't copy the code from the YT tutorial 😂😂
As hard as this may have been, it's crazy how much you can still do with a 50-year-old programming language. Yes, I was also caught off guard when I learned that C is 50 years old.
@@imraninfrarote Honestly, I have been writing that code and maintaining it for a long time, so it wasn't an over night success. Maybe over many nights . 😂
back in the uni, my prof said only an idiot will use C to develop a web server. And that what I also did. I am so glad that I am not the only idiot in this world :D
It only depends on how wide your hashtable is and how much data you have. If your hashmap is N buckets big and you have to make N + 1 entries, guess what? You will have at last 1 collision (or even more) - inevitable! No mater how good your hash function is.
I fought with Javascript for a long time, until I understood it. I don't say I agree with implementation but I think I understand it, funny to see juniors fight with code that should work but it doesn't))
@@imraninfrarote A nightmare? Nah. I've been programming in C for 3 decades, and I prefer it. So do the developers of virtually every other systems developer.
@@yapdog well, I clearly don't have experience like you do. So a huge portion of the time, I'm not even sure what I'm looking for. I will strive to be efficient in systems programming as it is something that truly interests me
@@imraninfrarote Coolness 😎 I'll try to keep up on your progress, but I'm sure I'm sure I'll learn a thing or three along the way. You're never too old to learn something new, right?
It was out of fear for this day that browser developers didn't allow the remote execution of C code.
...so they made an architecture called WebASM that C can compile to.
@@andrewporter1868 Yes
u use vim u alredy have no respect from react komunity
Hello channel deleted, i’m deleted too😅
@@andrewporter1868 XD
This is an excellent educational project. The code is clean and easy to understand. I probably wouldn't actually use it in production, cuz there's no checking for overruns, Etc. But as a way to learn what's actually involved in a web server I haven't seen a better example. I especially liked the binary search/ map
Well, obviously it is not anywhere near ready for being used in production. I just wanted to make this because it's a cool project and I learned a lot from it. I'm still learning and trying to improve on it. Thanks a lot for your support. It really means a lot
@ThatGuyJamal for me, rusts "the book" is a wonderful introduction. Rust as in the language
@ThatGuyJamal i have been learning rust recently and I have to say that openAI's chatGPT AI is really good at answering programming questions. I can copy paste errors I don't understand there and it will tell me what exactly it means, or I can ask it how to do something and it will provide a code snippet. Honestly has made learning like 5x easier.
LGTM!
what is overrunss and why are they bad?
Lvl 0 programmer: oh X is the best programming language because of reasons A, B, C
Lvl 1 programmer: you should use the best tool for each job and not be dogmatic about any particular programming language
Lvl 10 programmer: write it in C anyway lulz
Lvl 69:
Use python for work
Use C and shit on python on yt
I mean, everything I program is in C because I did not bother to learn another language and have other things to do in my life.
Nice to hear that it makes me a lvl 10 programmer in your view though, haha.
@@alefratat4018 that makes you level 0 though.
@@alefratat4018 you act like it takes a REALLY long time to learn a new language. That's definitely not the case, especially if you know c.
@@imraninfrarote pñ
That was the first exercise for the course operating systems in my Uni. We built a multithreaded server from scratch in c, utilizing pthreads, signals, sockets, mutual exclusion for the db, and synchronization of the incoming requests using a FIFO queue. One of the best projects actually!
It's really such an interesting topic to dive into. I mean all the stuff that we (web developers) take for granted, it's just mind boggling.
tell me where you went to college, at mine we didn't go beyond a simple cashier system. xD
@@bryanherreradev8055 I studied computer science and engineering at the university of Ioannina, Greece.
Can you mention the recourses/essential-readings and any other kind of useful materials that were listed in your course descriptor of this module?
Would love to take a read at those materials too if you still have it
For anyone looking to do this in production (I reduced my AWS bill by switching from Python to C/GO), I can recommend Ulfius or libonion
What was there? Web app or just serving static?
By how much (percentage is fine) have you reduced your AWS bill and could you share with us what is your application like at a high level?
For anyone looking to do this in production, I recommend therapy
@@peq42_ Is that library? Or pun intended.
@@peq42_ based
My man using C and Vim? Absolute god-tier programmer. I aspire to be as based as this one day
Good programmers choose the right tool for the job. Good programmers use an IDE, because they do understand the importance of using a debugger, so they can check the value of a variable without having to log it to the console, use watches, change values on the fly, debug step by step. Noobs use vim because they think it's cool and they believe programming is about how fast you can write the code because you can keep your hands on the keyboard. Also C in 2022 is a bad choice for anything, included low level programming, where C++ and Rust and Zig are a much better choice. Just a free advice from someone with 25 years of experience in the industry.
@@biomorphic cope
@@biomorphic Ever heard of GDB? real men only use the terminal
@@biomorphic As an ex-dev in over 3 FAANG & FORTUNE 50 companies, I absolutely agree.
@@biomorphic I'd just say to use emacs or vscode with vim keybinds
Writing an multi threaded web server using only std is literally the main example in the Rust book 💀💀💀
We actually had this as an assignment in our computer science course at uni and I found it a great learning experience for both C and HTTP/IP
I'm not sure if our networking course has this project/assignment. But it would be cool to have this
Same
@@imraninfrarote in us uni they have networking and db. Indian syllabus has only algorithms and basics. I'm guessing you're Indian from geeksfromgeeks page.
COMP30023 "Computer Systems" at the University of Melbourne for anyone wondering
I'm actually Bangladeshi
I remember watching this vid 1 year ago, beeing like, who tf would do that in c....
Year 2 in uni, implement an async server in c....
I hate my life..
I freaking love that coding kind of imbues us with this chaotic energy that makes us do *whatever* because we can 😂😂😂
The cool thing will be to get to a point where you can run a performance benchmark against stuff like apache iis and node express. Or even that new rust framework leptos
That's actually on my todo list. But for now, I'm just trying to get the basics done
until you get near feature parity, benchmarks aren't very useful, so that will be a long while off
leptos is a full stack framework. axum would be a more apt comparison.
The project is interesting, I did the same for a tp at the university. Once you do one of these you really understand how the web works
That's one of the main reasons I wanted to make this in the first place
Pretty nice 🙂It remembers me the old days where we had to create lots of programs using C and C++ and we didn't have a nice editor with all the syntax highlighting and code completion... *sigh* But it was a lot of fun 🙂
Now we get to create programs in c but with syntax highlighting and code completion !
Only 121 subs ? I thought this was already a big tech channel 😮 Keep going !
same
Appreciate the support mate
😶 okk you got a sub
484 now lol
@@billowen3285 696 now
This guy sleeps on the warm side of his pillow.
How could you tell?
honestly I feel like 50% of C's problems would be solved if arrays just knew their own fucking length
Bro this was awesome. I would absolutely love to see more of these web servers in C series. Also, you have inspired me to try this myself :)
Bro could you explain how to run this project
Love the humour. I have done large projects using the Websockets API ... fun fun fun!
If I had to implement route mapping I would suggest using a Trie. It is simpler than a balanced BST, has better time complexity and extending it to support common features like catch all routes (/catch-all/*) and slugs (/products/:slug:/p) is very straightforward.
Interesting. I was actually wondering how I'd handle slugs and stuff. I'll definitely take a look at it. Thanks for suggesting
The C language is one of the most important human developments of the last 50 years.
Next logical step: Assembly
Don't post spoilers pls
@@imraninfrarote If POST os prohibited, it should return a 403 not a 200.
Great Video!
Well if you want to try this again, but with an easier to use API, C has GLib+GIO (spun off from the GTK project) which you can use to write all of this in Pure C. GLib can provide pre-built data structures (yes, it has Hash Maps), and GIO which provide a high level File and Socket API including streams, all in Pure C. (Note, GLib and GIO DOES NOT depend on GTK, you can import them independently).
i worked as a software developer in Embedos Engineering in Mumbai India, here we use to make IOT edge devices with SBC's and Microcontrollers. We used Esp32 and wrote our own code in C from scratch created web servers to achieve 2 way communication between the device and the end user for device configuration and data visualization, can connect to the device once in the same network just get the IP of esp32 it serves html files stored in it (esp32).
As someone who has also done this, I can say it was pretty darn fun.
Now that AI can write code, *everything* should be written in C
This video remembered me, why I prefer using c# instead of its ancestors 😁
@Peter Brown for sure. Being fast is important in many fields. But I'm just to lazy to fight with all the struggle which is the cost for speed
We had to build a web server in C for a network programming project at university. This was in 2005.
One option for the routing map would be a trie structure, might be a bit better than a bst
This isn't just a learning project.
As a backend developer (who loves C/C++ More than any other language) i am about to write my own web server using C++ (i use C++ instead of C just for tge OOP i don't use the STL i hate it)
That's because most used web servers are open source and available for everyone, so hackers can download and start pentesting the webserver, potentially detecting an RCE vulnerablitity which puts all servers using this web server at risk.
When we write our own PERSONAL web server, we'll avoid all types of server attacks (because our web server isn't available for hackers to pentest) and pentesting requires debugging, analyzing the source code, and so on....
This video is like a push to me to create my own web server that serves files, and execute backend scripts such as python, php, and javascript.
The reduction in penetration testing stops being so valuable when the server is running scripts, because of the increased chance of unsafe inputs slipping into the interpretter.
@@absalomdraconis 100%, That's Why Im Going to mirror user input through multiple input validation bridges inside the server itself before throwing it to the interpreter.
> i don't use the STL i hate it
lol..
Security through obscurity is not security.
@@levyroth why bro
If we were in the old days, we wouldn't be using C as you did but instead through a superserver, like inetd, and you could easily make a server using printf's, read() and write() to stdin/stdout (you could make a webserver with AWK or Shell script like this). Second, if you are already using unix sockets, you can use unix/posix functions, and there's regex in posix c.
Fun fact: Even the UNIX "fathers" didn't like sockets (that came from BSD, not UNIX) but their solution was only done in Plan 9 through the /net directory, and they had to reinvent how file system works to make it work (and in the process they created private namespaces, which somehow creeped to linux as mount namespaces, and in linux the mount namespace is as powerful as private namespace of Plan 9, but everyone uses as only a gimick for isolating environments like chroots. This is sad, to be honest...)
So you're suggesting you can do communication across the network via mounting?
@@spaghettiking653 on plan 9 yes, but only because plan 9 treat fs differently. all fs in plan 9 works like FUSE on linux/macos.
you know this guy is the real deal when he uses geeks for geeks
Part 2 - Building my own Javascript framework
Not a bad idea though. It'll be an absolute blast to dive that deep into the JS world
The beej network guide is great for this if anyone wants to try or learn it. It's a good overall guide for new people. Now just need to learn parallel/concurrent programming...
What a nice neat little project. The code is easier to understand than I thought.
I loved the video, I'm still a newbie in C but I'll definitely try something like this !
In my experience, the best way to learn a programming language (or programming in general) is to simply build stuff with it. It doesn't have to be the next big thing. When I started coding I went nuts and built tons of questionable programs.
Don’t until you really know what you’re doing
rip 💀💀
I left a like and a comment to promote this video. Good stuff, keep it up, add more details
Thanks a lot 😊
Really appreciate the support
Ahhh C. It is like drinking coffee and relaxing after lunch.
Wether the cup contains little coffee and sugar, or half a ton of coffee is another thing
Jesus Christ, not only is he writing C code in VIM but he is also using Linux, not any Linux distro, but an RPM based distro. 👏🏾👏🏾👏🏾 a fellow man of culture, Based.
Really liked your video. You earned a new subscriber. শুভকামনা রইলো
Really appreciate it. ধন্যবাদ।
Ima let my dog know he had a whole week of spending afternoons at the dog park because I used gRPC. Thank you from him in advance.
This is such a good video, I see your channels gonna explode with content. You won my sub.
I wish you actually made a full tutorial on how to do this.
Wonderful work, I appreciate your humility. I'm excited to see where it goes!
Nice style kinda like liveoverflow.
good job brother. this motivated me to write same in python or c++
Really So much impressed brother and i myself like C Language and want to make my FYP project in C.
The C Language is best for beginners that wants to learn programing. Actually from C or C++ you understand and learn alot of basic concepts of programing which i think most of the programers still dont understand clearly and that is the reason for their poor cpde quality.
Looking forward for more informative videos from you :)
In-depth tutorial is much appreciated. Like
Would be a great programming assignment for a university course
Really fun video, mate! I am subscribing!
Liked how you forget to regord once and at the begining as you said that you didn't copy the code from the YT tutorial 😂😂
funny, every unix function is NOT error handled at all
Best I can do is write a basic window in WIN32 like it's stone age.
Nice project Dude!
Good luck and have fun 😊
1:55 ordered maps are most often B-trees for cache efficiency
As hard as this may have been, it's crazy how much you can still do with a 50-year-old programming language.
Yes, I was also caught off guard when I learned that C is 50 years old.
bro so pro making the impossible possible in 3 minutes
have fun migrating it all to epoll, see you next autumn
Amazing video. You rickrolled me. +Respect
LOL! The rick roll really got me!! xD
Awesome content homie!
But can you do it in FORTRAN?
I really wonder if anything can be done in any language. Like...can you do a website with cobol? Or a rest API with assembly, etc
I actually had written a web server, in C++ Builder, and integrated it in a rich GUI app. That's what I used to make the app available on the web.
That's actually amazing!
@@imraninfrarote Honestly, I have been writing that code and maintaining it for a long time, so it wasn't an over night success. Maybe over many nights . 😂
Here before 1mil views. Good job man!
freshers: we use chatgpt
experienced: we u se documentation
legends: I code in c
When he said python garbage , my context manger got pissed .
Why not? Recently I've made ftp server in pure C for Windows.
Very cool. `set number relativenumber` is the only way to fly
If you haven't set relativenumber (even if you don't use it to jump) what the hell are you doing with your life?
There is a really old framework to write websites in C named FCGI, it's a bit easier then writting your own webserver.
Great video lmao
Do a tutorial in this kind of style on how to use vim
When the "C" character come out in intro screen. I thought the next character is "#" :)))) crazy.
I always wondered how it is would be a server made with C 😅
you can take it further to see how it would perform in compare with Rust, Go, etc.
Working on it
Actualy Web Engine & Labguages mike HTML 5, CSS3 & JavaScript are written in C/C++ so I no doubt to think about that.
back in the uni, my prof said only an idiot will use C to develop a web server. And that what I also did. I am so glad that I am not the only idiot in this world :D
Nice video. Just to let you know, hash collisions are extremely rare for most hash functions.
Yeah. But I really wanted to try out a BST. I'm still learning
huh, looks like someone hasnt used a hash function in their entire life!
Are you so sure about that
It only depends on how wide your hashtable is and how much data you have. If your hashmap is N buckets big and you have to make N + 1 entries, guess what? You will have at last 1 collision (or even more) - inevitable! No mater how good your hash function is.
made it with assembly if you are a true sigma
I fought with Javascript for a long time, until I understood it. I don't say I agree with implementation but I think I understand it, funny to see juniors fight with code that should work but it doesn't))
You should also try out making a HTTP/2 server
introduces you to a lot of painful things
Painful things you say?
Interesting
Looking forward to seeing some benchmarks!
That was a great idea. I will try to it on my own as well.
Basically my day job sockets, epoll, clone and so on.
You could also implement routing with a finite state machine, although it would be tedious to hand write.
It's like his writing dna codes.
I started my c journey and its interesting to watch as a newbie
The best!!! ❤️Let's make web server in c++. 🙏
nah, in Rust, with Webassembly, with a windowing terminal for R and Julia.
basically every Operating Systems class in undergrad/grad school 😭
nice work, C is fast, scary fast, emphasis on the scary especially in Prod
Forget prod. The development part itself is a nightmare
@@imraninfrarote A nightmare? Nah. I've been programming in C for 3 decades, and I prefer it. So do the developers of virtually every other systems developer.
@@yapdog well, I clearly don't have experience like you do. So a huge portion of the time, I'm not even sure what I'm looking for. I will strive to be efficient in systems programming as it is something that truly interests me
@@imraninfrarote Coolness 😎 I'll try to keep up on your progress, but I'm sure I'm sure I'll learn a thing or three along the way. You're never too old to learn something new, right?
Zero hours and 69 minutes 😂
This has to be a memory overflow
please come to Universidade do Minho
Your data is gonna race faster than Bolt
1:03 Why did I instantly know what was going to happen next.
Human brains have amazing pattern recognition.
thats literatly what react can do
A cool project but I enjoy having a good mental health
"I used a BST cuz I didn't wanna roll my own HashMap" god I love rust
inb4 no_std killaz
Next challenge: web server on assembly language
what i love the most about this is, that it is c and not c++.
Can you tell me why you are using vim to code instead of modern IDEs
And thank you for the awesome Video😊😊😊
The memes level in this video is superb, 11/10
I was actually researching this topic at one point. Glad to see I'm not the only one who should be put in an institution.
holy shit, never thought about this. my language when i first entered university
Lol cant imagine how you managed all the structures..
This is some sort of artistic endeavor.