
Awk driven IoT - Aissen
https://anisse.astier.eu/awk-driven-iot.html
======
nprescott
I'm reminded of two other surprising uses of Awk -- "Awk for AI"[0] and "awk-
raycaster"[1]

I really like Awk as a language because it integrates so well with shell
pipelines and it is incredibly small, while remaining high-level enough to be
practical, which I think this project demonstrates quite well.

[0]:
[https://web.archive.org/web/20140926113347/http://www.wra1th...](https://web.archive.org/web/20140926113347/http://www.wra1th.plus.com:80/awk/awkfri.txt)

[1]: [https://github.com/TheMozg/awk-
raycaster](https://github.com/TheMozg/awk-raycaster)

------
tannhaeuser
Awk is already well-known in embedded systems, eg. busybox implements a lot of
POSIX using awk IMO.

Also, awk syntax is clearly the predecessor of JavaScript. The following is
both awk and JavaScript:

    
    
        function f(x) {
            my_array[1] = "whatever"
            my_array["a string"] = "something else"
            if (x in my_array) return my_array[x] 
        }
    

It's all there: the "in" operator, no need for semicolon as statement
terminator, the "function" keyword, untypedness, regular expression constants,
C-like curly braces, etc.

~~~
chubot
Yeah Awk and JavaScript have surprisingly similar syntax. But the semantics
are very different. Here are some things I found when studying Awk a bit more:

\- Awk has no local variables! There is no "var". Believe it or not, people
fake locals with unused function parameters.

\- Awk has no dict literals like d={}. And no function literals like f =
function(x) { return x; }

\- Awk dicts can't be nested. You can't have something like: {key1: {key2:
123}} (using JS syntax)

\- Awk CAN accept dicts as parameters, but it CAN'T return them. "return d" is
invalid.

\- Awk can't take functions as parameters OR return them. That is, no higher
order functions.

The latter three facts are basically consequences of the fact that Awk has no
garbage collection. It has a strict stack discipline and no nested compound
data structures.

~~~
tannhaeuser
Yes, and another difference is the use of 1-based string indexes, as opposed
to 0-based string indexes in JavaScript. Even though I started with C many
years ago (where 0-based string indexes are there for a reason, unlike in Java
and JavaScript IMHO), I found 1-based string index semantics to allow much
more compact and idiomatic expressions for typical string massaging tasks.

------
hilti
Awesome project!

There's a company who developed a cute product around this type of technology.
It's a bestselling toy in Germany.

[https://tonies.de](https://tonies.de)

~~~
_pmf_
> It's a bestselling toy in Germany.

German here; never heard of it, but looks amazing for my daughter. Thanks for
mentioning this!

~~~
adrianN
Tape cassettes are a dime a dozen whereas you pay 15€ for a story tonie.
Inserting a cassette and pressing play is also not too difficult for a child.

~~~
hilti
That's true and I was really concerned about that pricing, too. What I like
about the Tonie: I need to travel a lot business wise and can use their app to
record e.g. sounds of a city, songs I play on my guitar etc. and deliver them
to my kids Tonie. Because it's connected to the home WiFi.

------
staticvar
Love it! I worked on a research project where we built a lot of CLIs to pull
data form a sensor, send it over a Unix Pipe to a push CLI for a database. It
offers some fun flexibility and really fast implementations.

[http://openpipekit.github.io/](http://openpipekit.github.io/)

------
srean
The article mentions mawk which is one of the faster awks I know of. Then
there is awka that compiles awk script to C. Do you know of other speed demons
apart from these. I think cleaning up the language by removing some of the
one-off constructs and making it more regular (npi) could make faster
implementations possible. An embeddable/extendable awk that exploits simd and
multicore could potentially lift a lot of weight.

I wish awk had more mind share than it does these days.

------
thisrod
I've been using AWK for decades, but the NFC avatars are new to me.

Has anyone started a business where you send in some photos, or sit for a
sculptor, then they 3D print a set of NFC caricatures for you? I imagine it
would be fairly easy to do, especially if the sculpture tutor at your local
art school was willing to help with hiring.

------
js2
Somewhat gratuitous use of awk. It could be bash driven IoT:

    
    
       ... | while read -r line; do
       file=
       case "$line" in
         *"03 52 c1 1a"*) echo "file1 "; file="file1.mp3" ;;
       esac
       if test -n "$file"; then
         mpg321 -q "$file" &
       fi
       done

------
gingerlime
Really cool project. I'm already using mpd on my rpi to play music (controlled
with the iPhone mPod app).

Would be cool to let my 3.5yr old boy play some songs he likes... But at his
age, I need to think of a more advanced physical controller or remote (any
suggestions?)

~~~
netsharc
Amazon Dash is a one-button solution, if he can't press buttons yet you just
need to hack it so another action triggers the "button press" event.

~~~
gingerlime
But how can he choose different tunes? Hope to find some kind of controller
that's fun for him to use.

... and of course he can press a button :)

~~~
netsharc
Have several dash buttons? Like in the article where each figure plays a
different tune.

Otherwise you'd have to macgyver a toy with giant buttons, build a Bluetooth
device onto it that sends a different signal for each button.

------
fundabulousrIII
Now really do an inet aware interface with (g)awk:
[https://www.gnu.org/software/gawk/manual/gawkinet/html_node/](https://www.gnu.org/software/gawk/manual/gawkinet/html_node/).

------
DroidX86
This is awesome!

~~~
bcook
Why, exactly?

~~~
Annatar
Because it's using a 41 year old language which has ultra low memory
requirements, no dependencies and runs like a bandit, on internet of things.
(And can be compiled to machine code by using Awka.)

In Bryan Cantrill's (paraphrased) words: "let there be an orgy of AWK one-
liners!"

(Or even better, entire applications written in AWK, since the language is
perfect for dynamically generating web applications.)

~~~
Blackthorn
To give the parent the benefit of the doubt, I think the point he was making
was less "this isn't awesome" and more "explain why you think it's awesome,
don't just place your upvote in the form of a comment".

~~~
bcook
Thank you. I expected that my addition of "exactly" would help, but honestly,
my post was rather lazy.

