The AWK Programming Language

Category: Computer Science
Author: Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger
4.4
This Month Stack Overflow 3

Comments

by anonymous   2019-07-21

It is kinda 'whooaoaa man, how can that work???' - but I think you are describing the phenomenon known as 'self-hosting':

Languages (or toolchains/platforms) don't start out as self-hosting - they start off life having been built on an existing platform: at a certain point they become functional enough to allow programs to be written which understand the syntax which it itself happens to be written in.

There is a great example in the classic AWK book, which introduces an AWK program which can parse (a cut-down version as it happens) other AWK programs: see link below.

There is another example in the book "Beautiful Code" which has a Javascript program which can parse Javascript.

I think the thing to remember on this - if you have (say) a JVM written in Java which can therefore run Java Byte code: the JVM which runs the Java JVM itself has to be hosted natively (perhaps this JVM was written in 'C' and then compiled to machine code) : this is true in any case of a self-hosting program eventually - somewhere along the line.

So the mystery is removed - because at some point, there is a native machine-code program running below everything.

It kinda of equivalent of being able to describe the English (etc) language using the English language itself....maybe...

http://www.amazon.co.uk/AWK-Programming-Language-Alfred-Aho/dp/020107981X/ref=sr_1_fkmr0_3?ie=UTF8&qid=1266397076&sr=8-3-fkmr0

http://www.amazon.co.uk/gp/search/ref=a9_sc_1?rh=i%3Astripbooks%2Ck%3Abeautiful+code&keywords=beautiful+code&ie=UTF8&qid=1266397435

http://en.wikipedia.org/wiki/Self-hosting

by anon   2019-07-21

In the original (and still the best) book, The AWK Programming Language, the following are implemented (among many other things):

  • a simple assembler
  • recursive descent compiler
  • a text indexing program

Try doing that with sed.

by anon   2019-07-21

The AWK Programming Language, by Aho, Kernighan and Weinberger is the best. The initials of the author's names should tell you why...

by fooblitzky   2019-04-19
_The AWK Programming Language_ ( https://smile.amazon.com/AWK-Programming-Language-Alfred-Aho... ) is one of the best programming books, on any language, in my opinion. Worth reading even if you don't use awk. In less than 200 pages it covers an introduction to the language, through to implementing a relational database, recursive-descent parsing, and graph-based algorithms.

For gawk, the manual covers the gaps between the language introduced in the book and the latest implementation.