ncurses is actually newer than the web - it's from 1993 and Tim starts the web in 1991 But it's called ncurses because it's the *new* curses. The curses library was invented to improve Rogue, over a decade earlier, so curses does pre-date the web and even most GUIs
@@monad_tcp ah old difficult cursing... like, "damn your lineage and let the fields run barren wherever you rest your head" as opposed to new more efficient cursing, "fuck you".
you also have the option to skip them with "--no-deps" I believe. Sometimes even docs take a while if you have a massive dependency tree and you just cargo cleaned lol
i like to use `anyhow::Result` in my projects cos it's shorter to use `?` than `unwrap` and it's basically `Box` but instead of `Box` they use `Own` or something and provide helper functions like `context` and `bail!`
Specifically, `Box` puts the vtable pointer in the box struct itself, turning it into a wide pointer; by contrast, `anyhow` puts the vtable pointer on the heap next to the thing that's boxed. This is slower, since it requires two dependent indirection where the first approach allows for parallel access (which with CPU pipelining is faster), but you don't really care if accessing your error is marginally slower usually and it means that if your non-error type in result is
You certainly don’t need a crate for handling errors and be able to use the ? operator.. All you need is a generic error struct and just implement From for MyError and you can use question mark operator everywhere.
@@yaksher Ideally your system shouldn't be throwing errors often enough for a performance impact like that to matter. I realize that's not always possible though, so of course there will be times where that may actually matter. But in general, that shouldn't be something you should worry about until the problem actually happens.
@@yaksher People on the internet love to think that some practically irrelevant difference in performance somehow actually matters in their code, and nowhere did you say "this performance difference is meaningless". I just wanted to make that crystal clear to the sizable portion of Tsoding's audience who are not experienced programmers and who have that tendency to be terrified of anything that remotely sounds like it might hurt performance without actually understanding things.
Maybe a weird question I guess but in your recent AMA, your answer to the question “how to learn programming” was to just fuck around. I personally struggle with getting an idea for a project and having the motivation for it. If someone makes me write some program or code, I will do research and do the best I can but I just struggle with getting an idea for a person project. What would you (or anyone) recommend?
I think he's encouraging people to follow their curiosity. That said, you might not feel any particular inspiration or passion for making projects, and that can be OK too. Have you tried making tutorials to teach others? Or, have you tried taking any courses? Some people learn better with structure, accountability, and clear goals, versus exploratory/self-directed learning.
i was inspired to have a simple personal project because of a movie, i watch some things that may inspire me to create something, you could try it this way.
@@maximus1172 it is just fear of making trash, you have to be humble and accept that anything you'll make at the beginninng will in fact be trash and then just iterate it till you have something that resembles a working program
The goal you mentioned at the start of the video (reserve the last line of the terminal for input and have conversations go on above it), reminds me when I was in high school and wanted to make my own terminal chat application. I also didn't want to use any library, and more importantly, was too lazy to learn ncurses. So I did it the non-portable hacky way as one would. Whenever a new message was received, I would just print "\b" `our_length` amount of times, where `our_length` is the length of the message our user is currently typing. Then print " " (space) `our_length` amount of times (\b doesn't remove the characters, it just makes ur cursor go back, so u need to write over them with a whitespace character). Now again print \b `our_length` amount of times to go back to the start of the line. Now print the received message, and then in the next line, print the user's currently typed-out message. This gave the illusion that the user has a dedicated text field.
I learned about `cargo tree` today. Love the paranoia-oriented programming approach, helps keep react andys from `npm install` onto 800+ deps for a hello world project at bay
That's partly due to node's godawful community though. When you're developing a library, you need to be extra aware of any dependencies you pull in. For small things which are only like 1 or 2 functions, it's often a better idea to just recreate that functionality yourself rather than include an otherwise unnecessary extra dependency. When writing something which isn't intended to be consumed as a dependency itself there's less need to be quite so paranoid about things.
@@Bobbias A decent model might be to have two ways of adding a library, either as a "dependency" or just copy-pasting it into your source tree. You could imagine something like "npm copy" to just stick the files right in your src/ so you can use them or modify them as if they were your own source code.
@@Bobbiasthe literally can't do that, imagine duplicating code that already exists elsewhere in the world. Imagine writing your own code. Totally "invented here" syndrome. Which is the opposite of not-invented-here in which you never use something you didn't make yourself. (which to be fair greatly simplifies and speeds up things, cut extremely the need for using outside libraries to a minimum)
Your loss, I guess. The benefits are well worth pushing past that early prejudice based on an emotional reaction to the syntax (assuming that's all it is).
In my humble opinion crossterm is here to stay. Lots of big crates/projects use it. In the worse case a fork will be made like for tui-rs (aka ratatui now) and the transition was seamless !
Why do people feel this need for validation. Does the library do what you need ? Do any other libraries have a feature the one you are using doesn't have, no, then I fail to see the problem. If they have then you swap the libraries, or implement the feature in the library you're using , this is open source, baby. And you literally have the source to fix shit later if it's needed. Why must people only use what's popular. I don't get it, what a stupid metric. If something works, it works, this is engineering, not fashion.
terminal raw mode? It is good practice to safe the original states of the terminal settings that you change and restore them on exit (guaranteed by something like an exit or defer mechanism). That is the first and last thing you should always do. Well, besides that little ctrl-c problem, hehehe
this is what coding is meant to be like. just having fun learning a library. none of this learn what a hook is, why we dont want class components,, call back vs async. I dont want a new paradigm of coding, i just want to show something on the screen.
As of 39:13, I don't know if you will explain more on the terminal flickering or not. But i tried build a terminal animation but a lot more simpler, and it was because of your previous video about bouncing ball on the terminal. I think the flickering can be solved by rendering it really fast like 60 frame per second
... does INCLUDE a call to if needed. Just because you guys otherwise hate superfluous keystrokes (Emacs-User, hehe) like the devil, don't you?:) :P But I get it. You do this because of your "IDE" and the headless duck programming style (error -> correct, error -> correct, error -> correct, and so on, hehehe) (secret-pro-200-iq-monster-tip-hint: rust-analyzer in the IDE/Emacs ... )
I recently boosted the sensitivity of my mousewheel, hearing yours each time you scroll reminded me. It is so nice to just go one notch and a bunch of lines now.
"Queue can fail" Wait... if it can fail... shouldn't the rust compiler just have... rejected the code altogether? I thought you weren't allowed to ignore fail cases in Rust... at least not without unrwapping or something...
At about 13:59ish minutes in you got annoyed about the compiler telling you you had unused imports and to remove them, but it then required you to put it back. The reason you initially had the unused import warning was because of your unwrap being in the wrong place, and therefore it was never actually requiring that type to be in scope, until you moved unwap to the correct line. I am no fan of Rust, but to be fair that isn't something that the compiler would have known to account for.
Except it is, why do you need to import things you don't use directly, aka transitive dependencies. Just do Hindley&Milter type inference on that. I'm kidding, that would make compile times almost infinite . Unless Rust is full of extension namespaces . Then it really is fair
GUI is also very easy in rust with something like egui & egui_inspect (fork, because egui_inspect is kinda dead). I've been meaning to try clap and ratatui for cli and tui, but not sure there's that much point (for me, since adding egui_inspect to my structs is trivial enough, except for maybe headless access).
egui_inspect is a fork of egui? egui is dead? what are you on about? egui_inspect is a crate with derive macros for egui itself egui is alive and well, last commit 6h ago
Would you mind telling me how i should feel about the rust programming language? I need something topical and snappy. Please I'm trying to base my whole personality off of this programming tool. Dude please
Actually not having a client and make everything work over something simple as netcat can be beneficial. The only problem is that server must do all the work of setting up terminal for you. Otherwise you can do netcat with rlwrap, but this limits you to one-line input, or do pipes in folders like ii does for IRC, where you can just cat file 'out' and write to other pipe 'in'.
@1:01:30 Named loops + breaks crying in the distance. @1:10:10 Range indexing, crying in the distance. Why would you just index from where you need instead of iterating the entire thing every time. That would be insane. @1:18:20 Sees it asking for parenthesis, immediately gives up instead of just putting the parenthesis where it said to (granted, the thing he ended up with is better, but still)
@@ElPikacupacabra I mean, in Rust: - you very rarely need cleanup because it's almost always done through destructors - you can just... put the cleanup after the loop? Like you would anyway?
At minute 10 it is sort of strange to see you making "fun" of the term queue and telling that the authors didn't know the term batch. Are you deadly sure one preceeds and fully includes the another?
You keep repeating yourself, I've noticed that it comes more often when you are out of the script. It denotes that your body is making use of Alternate Current for tasks that asks for Continuous Current. It is a backup so your system won't stall, but renders a choppier experience, undermining all your apparent strengths. Perfection comes primarily from brushing off imperfections. But it doesn't mean that the signal at the end will be better. In our case, perfection is when everything functions as expected, without extra loops.
@@vinos1629 I say that. But then again, I work in hardware design, we love politics in our industry. The company I work for, arm, has a policy to only use tools from the people who aren't total dipsticks and is very anti open source. Not saying rust is that, rust is baby compared to drama in our industry.
You can now add the -Zthreads=8 environment flag on the nigthly build to use the specified number of threads during frontend compilation which should make it faster.
i wonder if this terminal library can put a character in the lower right corner of the terminal without causing it to scroll to a new line. thats like the ultimate challenge for terminal libraries
41:39 lol I've been rereading the perl book, and one of their fundamental operators, alongside `+` and `*`, is `x`, the "string multiplication" operator, so literally `stdout.write("-" x w)` would do what you need here. I still don't know if perl is a good language but it's definitely a fun language