How do I make multiple concurrent progress bars in the terminal? (tutorial in C)

  Рет қаралды 22,026

Jacob Sorber

Jacob Sorber

Күн бұрын

Пікірлер: 72
@kyleherrity8443
@kyleherrity8443 3 жыл бұрын
I used to program exclusively in C. Now I program primarily in C++. Your videos make me wax nostalgic about my past. I miss the purity and simplicity of C! Great videos.
@kayakMike1000
@kayakMike1000 3 жыл бұрын
C seems pure because it is so much more simple, I am sure your C++ code is pure also.
@marcosfons
@marcosfons 3 жыл бұрын
I was always in doubt about how it was done, but I had never really researched it. What a nice video to watch, thank you
@JacobSorber
@JacobSorber 3 жыл бұрын
Glad you enjoyed it!
@fburton8
@fburton8 3 жыл бұрын
Back in the day (late 1970s) I knew most of the VT52 and VT100 escape codes off by heart when I wrote a 'visual' text editor for use on our PDP-11 terminals. Better than using TECO and later EDT for writing code anyway.
@kayakMike1000
@kayakMike1000 3 жыл бұрын
Damn dude, you're a fantastic software engineer.
@nomadic-insomniac
@nomadic-insomniac 3 жыл бұрын
Awesome , I've been coding in C for a couple of years now and I still learn something new whenever I visit your channel. Keep up the good work. Stay safe.
@JacobSorber
@JacobSorber 3 жыл бұрын
Thanks! Hopefully, we'll keep learning new things together.
@massimilianogilli1164
@massimilianogilli1164 3 жыл бұрын
mind doing a video on event-driven model?
@joseortiz_io
@joseortiz_io 3 жыл бұрын
I would love to see this as well!
@JacobSorber
@JacobSorber 3 жыл бұрын
Yeah, it's been on my list for a while. For some reason, some ideas take more fiddling than others. It'll show up one of these weeks.
@joseortiz_io
@joseortiz_io 3 жыл бұрын
@@JacobSorber Yeah I'd definitely love to see this. I've been working on a microservice architecture and one issue I'm dealing with is implementing CQRS for updating views. And that requires an event-driven model. I thought about using gRPC for that but I'd like to know all other options
@butchdean
@butchdean 3 жыл бұрын
This was one of your most excellent videos ever! Progress bars have been making me feel lacking for years! haha. Thank you!
@JacobSorber
@JacobSorber 3 жыл бұрын
You're welcome!
@vitacell1
@vitacell1 3 жыл бұрын
I love C, and your videos about it.
@JacobSorber
@JacobSorber 3 жыл бұрын
Thanks. Glad you're enjoying them.
@Arnau_0_0
@Arnau_0_0 2 жыл бұрын
I had a lot of problems understanding ESC characters but you made it all clear to me. Thanks!!
@redcrafterlppa303
@redcrafterlppa303 3 жыл бұрын
I was recently making some terminal related lerning libraries and moving the cursor using ansi was something I was overcomplicating. This video really helped me understanding ansi better.
@stackoverflow2155
@stackoverflow2155 3 жыл бұрын
I really like your tutorials. They cover C, and how people can use it well.
@oblivionronin
@oblivionronin Жыл бұрын
I started to research this after i saw the output of docker build, tought it was so cool, like how do i get this into my program ?! I knew it wasnt curses, glad to see its fairly simple. Great video, thanks !
@zedespook
@zedespook 3 жыл бұрын
Can you do a video about #pragma once vs. header guards?
@edenr1988
@edenr1988 3 жыл бұрын
Thanks a lot! couldn't find a better explanation anywhere else than in your video! 👍
@JacobSorber
@JacobSorber 3 жыл бұрын
You're welcome! Glad it helped.
@praenubilus1980
@praenubilus1980 3 жыл бұрын
Please make more videos like this one
@gaganb
@gaganb 3 жыл бұрын
A video about namespaces would be great to see!
@TheKelor
@TheKelor 3 жыл бұрын
This was *exactly* what I was searching for :o really ty :D
@JacobSorber
@JacobSorber 3 жыл бұрын
Welcome. Glad I could help.
@ahmadj1064
@ahmadj1064 3 жыл бұрын
Hey jacob, really really love your stuff. Can you make a video on strings in general in c? I have a hard time with strings and would really like a video on string manipulation
@JacobSorber
@JacobSorber 3 жыл бұрын
Yeah, probably. Are there specific things about strings that are messing you up?
@mah4i
@mah4i 3 жыл бұрын
While i was watching this video ,i noticed that most of icons in KZbin page changed from almost 1 minute ago. well, that's weird. Also love your videos man , i like people who respect C :D
@JacobSorber
@JacobSorber 3 жыл бұрын
Thanks. Not sure what was happening with the icons, but I'm glad you're enjoying the videos.
@abdus-salam
@abdus-salam 3 жыл бұрын
can you help to understand by example of old fashion terminal dashboard with dynamically updating values?. i.e gpsd do
@oj0024
@oj0024 3 жыл бұрын
Can you link some ANSI control sequence documentation? Whenever I need to use them, I end up using some random site that has like three to four escape sequences, which is really annoying. Is there a reference with an exhaustive list of all the standard ones?
@JacobSorber
@JacobSorber 3 жыл бұрын
I typically use the wikipedia page (en.wikipedia.org/wiki/ANSI_escape_code). It also has links to more official docs down at the bottom.
@ukaszdrukaa8326
@ukaszdrukaa8326 3 жыл бұрын
The xterm documentation is one of the de facto standards for terminal escape sequences; you can search for "xterm sequences" and you'll find it, granted it's lengthy and technical. It's also worth mentioning that not all terminals support all sequences, and that's why the terminfo library (that ncurses uses) exists. You can use it to see if the terminal supports a sequence and if not, then you can avoid using it. (terminals can really get upset when they receive broken or unknown escape sequences) Aaand I'll also allow myself to shill Notcurses. It's an awesome terminal graphics library, more powerful and modern than ncurses is.
@JohnHollowell
@JohnHollowell 3 жыл бұрын
Now I know what all the cryptic stuff in my shell prompt variable (PS1) means and why they give me different colors and text formats, thanks!
@agustinranieri
@agustinranieri 3 жыл бұрын
Love your videos! How about making a selection menu?
@JacobSorber
@JacobSorber 3 жыл бұрын
Yeah, we could do that. I'll add it to the list.
@udhayakumar8259
@udhayakumar8259 3 жыл бұрын
Hi ,jacob can you explain fcntl- (fille control in unix ) record locking features in Unix
@JacobSorber
@JacobSorber 3 жыл бұрын
I'll add it to the list, and see what I can do in a future video. Thanks.
@udhayakumar8259
@udhayakumar8259 3 жыл бұрын
@@JacobSorber thank you jacob awesome.
@EpiKaoZ
@EpiKaoZ 2 жыл бұрын
Why you didnt need to use mutexes? isnt It unsafe to access progress from diferent threads?
@thebigmacd
@thebigmacd Жыл бұрын
None of the threads are writing to the same memory location, so there is no conflict.
@storkmobile7432
@storkmobile7432 3 жыл бұрын
Jacob, Nice videos to watch and to learn c from a profession. May I ask for a reqest. Maybe one step behind mulity threading, MPI (message pasing interface, executing parallel programs on different computers. I'm interested in how to use it in practice. Thanks Ben
@JacobSorber
@JacobSorber 3 жыл бұрын
An MPI tutorial could be fun. I'll see what I can do. Thanks.
@Cwmwd24
@Cwmwd24 3 жыл бұрын
Why not use "\e" for the ESC character?
@benjaminshinar9509
@benjaminshinar9509 3 жыл бұрын
really cool! how does the format know you meant \033 and not null terminator ('\0') followed by 33 without spaces? great video as usual, I'm always learnning new things.
@JacobSorber
@JacobSorber 3 жыл бұрын
Thanks. Octal escape sequences have 1-3 digits (octits), and the sequence ends when you either run into a non digit or you finish with 3 digits. So, "\0003" would be NULL character followed by '3' and \03 would be the character with value 3.
@Scotty-vs4lf
@Scotty-vs4lf Жыл бұрын
@@JacobSorber what if u used hex instead of octal
@guifes10
@guifes10 3 жыл бұрын
Is this supposed to work on a windows terminal as well? or just unix?
@therealchonk
@therealchonk 3 жыл бұрын
Can't you just use '\b' for backspace?
@JacobSorber
@JacobSorber 3 жыл бұрын
Good point. Yes, you can. I was just looking through the CSI docs and so I ended up using that one.
@edgarbonet1
@edgarbonet1 2 жыл бұрын
Indeed. For the record, when you hit the backspace key on a terminal operating in canonical mode, the terminal driver echoes "\b \b", meaning: move back one cell, overwrite with a space, move back again.
@airbus5717
@airbus5717 3 жыл бұрын
can u make a video recommending other Yt channels that produce C content
@pro-nav
@pro-nav 3 жыл бұрын
So you are saying I can make ASCII games for a terminal without using windows.h? Excellent, right when I needed it.
@b4ttlemast0r
@b4ttlemast0r 2 жыл бұрын
the arrowhead overwrites the initial [ too
@winter0912
@winter0912 3 жыл бұрын
Just wanna point out that in real world you have to use some synchronization mechanism (mutexes / atomic variables) while updating and reading progress, otherwise it's data race, so undefined behaviour
@winter0912
@winter0912 3 жыл бұрын
Well, it of cource depends on the architecture, for example not synchronizing it on x86 is *probably* ok, you won't see half-updated int. But you should always pay attention to this kind of details.
@XenoTravis
@XenoTravis 3 жыл бұрын
Why do people say avoid using sleep functions? I can't ever seem to find a good answer or alternative. I imagine it isn't that big of a deal with modern computing
@JacobSorber
@JacobSorber 3 жыл бұрын
First off, you always want to be careful with this sort of advice. Such a broad recommendation is bound to be wrong at least some of the time. That said, there are a bunch of different reasons someone might say that. In embedded systems, we avoid *some* sleep functions (like __delay_cycles on the MSP430s) because they can keep the CPU active and may not properly utilize low power modes. Others do, and...so, no worries. Depending on what you're trying to do, sleep functions are often a bit clunky. They are often uninterpretable. They aren't guaranteed to wait for the amount of time you asked them to. So, you often have more efficient and responsive ways to wait for things - like condition variables, mutexes, timers, events, etc. For the example in this video, I didn't really care about any of that. I just didn't want to be constantly burning CPU cycles.
@XenoTravis
@XenoTravis 3 жыл бұрын
@@JacobSorber well now I got some investigation to do! Thanks for the info!
@Victor_Marius
@Victor_Marius 2 жыл бұрын
@@JacobSorber i think on arduino, using the delay functions it doesn't work well with some timing libs (for alarms, timeouts and intervals) and maybe another thing is that you can not use it on interrupts.
@Victor_Marius
@Victor_Marius 2 жыл бұрын
Does it work in windows? I tried these escape sequences in CMD (but in python) and \033[5F doesn't appear to work. I used \033[5A instead.
@Starwort
@Starwort 2 жыл бұрын
cmd and powershell do not support ANSI natively afaik, but Windows Terminal does, or you can use the colorama library to polyfill it (colorama.init() sets up your terminal to use ANSI, and the library also contains some shortcuts)
@Victor_Marius
@Victor_Marius 2 жыл бұрын
@@Starwort I'm pretty sure I used colorama.init in CMD and there are some escape sequences that don't work even though they are on the Microsoft developer website
@Starwort
@Starwort 2 жыл бұрын
@@Victor_Marius weird; were you using the colorama tools or ANSI escapes directly? If the latter, you may have messed up the parameters to init?
@v3spirit
@v3spirit 3 жыл бұрын
multiple progress in the bars terminal?
@kodref
@kodref 3 жыл бұрын
ESC CSI NUMTHREADS PREVIOUSLINE
@sonymusicproducer8711
@sonymusicproducer8711 8 ай бұрын
😘
@lifesoftserv
@lifesoftserv 3 жыл бұрын
Really like your channel. Would like to see your thoughts on a build system, if you are interested in looking it is called "qo" and it is on github from andlabs/qo . Thanks and keep up the good work :)
@JacobSorber
@JacobSorber 3 жыл бұрын
Thanks, Joe. I'll take a look.
What Actually is Embedded C/C++? Is it different from C/C++?
11:05
Jacob Sorber
Рет қаралды 154 М.
Why are Progress Bars Always Wrong? Progress Bar Example in C.
35:44
Симбу закрыли дома?! 🔒 #симба #симбочка #арти
00:41
Симбочка Пимпочка
Рет қаралды 4,7 МЛН
Молодой боец приземлил легенду!
01:02
МИНУС БАЛЛ
Рет қаралды 2 МЛН
Pulling Back the Curtain on the Heap
21:38
Jacob Sorber
Рет қаралды 37 М.
How one thread listens to many sockets with select in C.
12:01
Jacob Sorber
Рет қаралды 100 М.
How to write a multithreaded server in C (threads, sockets)
14:30
Jacob Sorber
Рет қаралды 137 М.
How do I access a single bit?
11:07
Jacob Sorber
Рет қаралды 22 М.
Safety and Speed Issues with Threads. (pthreads, mutex, locks)
9:13
What is a semaphore? How do they work? (Example in C)
13:27
Jacob Sorber
Рет қаралды 307 М.
Fixed and Variable Length Arrays in C and C++
20:24
Jacob Sorber
Рет қаралды 45 М.
When do I use a union in C or C++, instead of a struct?
11:18
Jacob Sorber
Рет қаралды 70 М.
Add a Simple LOADING BAR To Your Shell Scripts!
16:26
Cheesed Up
Рет қаралды 85 М.
Симбу закрыли дома?! 🔒 #симба #симбочка #арти
00:41
Симбочка Пимпочка
Рет қаралды 4,7 МЛН