Newsletter # 3 - Understanding the RunLoop model Oct 4 2019

Hello,

This week I spent some time away from the computer relaxing and visiting San Francisco. Had such a good time with friends I haven't seen in a long time.

This week's post was about understanding the RunLoop. We used a basic shell implementation to show how to use different input sources on our RunLoop. There are not many examples on how to do this, and I feel that the RunLoop is central to the macOS architecture, and understanding it helps us design better applications.

If you miss it, here's the link to the article: [https://rderik.com/blog/understanding-the-runloop-model-by-creating-a-basic-shell/]

Also, I hope you enjoy the use of ANSI/VT100 Terminal Control Escape Sequences on the example. Escape sequences are useful when creating command-line tools.

Ok, that's it for this week. I'll go now and have dinner with friends. Until next week.

Derik

Tip of the week

You could use argv[0] (The first argument when running a command-line tool) as a switch.

For example, let's say you have script myscript.sh and then create a symlink:

1
$ ln -s myscript.sh myotherscript.sh

If you run myotherscript.sh the name will be different in argv. You can have a flow-control check based on argv[0]'s value. You can have the script behave in a certain way when running as myscript.sh and in a different way if it's running as myotherscript.sh. Quite useful if you would want your script to provide a set of utilities depending on the filename and location.


** If you want to check what else I'm currently doing, be sure to follow me on twitter @rderik or subscribe to the newsletter. If you want to send me a direct message, you can send it to derik@rderik.com.