News for hackers. Stuff that matters.
Re:Awk driven IoT by nprescott on Monday July 10, 2017 @12:12PM (#14737217)
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...

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

Re:Awk driven IoT by tannhaeuser on Monday July 10, 2017 @01:17PM (#14737841)
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.
Re:Awk driven IoT by chubot on Monday July 10, 2017 @01:30PM (#14737978)
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.

Re:Awk driven IoT by tannhaeuser on Monday July 10, 2017 @01:51PM (#14738157)
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.
Re:Awk driven IoT by kiwidrew on Monday July 10, 2017 @07:30PM (#14740505)
> busybox implements a lot of POSIX using awk

Citation, please?

It looks like busybox implements the 'dos2unix', 'tac', and 'unix2dos' commands as shell scripts that call 'sed'. And there are a couple of awk scripts (e.g. 'scripts/checkhelp.awk') that are used during the busybox build process. But as far as I can tell, all of the actual busybox applets are written in plain C.

I'd love to be wrong on this point, however -- I think that implementing a full POSIX userspace with just /bin/sh and /bin/awk is an awesome idea!

Re:Awk driven IoT by stephengillie on Monday July 10, 2017 @02:54PM (#14738646)
Add in dollar signs before the variables and you very nearly have valid Powershell as well.

>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

At some point, these polyglots must merge. It makes no sense to have arbitrary particles be the only distinction between languages.

Re:Awk driven IoT by krick on Monday July 10, 2017 @04:57PM (#14739593)
Is there any downside to using JS instead of Awk for one-line shell scripting? Maybe it's time to retire Awk, and use js/Perl/whatever instead for that purpose?
Re:Awk driven IoT by shakna on Monday July 10, 2017 @09:54PM (#14741062)
Awk is much faster, and much more consistent in its memory management, and doesn't have some of the things that trip people up in JS (== vs ===, order of operations).

Plus, awk is probably in any *nix system, and probably doesn't need any updates to behave as expected. (And my favourite little thing: awk's executable is tiny.)

Re:Awk driven IoT by hilti on Monday July 10, 2017 @10:53AM (#14736454)
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

Re:Awk driven IoT by Aissen on Monday July 10, 2017 @11:00AM (#14736508)
Wow, op here, I had never heard about tonies ! It seems to be exactly the same concept, awesome ! It seems good ideas happen at the same time :-)
Re:Awk driven IoT by _pmf_ on Monday July 10, 2017 @10:58AM (#14736493)
> It's a bestselling toy in Germany.

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

Re:Awk driven IoT by adrianN on Monday July 10, 2017 @12:40PM (#14737499)
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.
Re:Awk driven IoT by hilti on Monday July 10, 2017 @04:28PM (#14739342)
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.
Re:Awk driven IoT by hilti on Monday July 10, 2017 @04:29PM (#14739356)
My kids love it and highly recommend it. I never heard of it before until last XMAS.
Re:Awk driven IoT by staticvar on Monday July 10, 2017 @01:45PM (#14738104)
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/

Re:Awk driven IoT by srean on Monday July 10, 2017 @02:27PM (#14738430)
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.

Re:Awk driven IoT by thisrod on Monday July 10, 2017 @09:34PM (#14740978)
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.

Re:Awk driven IoT by js2 on Monday July 10, 2017 @05:25PM (#14739837)
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
Re:Awk driven IoT by gingerlime on Monday July 10, 2017 @11:16AM (#14736646)
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?)

Re:Awk driven IoT by netsharc on Monday July 10, 2017 @12:17PM (#14737268)
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.
Re:Awk driven IoT by gingerlime on Monday July 10, 2017 @03:29PM (#14738907)
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 :)

Re:Awk driven IoT by netsharc on Tuesday July 11, 2017 @10:49AM (#14744625)
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.

Re:Awk driven IoT by azinman2 on Monday July 10, 2017 @02:53PM (#14738630)
They have like a 4 second latency, which would be tough for a child.
Re:Awk driven IoT by fundabulousrIII on Wednesday July 12, 2017 @09:36AM (#14752382)
Now really do an inet aware interface with (g)awk: https://www.gnu.org/software/gawk/manual/gawkinet/html_node/.
[dead]
Re:Awk driven IoT by Jhsto on Monday July 10, 2017 @11:52AM (#14737031)
Please don't submit puns which can be found in other comments already. In general, you should only comment if it brings something new to the discussion.
Re:Awk driven IoT by ktta on Monday July 10, 2017 @05:06PM (#14739668)
>In general, you should only comment if it brings something new to the discussion.

This has been said already, so should you be commenting this?

Re:Awk driven IoT by Jhsto on Monday July 10, 2017 @06:08PM (#14740119)
You are right, it would not make sense to reply now. But at the time of my reply, the user account was 44 days old and the comment was at the top of the submission. I presumed the user among other people were not aware of HN guidelines.
Re:Awk driven IoT by ktta on Monday July 10, 2017 @07:54PM (#14740603)
My comment was intended to say that just like your comment might be new to them, their comment will be new to many. So there's no need to police them.

Everyone who signs up shouldn't have to look through all the popular comments of the past and then decide if they can comment or not. If it is annoying to you, downvote it. The fact that it was at the top should tell you that it is appreciated by many, so that comment isn't as well known as you might think.

Re:Awk driven IoT by DroidX86 on Monday July 10, 2017 @10:28AM (#14736206)
This is awesome!
Re:Awk driven IoT by bcook on Monday July 10, 2017 @10:36AM (#14736283)
Why, exactly?
Re:Awk driven IoT by Annatar on Monday July 10, 2017 @11:25AM (#14736757)
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.)

Re:Awk driven IoT by technofiend on Monday July 10, 2017 @01:14PM (#14737808)
Awk is pretty awesome - certainly one of my first loves. As I often do when it comes up in an HN thread if anyone has the artwork or is willing to scan said artwork of the infamous Bell Labs T-shirt I would be eternally grateful. It emphasizes the one weak point of AWK which is debugging. The shirt shows a gangly bird parachuting out of an airplane and reads "Awk bailing out near line 1"

The original as referenced here - ftp://minnie.tuhs.org/UnixArchive/Documentation/Books/Life_with_Unix.pdf - is no longer available as "The Independent UNIX Bookstore" no longer exists.

Re:Awk driven IoT by coliveira on Monday July 10, 2017 @05:02PM (#14739637)
Re:Awk driven IoT by Blackthorn on Monday July 10, 2017 @11:29AM (#14736800)
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".
Re:Awk driven IoT by bcook on Wednesday July 12, 2017 @12:22PM (#14753825)
Thank you. I expected that my addition of "exactly" would help, but honestly, my post was rather lazy.