mawk, the fastest computer language around...

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

mawk, the fastest computer language around...

#1 Post by musher0 »

Hello, Puppyists.

According to http://awk.info/?doc/news/mawkIsFast.html, mawk is faster than
C, C++, Java, Perl, Ruby,.. They say it's the fastest computer language around. Now
that's pretty enormous to say, but the people at awk.info seem to be able to back
it up: they have test benches showing that mawk can handle large bundles of data
fast and splendidly.

I for one feel that mawk is faster than both nawk and gawk, but it's an impression
rather than a fact. I'm too busy writing Puppy scripts these days to pause and
validate that statement. :D However those of my bash scripts that contain awk
lines or statements do feel speedier running with mawk.

~~~ Edit, April 22, 2016: ~~~
Please see below for local download.
~~~ End of edit. ~~~

I realize that gawk is present on all Puppies. However it is not known for its speed,
and some believe that it is not a real awk in the sense that it has "proprietary"
commands not found on run-of-the-mill awks. gawk is also mammoth-sized (over
400k) compared to mawk's 160k.

This package includes a pdf on mawk to get you started. There are of course
numerous resources on-line for awk generally. This search
http://www.ask.com/web?qsrc=1&o=0&l=dir ... archTopBox
should provide a good jumping board for anyone interested in the awk language.

As for me, I like awk because
  • * its logic is not foreign to my regular thinking as a language worker (which
    __ I am by trade);
    * anyone with a minimum of logic can understand its basic concept of line and
    __ column or record and field processing;
    * it's not cryptic or "savant"; and
    * it interfaces wonderfully with the bash script language we have on Puppy.
Enjoy!
Last edited by musher0 on Fri 22 Apr 2016, 14:07, edited 5 times in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#2 Post by slavvo67 »

Musher0:

I'm jumping in to play. Do you have any sample scripts to get me started?

Best,

Slavvo67

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#3 Post by musher0 »

Hello, slavvo67

Here is my series of opera bookmarks for awk.
You'll find in there four references to awk one-liners.
Try some? :)

BFN.

musher0
Attachments
awk.html.zip
(2.98 KiB) Downloaded 232 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#4 Post by slavvo67 »

I guess the real issue here is how to use mawk as more than just an awk substitute. If it's speed is really that fast, it would be great if there was a way to use it beyond the typical awk type uses.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#5 Post by musher0 »

Hi, slavvo67.

The answer is yes and no. Certainly we should try to write and run complete awk
program with mawk, but I won't snub the use of the occasional (m)awk sub-routine
within an ash or bash script.

I mention ash because it executes scripts +/- 150 % faster than bash. ash+mawk
seem to be a winning combination if we're considering speed. However, ash has a
more limited set of commands than bash.

One can search the difference between ash and bash to his/her heart's content :)
via
http://www.info.com/searchw?qkw=diferen ... &qhqn=&KW=

Come to think of it, if you are bringing up the question, maybe it's because you
already have some awk programs you'd like to share ? :)

BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#6 Post by slavvo67 »

I respect that Ash comment. Were you the one that first noticed that speed difference? It's quite substantial depending on the script. Now you did it... you have me digging through my old scripts seeking some of my better uses of awk. Funny on how many use sed and grep and how few actually use awk. That said, I think awk's a great tool for the right purpose. Here's one but it's not mine. INSTADONE.txt is the name of my original text file so that would be replaced with whatever text file you have. INSTADONE1.txt is just a temporary so it could be named anything, really.

The below removes dupe lines from a text file, and if I recall correctly; they don't need to be next to each other for it to work.

awk '!x[$0]++' INSTADONE.txt >INSTADONE1.txt
mv INSTADONE1.txt INSTADONE.txt

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#7 Post by musher0 »

slavvo67 wrote:(...) Now you did it... you have me digging through my old scripts seeking some of my better uses of awk. (...)
Haha ! :) The cat's out of the bag! :) I knew it! :)

Ok, folks: we have a awk programmer amongst us! ;)
He just has to brush some dust off his stuff! :)

BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#8 Post by 8-bit »

Somewhere along the line of downloading mawk, I got connected to a site called marriage chat with the picture of a young lady and a chat window with the line "Why don't you join now?"
Not what I was expecting.
I will have to check out the mawk programming language though.

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#9 Post by slavvo67 »

So you tested Mawk and got married! What a day! LOL

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#10 Post by musher0 »

slavvo67 wrote:So you tested Mawk and got married! What a day! LOL
Yeah, 8-bit, you must be exhausted! :)
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#11 Post by musher0 »

Hello all.

This the latest mawk: same version number but dated May 3rd 2015.

This time I'm presenting it in an archive small enough to fit as an attachment on the
forum. (Please see below.) Compiled on Slim-6, a derivative of Slacko-6_32 bit.

This pet package does not offer documentation, except for a man file. You'll find it online
at http://invisible-island.net/mawk/mawk.h ... umentation. There, you'll see a
variety of formats in the top line: your choice, really.

Note: the Puppy default symbolic "awk" link to gawk in /bin will be replaced with a link to
mawk. But gawk is not removed: just change back the symlink if you have to use gawk.

Enjoy!
Attachments
mawk-1.3.4.pet
(77.51 KiB) Downloaded 159 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#12 Post by step »

musher0 wrote: Note: the Puppy default symbolic "awk" link to gawk in /bin will be replaced with a link to
mawk. But gawk is not removed: just change back the symlink if you have to use gawk.
Which makes me want to add one more tip for anyone using awk in their scripts, "be explicit". If your awk script uses gawk-specific features (there are many!) then have your script call gawk. That little 'g' makes all the difference between a script that fails for some puplets and one that doesn't. Same tip goes for mawk specific features. awk isn't gawk isn't mawk - they're cousins :)
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#13 Post by musher0 »

step wrote:
musher0 wrote: Note: the Puppy default symbolic "awk" link to gawk in /bin will be replaced with a link to
mawk. But gawk is not removed: just change back the symlink if you have to use gawk.
Which makes me want to add one more tip for anyone using awk in their scripts, "be explicit". If your awk script uses gawk-specific features (there are many!) then have your script call gawk. That little 'g' makes all the difference between a script that fails for some puplets and one that doesn't. Same tip goes for mawk specific features. awk isn't gawk isn't mawk - they're cousins :)
Ah, family trees! ;)
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

#14 Post by Sailor Enceladus »

No comparisons between mawk and ASM? With ASM you can talk directly to CPU registers without having to travel to the RAM/cache and back, saving a ton of cpu cycles, and since ASM is only one level up from machine language it is easy to pinpoint exactly what is happening in every single instruction. With higher levels like mawk there is less transparency and control. ASM ftw! :lol: (goes back under a rock and boots into my non-API-wrapped 100K FreeDos OS, it even has tree! Lol <3 )

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#15 Post by musher0 »

Sailor Enceladus wrote:No comparisons between mawk and ASM? With ASM you can talk directly to CPU registers without having to travel to the RAM/cache and back, saving a ton of cpu cycles, and since ASM is only one level up from machine language it is easy to pinpoint exactly what is happening in every single instruction. With higher levels like mawk there is less transparency and control. ASM ftw! :lol: (goes back under a rock and boots into my non-API-wrapped 100K FreeDos OS, it even has tree! Lol <3 )
Hi Salior.

The URL for awk.info in my original post mentions that mawk is faster than the other awks
and a whole bunch of ruby's, plus a couple of perl's and python, but no ASM is mentioned.

Maybe mawk itself has been written in ASM? Who knows.

So you like forests, eh? ;) Me too!
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply