@@JacobSorber Thanks @Tarun I found IUP. I never knew there exist a library like this. Would love to learn it.
@yangliu37543 жыл бұрын
Your video always remind me how challenging working with C can be compared with working with other languages. But this may be also why so many programmers love C. Challenging but cool.
@tordjarv38023 жыл бұрын
Also the Turing halting problem is a problem to consider for the humble programmer that just want a progress bar for their program
@TheCocoaDaddy3 жыл бұрын
Awesome video! I'm definitely someone who gets frustrated with inaccurate progress bars and even though I'm a programmer, I never stopped to think about the implementation of a progress bar. So, this video changed my perspective significantly. :) Plus, it was fun watching you create the progress bar. :) Thanks for posting!
@JacobSorber3 жыл бұрын
Thanks!
@manla99213 жыл бұрын
Could you make a video showing how to Configure/Setup VS Code for C programming please?
@bishoppebbles56993 жыл бұрын
Checkout the video by CodeVault called "Compile and run C code using Visual Studio Code". He has another video for Linux as well.
@NicolaiSyvertsen3 жыл бұрын
The point is that the progress bar says nothing about how long something is going to take. There are progress dialogs that show estimated time left but that is also something that is based on an algorithm often by sampling the download speed at intervals and updating it. Also one more thing you should have mentioned is that on the terminal and in single threaded applications you actually shouldn't print too much to the terminal while doing processing as then the processing will be limited by the throughput of the terminal. rsync with and without -v argument (verbose) shows this clearly. It prints a line per file copied which does slow it down. A timer signal handler (POSIX timers) that sets a volatile flag which you can then poll in your processing code to do status updates every second or so would definitely help. Though I'm not sure how to fix rsync other than doing the processing in its own thread. The problem with this approach is that the status updates would start to lag behind what is actually being processed fast.
@nagarajahuliyapuradamata34473 жыл бұрын
I have been disappointed recently with, 1. Horrible hobby projects available online with fake update %ge bar graphics (hold cpu time just to show a fake progress whereas nothing is happening in the background!) 2. Live code sessions recorded with huge screen/monitors, that I couldn’t see fonts (therefore couldn’t understand what was going on). They missed the whole idea of live coding sessions! (note: developers are watching KZbin live coding sessions on mobile mobile because they have lost jobs/no access to laptops, thanks to corona pandemic! Such videos are useful to keep our skills sharp) I like this video because, 1. It addresses all above points 2. I liked the initial prediction and calibration logic Thanks for sharing this video!
@adambishop3282 жыл бұрын
I liked this video because it included a small amount of many things like networking, prediction methods, and gui. And the great part was that it was presented in a digestable chunk of just a few short functions. I'm currently a third-year CS student and for specific topics it's really great to see someone actually build programs like this, it makes it so much more concrete and memorable.
@adriancostin91383 жыл бұрын
this video actually made me want to code in C again. really appreciated the production quality on this, thank you.
@Ythishate3 жыл бұрын
Really loved the old days , C and the pointers, will start programing again , Anything can be done in C.
@lorensims48463 жыл бұрын
Wheee! I always knew there was a lot of guesswork involved but hoo boy! You've clearly made a valiant effort and yet your progress bar still parked when it hit that Debian download. Thank you SO much for the example. It gives us a place to start from.
@zxuiji2 жыл бұрын
25:22, for accuracy I would default to url_index vs url_total for done vs expect but when ever a url provides the total bytes I would add that to the expect parameter and add the total bytes done to the done parameter, the write function can detect this difference by simply checking what the initial handler given has set something like max_current_url_bytes to, if it's 0, stick with what you have, if it's not, add the byte count working with to the done parameter as the expect parameter is already been added to by the same function that set max_current_url_bytes, this method provides more accuracy when available but sticks to what it know when it's not, the max_current_url_bytes parameter is then also usable by the update function to produce either "current url: bytes of max bytes" or just "current url: bytes"
@PlasticCogLiquid3 жыл бұрын
I first time I ever made a progress bar I just tied it to some behind the scenes stuff for a 2d game. It generated a bunch of random items every time a level started so I tied the graphic of the bar to the amount of objects being generated. On modern computers you don't even know there is a progress bar, but on ancient computers it works great :P That made me start wondering what the progress bars in other games are actually tied too and how many other people sorta fake it like I did. You expect that it's magically loading everything in the game, and maybe for other games it is, I wouldn't know because I'm a hack
@FreddieDeetlefs3 жыл бұрын
What I normally do is have a progress bar for each separate task and then one main progress bar to show the overall progress.This way you can see which tasks have been completed and which ones are still executing, I also add a label that indicates the amount of tasks that have completed and the amount that still need to be done.So still no indication of the amount of time needed but this way you see the actual progress being made.
@dovias56653 жыл бұрын
Oh boy! This is gold content. Even better than Cherno's C++ series. Thanks!
@eqanio3 жыл бұрын
True legends of the game
@aaryan65773 жыл бұрын
Love your content! There aren't many channels who do this good quality C videos. I'd love to see any good C project videos too!
@JacobSorber3 жыл бұрын
Thanks. I'll see what I can do.
@d97x173 жыл бұрын
Thank you for this video! I do have a question about the use of the predict_next function. In the video, you always supply statusinfo::exp_bytes_per_url as the value for the last prediction. Based on that one and the estimate_current, you make a new prediction and store it in guess_next_prediction. Subsequently, guess_next_prediction is used to (eventually) calculate the percentage, but afterwards it's discarded. Wouldn't it be better to either store guess_next_prediction into statusinfo::exp_bytes_per_url or keep track of it in another way and use it as a first argument for the predict_next function? I think in that manner, you actually take into account the full history
@JaimeWarlock2 жыл бұрын
Just make your progress bar work like Microsoft progress bar does. Speed depends on remaining amount of the bar with no link to reality. So if the bar is 90% done, that means it moves at 10% speed. At 99% done, moves at 1% speed.
@svdinverse40253 жыл бұрын
Professor, great video as always. Thank you for this and so many other wonderful tutorials. I have a request. Can you do some tutorials(s) on sockets, zeromq messaging and related topics. It would be v helpful. Thank you again.
@JacobSorber3 жыл бұрын
Thanks. I already have some on sockets. Let me know what specifically you think I'm missing. And, I'll add ZeroMQ to the topic list and see what I can do.
@svdinverse40253 жыл бұрын
@@JacobSorber Thank you, I went and watched the websocket client that does a simple get http. I was looking for tutorials of clients that can get streaming market data from some web server. How to change your example so that whenever the server pushes new data, the client automatically updates itself?
@JohnB-20213 жыл бұрын
I've not watched all the video yet, added it to watch later. You wrote for i=0; i
@JacobSorber3 жыл бұрын
True. My wording was not very precise. I wanted it to execute the loop body for 1== 100, not just count to 100.
@JohnB-20213 жыл бұрын
@@JacobSorber Thank you Jacob. I program Pic Microcontrollers and only now moving to visual studio to learn more... Great video.
@ivelinkarageorgiev31113 жыл бұрын
Damn that's my favorite cs channel, keep rocking ^^
@carolinemathieson2 жыл бұрын
Write the progress bar to stderr first of all then you don't need the fflush. Also if you do this and need to redirect the output of your program to a file to keep a record of what happened then the file will not contain a huge number of lines for each step of the progress bar updates.
@SHONNER2 жыл бұрын
I have lots of progress bar example code. But none of what I do can be applied to them because my apps don't know when they will finish. So I don't use them.
@danielrazulay3 жыл бұрын
Progress bars should measure bytes v total bytes, not files vs total files. Time prediction shouldn't even be part of the code.
@philippejean11023 жыл бұрын
Super channel !! I just discovered and I love it !! great job !!
@JacobSorber3 жыл бұрын
Thanks and welcome, Philippe.
@iltrovatoremanrico3 жыл бұрын
Great video, thanks! Can I ask, what is the font you use in VS here?
@von-fur-wegen-gegenolli91963 жыл бұрын
Finally i know how that works!! 🙏
@johnconnorstopskynet2 жыл бұрын
I'm not a programmer I'm just starting out maybe I'm just speaking on something that I don't know anything about which I probably am. But wouldn't the most accurate way be to determine the total download size and then factor in the average download speed. As you said it's not easy to figure out the download file size which I'm not sure why if a web browser can do it.
@samuelmartin73193 жыл бұрын
Loved the video! Would you ever dive into something like the Quake 3 engine and do videos on that? The engine is “simple” compared to something like unreal.
@subhankarkarmakar26502 жыл бұрын
where does curl save the files ?? I cannot find them !
@agustinanfuso65053 жыл бұрын
This was amazing!
@JacobSorber3 жыл бұрын
Thanks.
@danielbodovs11953 жыл бұрын
Hey, great video, but I feel like it could have been summarized in a minute or two in the beginning and then the code could've been shown. The whole idea is quite simple and writing out the code seems like a waste of time, at least for people who have coded for some time. I thought that it would be this exact reason, but still watched as it seemed like you were gonna make an important point about something else or at least discuss these issues more at length in the end (e.g. you could've said how with many files requiring download estimating may be better than just asking so many separate servers about the size of the files due to the inefficiency of that, which you kinda said, but didn't elaborate on why this is only really a problem with many files and mainly in the beginning (spending a minute on just loading the size and then actually starting the download and updating the progress bar would cause a lot of people to quit midway through (and how making so many requests to different servers is not that great of an idea because some servers would not receive the actual file request until possibly a lot of time later, even hours, therefore initializing the connection would be the big inefficiency problem here); with few options to request it's not that big of a deal)). Or you could've talked about how this could be at least partially solved by the server of the program we are developing storing the latest size of the downloads and using that. What I'm trying to say is that you could've covered things with words first and then with code so as not to have the video be underwhelming. Again, though, the explanation was pretty good for the level of depth.
@leonardusl51413 жыл бұрын
10:19 Why isn't sizeof(urls) just giving the size of a pointer?
@edenr19883 жыл бұрын
Great video, I remember getting challenged to draw multiple progress bars for multiple processes running in parallel, and couldn't really find a proper solution for it. Idea perhaps for your next video ;)
@JacobSorber3 жыл бұрын
Thanks. Yeah, we could probably do that. Were you working in the terminal, or using some sort of graphics framework?
@edenr19883 жыл бұрын
@@JacobSorber was working in the terminal. A good example for this kind of progress bar is perhaps docker cli when downloading a container image you would see multiple digest layers being downloaded in multiple progress bars and I wonder how did they implement it, I couldn't figure it out. I would assume they're opening channels between the main thread and that thread which currently running the download and transmiting the progress to the main thread to draw it.
@JacobSorber3 жыл бұрын
@%9F%98%80nel/UCvQtSHqKNUKpVbWkfhesmKA They were probably using control sequences. Sounds like we'll need a future video on that. Thanks for the idea.
@papaoese62583 жыл бұрын
@@JacobSorber I've also seen similar behavior by pacman (Arch Linux package manager). It would be interesting to get an explanation of how the parallel download progress bars are implemented
@apexstate31273 жыл бұрын
Sir, Today I am start learning about getchar and putchar , I can't Understand why getchar read single char if we use without loop. and why getchar read all character if we use within loops.
@zxuiji2 жыл бұрын
6:14, frankly I would've just not set i on the second loop and used PROG_BAR_LENGTH as is, less prone to mistakes that way, but the integer conversion was new to me, was looking for how to do that without floats, didn't occur to me to just multiply 1st
@SealedKiller3 жыл бұрын
What font are you using?
@sababugs11253 жыл бұрын
Will you make a video about graphics in c ?
@JacobSorber3 жыл бұрын
There are lots of ways to do graphics. I've touched on a few in the past (the curses videos and the pandemic simulator video). Do you have something specific in mind?
@sababugs11253 жыл бұрын
@@JacobSorber you could do something about basic drawing objects to the screen and opening windows and what not ? Do you have any plans for those kinds of videos ?
@adude51363 жыл бұрын
@@sababugs1125 That’s gonna vary from platform to platform and based on what you mean by graphics. If you just want to open a basic window or OpenGL context, draw simple sprites to the screen, etc, on any platform you’d probably be best off using SDL2. But if you mean more typical desktop GUIs that are well-integrated with your OSs windowing features, menu options, etc. then you’ll have to work with the tools your OS (and windowing system) gives you. That will vary a lot, but some examples include the Win32 API, Xcode’s Interface Builder, or GTK. In some places with these, you may have to move away from pure C.
@antonw81343 жыл бұрын
@Sababugs112 You might check out the One Lone Coder channel for playing around with graphics. It’s in C++ but if you’re asking about graphics you’re ready for advanced topics. ;^}
@puppergump41173 жыл бұрын
@@sababugs1125 Look up Ryan Ries (Building a game from scratch in c) or Samuli for Win32 graphics. However, just using Win32 requires you to make your own backbuffer and manage that buffer's memory to prevent [Access violation error writing location]. SFML (or the c version, CSFML) is a useful library to automate that stuff, so all you have to do use the functions provided to draw simple shapes or textures. Also, GLFW. But my point is that knowledge on graphics in standard c is mainly useless and headache-inducing. If you're programming in c, it's my opinion that you just make a program or library to do graphics for you, or download one from somewhere else. As an example drawing a simple rectangle with Win32: #include int width, height; // Window Procedure, or message handler thing LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_QUIT: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wparam, lparam); break; } } // The rectangle making function void DrawRectangle(int rx, int ry, int rectwidth, int rectheight, short color, void* buffer) { int* pixel = (int*)buffer; // each pixel has sizeof(int) amount of color data with 32bpp pixel += (y * width) + height; // pointer starts at 0 (bottom left corner) and increments to the right, moving up as it hits the right edge for (int y = 0; y < rectheight; y++) { for (int x = 0; x < rectwidth; x++) { *pixel++ = color; // The pixel gets a color and the pointer increments } } } int __stdcall WinMain(_In_ HINSTANCE hinstance, _In_opt_ HINSTANCE hprevinstance, _In_ LPSTR lpcmdline, _In_ ncmdshow) { width = GetSystemMetrics(SM_CXSCREEN); height = GetSystemMetrics(SM_CYSCREEN) // Basically, formatting the image to be drawn BITMAPINFO bitmapinfo; bitmapinfo.bmiHeader.biSize = sizeof(bitmapinfo.bmiHeader); bitmapinfo.bmiHeader.biWidth = width; bitmapinfo.bmiHeader.biHeight = height; bitmapinfo.bmiHeader.biBitCount = 32; bitmapinfo.bmiHeader.biCompression = BI_RGB; bitmapinfo.bmiHeader.biPlanes = 1; // To hold image data (will be used in the drawing function, StretchDIBits) void* buffer = VirtualAlloc(NULL, width * height * 32, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); // Window creation WNDCLASSEX wc; MSG message; HWND hwnd; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = L"class"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // Error check window class because it literally always fails if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } // Creating the window hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, L"class", "The title of my window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, hInstance, NULL); // Error check window then cry because you can never find out why it fails if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); // The programming portion of a project that uses a graphics library // Draws a green 100x100 rectangle at (500, 500) into buffer DrawRectangle(500, 500, 100, 100, 0x00ff00, buffer) while(running) { PeekMessage(&message, hwnd, 0, 0, PM_REMOVE); TranslateMessage(&message); DispatchMessage(&message); StretchDIBits(dc, 0, 0, width, height, 0, 0, width, height, buffer, &bitmapinfo, DIB_RGB_COLORS, SRCCOPY); } return message.wParam; } I just realized you might not have been talking about standard c. I'm gonna go stress eat pizza, quit my job, get a loan and take a vacation to Mexico.
@islandcave87383 жыл бұрын
Having made a progress bar, I know why. If there are say 4 steps that are hard to compare, you could break that up into 25% each, but thats not accurate. Maybe some of those steps have n items to go through, so 25% / n...
@bernard36903 жыл бұрын
I can't believe it I watched you type for half an hour only to learn what you could have explained in the first ten seconds but finally got around to in the last ten seconds Amazing "Progress Bars are always wrong because it is not always possible to predict the amount of work which will be done" That's all you had to say Amazing Of course I will not subscribe Maybe I can teach you something In my own progress bars I display a numerical percentage and will insist on displaying the full floating point percentage so the user will be more likely to see an increasing number even for lengthy operations and I make every attempt to predict the amount of work which will be done - Cheerio
@siddharthpandey32043 жыл бұрын
I've this question as I'm in a dilemma for sometime that should I switch to C for competitive programming, or the popular C++ (knowing the few drawbacks of C, as mentioned no direct method to compute array length) from my till now CP partner JAVA? The question arises coz presently I'm associated with Embedded C projects & have been learning C for that matter & wish to be more fluent in it. Would really appreciate some advices on this :)
@NikitaMittcev3 жыл бұрын
In competitive programming speed is everything once you understand how to solve the problem, so STL algorithms and data structures in C++ (like sort, vector, set and map) are just too good to throw away. If you want to practice and get a better understanding of their internals then consider implementing some of them yourself with C++ templates (maybe even in C-style to some extent) but still go with the standard library implementations for actual contests. They are robust, very fast, versatile and can be customized on the fly for any kind of input data
@NINJ4_TR0N3 жыл бұрын
study for pentest work, video is very essencials for work in pentest
@FiveNineO3 жыл бұрын
Make progress bars great again 👍
@DerDill2 жыл бұрын
What symbol is this arrow on the keyboard in 17:31? Thanks
@ksherif482 Жыл бұрын
I suppose it is a fance symbol replacing the -> (arrow). He also uses the ≥ which replaces the >= . I tried it in my code but it isn't recognized. Probably something in the settings, but I wouldn't mind it
@flowingcode8069 Жыл бұрын
Nerd fonts
@Kitulous3 жыл бұрын
watching this video while Raspberry PI on the second monitor is updating apt packages (watching it through SSH) :D
@roshandsouza23293 жыл бұрын
Cool stuff, thank you 👍
@JacobSorber3 жыл бұрын
Glad you liked it!
@smrtfasizmu61612 жыл бұрын
Flushing the output stream is done in Java as well. In Java I write bufferedOutputStream.flush();
@JacobSorber2 жыл бұрын
Very true. Thanks.
@georgeomara3 жыл бұрын
Wow I love this.
@JacobSorber3 жыл бұрын
Thanks!
@sumitbhosale34013 жыл бұрын
Damm. Awsome Video. Thanks. Can You Make a Video On Graph
@JacobSorber3 жыл бұрын
Thanks! Yeah, graphs are on the topic list. I'm sure I'll get to them at some point. Do you have anything specific about graphs that you're looking for?
@sumitbhosale34013 жыл бұрын
@@JacobSorber Well I Don't Know How Graph iplimenting In C rogramming.
@ChoudharyRamesh3 жыл бұрын
love this video
@rmcf75143 жыл бұрын
Love the shirt man!
@JacobSorber3 жыл бұрын
Thanks. I know where you can get one of your own. 😀
@darkknight82073 жыл бұрын
great content.
@JacobSorber3 жыл бұрын
thanks.
@abijeetrs65223 жыл бұрын
ProgressBar pbUrls = new ProgressBar (); 😛-- learnt a lot though from your code -- Thanks.
@JacobSorber3 жыл бұрын
😂 You're welcome.
@eboubaker3722 Жыл бұрын
Bro just send a HEAD request to all urls and sum all their responses's CONTENT-LENGTH to get total bytes to download.
@thedoublehelix56613 жыл бұрын
Maybe you should have the biggest things download first. That way the user gets a nice surprise when the download finishes faster than expected
@SadgeZoomer3 жыл бұрын
Maybe the topological order doesn’t allow that?
@thedoublehelix56613 жыл бұрын
@@SadgeZoomer yeah maybe you'd have to find the download sizes anyways to order them in that case
@bokunochannel842073 жыл бұрын
progress bar is pure for aesthetic reason. the number tell the truth.
@JacobSorber3 жыл бұрын
So many philosophical retorts to this...🤔 Aren't they both just visual representations of an abstract quantity? 😀
@puppergump41173 жыл бұрын
@@JacobSorber Seems like an abstract representation of a visual quantity, the visual quantity being only how much the program has seen.
@streamdx3 жыл бұрын
I don’t like progress bar that making backward steps!
@p2k77779 ай бұрын
I hate when a progress bar says 100% and I'm still waiting
@marceloguzman6463 жыл бұрын
whats that font 😩
@JacobSorber3 жыл бұрын
cascadia code
@ChristopherBruns-o7o3 ай бұрын
Is it cool iof i deep fake this content? For educational purpose of coarse.
@mehmetedex3 жыл бұрын
voice channel not aligned at the end
@Youtube_Stole_My_Handle_Too2 жыл бұрын
A progress bar has two purposes. 1) Estimate time on arrival. 2) Inform if the connection is alive. If the backend is so poorly done it can't deliver on 1), you as a programmer can still inform the user about activity, ex, bytes per second. Most programmers are complete morons they can't even do 2).