Taco Bell Programming (WIP)
added on 2022-08-29
This is the second post, in my new series where I show how I use the commandline, for casual daily stuff, mostly unrelated to my daily work.
This post is less of how I use them, and more of how else I can use them.
This post has been inspired by this post by teddziuba here
My objectives out of this post ?
- What are the core tenants of this style of programming, How do you define it ->
- How is it different from an imperative programming language ? (like Python)
- Can I overcome the limitations ? , if so how ? ->
- Figure out if i can code new projects faster with this style ->
- If so, how should I lay out code for different projects, in line with this style of programming
- When does this style work ? and when does it not ? (Usecases | Limitations)
- How to do error reporting ?
- How to log ? (syslog ?)
- How to do profilling / monitoring ?
- What language should i use to write tacoscripts , bash or haskell ? ->
- A standard for writing new tools to extend this community ->
I’ll be modifying the article, as more ideas and setbacks are faced while exploring this style.
I look forward to this venture to bear fruits in my productivity while building new products.
The UNIX style of programming, using text parsing , line oriented way to pass information between programs, to end up with a larger program.
What are the core tenants
- Write multiple reusable programs which are atomic in terms of its tasks, and can be slapped together to do something bigger
- i.e parsing programs, should never do anything else, aka grep, sed, cut, awk, etc.
- i.e data extraction from programs from raw pile should be seperate, aka find, curl, lynx, etc.
- i.e action programs, should be seperate, aka notify-send, sendmail, alert, touch, mkdir, rm, etc.
- Should data be sent both ways ?
- If we allow it, a lot of interaction between programs get abstracted away.
- programs might lose modularity. i.e some programs might be incompatible bi-directionally with others
- Only necessary in complex usecases.
- Limitations of not sending data both ways ?
- An ingester digesting content cannot modify its behaviour based on data being parsed,
by a program down the line - Hard to represent interactions, where user wants an updated status based on a particular interaction\ example:- A user submits an email form, and wants instant reply, shell scripting is prolly a bad idea for this
- Further splitting of codebases.
Code inter-related to code expressed in tacostyle, might need to be written in python3.
This causes the programmer to refer to both places to figure out how a business logic works. - Security Nightmare Shell escape is a real threat
- An ingester digesting content cannot modify its behaviour based on data being parsed,
Rapidly Reactive Stateful Programs should be avoided from being coded in this style of programming
Can I overcome it ?
The limitation of being hard to express web servers and replies
I could in theory script intent in form of data for example a dsl like
:<POST/GET/PUT/DELETE>: (action)
:<POST/GET/PUT/DELETE>: (action)
and use this DSL, to auto generate new code in FastAPI / Flask / Django / Typescript / other frameworks to auto write the boilerplate code, this should cut down on a lot of code writing , combine this with vipe to get even better result, e.g
cat template/webdsl | vipe | toFastAPI >> appendableapiserver.py
The security limitation could be overcome using bubblewrap, providing a safe environment to process all of this
Tools that can aide me with this
- A tool to auto pull cheatsheet based on context, an interactive interface where if i type *.py, all python cheatsheets are shown if i type fastapi, fuzzy search is used to display while typing and then all specific cheatsheets are displayed (design this taco style)
- A tool to annotate items with data, systemfiles, urls, etc and store it and make it surfaceable when needed ( just use mkfifo )
- Use the custom job queue i built in Postgres as a mkfifo alternative
- A cli tool with gitblame to ask the correct person answer to some questions
- A suggestions tool, runs as a cron job, pulls whatever data it needs to and builds out the suggestion list
- A tool to copy output from to a central store, which can be extracted again to stdout, by other programs, using clicommand (storeto) do i need this ? (use mkfifo)
- DO NOT USE dnpipes this or any similar implementation, as multiple readers to a pipe is PAIN, just use kafka, and at max, stream it out to localnamed pipes using python3 scripts
Can I code faster with this style ?
Let’s find out.
Build a new page template
cat hugopage.md | ,grep-md > mdpage.md
cat hugopage.md | ,grep-yaml | md2html mdpage.md | ,appendCSS tufte > finalpage.html
Send an email to all subscribers in an email list and update blacklist
cat subscribers.txt | sort | uniq | ,filter --csv --json --plain blacklist | ,toCSV subscribers.csv
cat emailcontent.md | toEML --assert-dir "assets/" --from "teito@teitoklien.com" --to-list subscribers.csv --outdir "shortcuts29th-email/"
mkfifo emailfeedback
awsfeedbackapp > emailfeedback
cronit @5mins: cat emailfeedback | ,genBlackList --pre oldlist > newlist.txt && ,mv newlist blacklist
# parsefeedback and update blacklist every 5 mins
The Standard
- All new cli tools must have ability to interface with storeto reserve directly to catch parameters
- Use && to concat independent actions
- Use tee and process substitution when necessary (refer here)
- Use namedpipes using mkfifo, whenever necessary to combine programs running and interfacing independently\ e.g: building queues/buffer using mkfifo
- All personally made/maintained cli tool name should start with a ,
- On passing no param and no stdin, Usage should be displayed
- All personally made tools, should have a man page displayed
- All commands should have a –dry option to not do anything but just output what it will do
- Use environment variables cautiously , and try to be explicity in cmdline itself instead
- Combine it with literate programming (refer here)
- Use makefile to further extend this style of shell scripting (refer here)
What language should i use
Actually, python3 kek.
How ?
A combination of
- This new pipe library here tutorial
- This literate programming lib here
- Mindfullness while coding, avoid repeating yourself
Bash should be there too, but less of it and only for personal onetimer use, not for day to day project specific work.
Other notes
References
- post by teddziuba here
- another post on makefiles by teddziuba here
- python and pipes unix series by lyceum here
Contact/etc
I’m mostly exploring this style of programming as an idea and thinking of how many places and how many ways, I can use this style to my advantage.
If you have more ideas on how I can improve this even more, or have questions that you think might be relevant to this discussion.
Email them to me at teito@teitoklien.com
I’ll add a link here to my next post in this series, when It’s ready,
Appended on 2022-08-30:
Here it is Brewing a Taco-style Flavoured Python