🤔 How do I/O compare to CPU tasks in terms of speed?
I/O are 3-4x slower than CPU tasks which just happen in the processor
the async event loop is a much better model than threads for the I/O tasks
node gives you high throughput low latency I/O communication
Command-line scripts
🤔 What is POSIX?
It’s a way that C-style programs interact with a linux system.
process.argv’s first two arguments: path to my node installation, full path to the file
💡 You can run process.argv.slice(2) to chop them off!
File System
Streams
simplex stream: you can either read or write to it
duplex stream: you can do both
Gzipping
Waiting until the end of stream
🤔 What is the advantage of the streaming protocol? (aka why chunks?)
Not only it’s more efficient it also uses less memory (65kb buffer size at a time, by default)
Database
🤔 What are advantages of using SqLite?
Unlike MySQL, lite doesn’t require a db server, instead, it’s a serverless embedded db that runs as part of the application. It cannot connect to any other application over the network. It’s super lightweight and ideal for small sets of data.
How to join a table
Web servers
Express routing and static file serving
Child process
how to deal with node across multiple processes, specifically how to spin up child processes from our main process
one way of testing whether a command was successfully run (aka non 0 exit code), is to chain another command after it. If the original command errored it will immediately exit and not run the next command, e.g.: node index.js && ls -la
Debugging
go to chrome inspect and when you run add the --inspect flag