(no subject)

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

Duck-2
>Pm's technique is an interesting way to get around 
>the "nobody has the necessary prerequisites installed" 
>problem that tends to be a issue for alternative build 
>systems....

Indeed. I have my own build tree for Lua, from which I can build Lua as a 
stub linking to a Lua DLL plus package DLLs, a lua.exe with package DLLs 
which link back to it, or an all-in-one exe with packages 
statically-linked in (except for large ones, such as lxp, and for ones 
with non-free licences, such as lxysll, which has to be LGPL because xyssl 
itself is). And I can build for Windows or Linux. I am hoping to be able 
to have the luxury of building for OS X some time, but Apple's draconian 
restriction against virtualisation of their (open source based, if you 
don't mind :-) OS makes this unlikely...

...and I thought to do it in Lua, until I realised that I'd want to use my 
own build tree's Lua, else why have it, and then I'd have a bootstrap 
problem, and I so I ended up writing it in ...

...gawk, since it's standard both on Linux and in MSYS/MinGW.

Laugh if you will. I did.

Reply | Threaded
Open this post in threaded view
|

Re:

steve donovan
(g)awk is a lovely language. Look at those old books by Jon Bentley and
you'll see the oldtimers prototyping things in AWK. Was probably the
first scripting language, apart from BASIC and shell ;)

steve d.

On Feb 8, 2008 3:30 PM, Duck <[hidden email]> wrote:
>
> >Pm's technique is an interesting way to get around
> >the "nobody has the necessary prerequisites installed"
> >problem that tends to be a issue for alternative build
> >systems....
>
> Indeed. I have my own build tree for Lua, from which I can build Lua as a
> stub linking to a Lua DLL plus package DLLs, a lua.exe with package DLLs
> which link back to it, or an all-in-one exe with packages
> statically-linked in (except for large ones, such as lxp, and for ones
> with non-free licences, such as lxysll, which has to be LGPL because xyssl
> itself is). And I can build for Windows or Linux. I am hoping to be able
> to have the luxury of building for OS X some time, but Apple's draconian
> restriction against virtualisation of their (open source based, if you
> don't mind :-) OS makes this unlikely...
>
> ...and I thought to do it in Lua, until I realised that I'd want to use my
> own build tree's Lua, else why have it, and then I'd have a bootstrap
> problem, and I so I ended up writing it in ...
>
> ...gawk, since it's standard both on Linux and in MSYS/MinGW.
>
> Laugh if you will. I did.
>

Reply | Threaded
Open this post in threaded view
|

Re: gawk etc

David Jones-2

On 8 Feb 2008, at 14:03, steve donovan wrote:

(g)awk is a lovely language. Look at those old books by Jon Bentley and
you'll see the oldtimers prototyping things in AWK. Was probably the
first scripting language, apart from BASIC and shell ;)

awk is also, apart from shell, the only real programming language that guaranteed to be installed on a POSIX machine. All the language compilers like c90 and f77 are optional.

drj

Reply | Threaded
Open this post in threaded view
|

Re: gawk etc

Gavin Wraith
In message <3DC8AB4F-3D2B-433A-B731-D8191A985F8F@...> you wrote:

> On 8 Feb 2008, at 14:03, steve donovan wrote:
>
> > (g)awk is a lovely language. Look at those old books by Jon Bentley
> > and
> > you'll see the oldtimers prototyping things in AWK. Was probably the
> > first scripting language, apart from BASIC and shell ;)

Awk is what I used to use until I discovered Lua. Awk, too, is a language
that elicits affection, despite its shortcomings. See
http://www.wra1th.plus.com/awk/awkfri.txt

-- 
Gavin Wraith ([hidden email])
Home page: http://www.wra1th.plus.com/

Reply | Threaded
Open this post in threaded view
|

Re: gawk etc

steve donovan
On 2/8/08, Gavin Wraith <[hidden email]> wrote:
> Awk is what I used to use until I discovered Lua. Awk, too, is a language
> that elicits affection, despite its shortcomings

In the case of AWK (Aho,Weinberger and Kernighan) the shortcomings
were partly deliberate. The designers were suprised when people
started to write long awk programs, and took pity on them and added
functions ;)

steve d.

Reply | Threaded
Open this post in threaded view
|

Re:

Miles Bader
In reply to this post by steve donovan
"steve donovan" <[hidden email]> writes:
> (g)awk is a lovely language. Look at those old books by Jon Bentley and
> you'll see the oldtimers prototyping things in AWK. Was probably the
> first scripting language, apart from BASIC and shell ;)

Yes, I agree, awk is wonderful.  In many ways it's a far better
language, despite its limitations, than most of its purported
replacements (Lua excepted of course :-).

-Miles

-- 
In New York, most people don't have cars, so if you want to kill a person, you
have to take the subway to their house.  And sometimes on the way, the train
is delayed and you get impatient, so you have to kill someone on the subway.
  [George Carlin]

Reply | Threaded
Open this post in threaded view
|

Re:

Ben-2
Man, you guys are making me really want to look at and learn Awk.

On Feb 11, 2008 7:19 PM, Miles Bader <[hidden email]> wrote:
> "steve donovan" <[hidden email]> writes:
> > (g)awk is a lovely language. Look at those old books by Jon Bentley and
> > you'll see the oldtimers prototyping things in AWK. Was probably the
> > first scripting language, apart from BASIC and shell ;)
>
> Yes, I agree, awk is wonderful.  In many ways it's a far better
> language, despite its limitations, than most of its purported
> replacements (Lua excepted of course :-).
>
> -Miles

Reply | Threaded
Open this post in threaded view
|

Re:

Luiz Henrique de Figueiredo
> Man, you guys are making me really want to look at and learn Awk.

The 320-page GAwk manual by Arnold Robbins is really nice. It's
much more than a reference manual; it's called "GAWK: Effective AWK
Programming: A User's Guide for GNU Awk".

http://www.gnu.org/software/gawk/manual/

Reply | Threaded
Open this post in threaded view
|

awk (was: Re:)

David Given
In reply to this post by Miles Bader
Miles Bader wrote:
"steve donovan" <[hidden email]> writes:
(g)awk is a lovely language. Look at those old books by Jon Bentley and
you'll see the oldtimers prototyping things in AWK. Was probably the
first scripting language, apart from BASIC and shell ;)

Yes, I agree, awk is wonderful.  In many ways it's a far better
language, despite its limitations, than most of its purported
replacements (Lua excepted of course :-).

I think I can definitively pontificate on awk --- I wrote a compiler in it once. A full reverse-descent strongly typed bytecode-targeting language. Thinking back now, I must have been insane.

The biggest problems with awk: firstly, everything's a string:

1 == "1"     true
1 == "1.0"   false
1.0 == "1.0" false

This makes doing anything involving maths really unpleasant. You keep having to do 'n + 0' to force type conversion.

Secondly, the '' operator is string concatenation:

"foo" "bar"  -> "foobar"
1 "bar"      -> "1bar"
1 1.0        -> "11"

...which as you can see interacts nastily with the first problem. This can lead to some *ludicrous* typos.

Thirdly, no local variables; you fake them instead by using extra function arguments:

foo(arg1 arg2 var1 var2) { ... }

...which can obviously go terribly wrong if you pass too many arguments into a function.

Fourthly, no arrays.

This is a big one. There are associative arrays, but both the key and the value must be a string. This makes it rather hard to store complex data structures. There's syntactic sugar for multidimensional arrays of the form array[foo, bar], but that's identical to array[foo SUBSEP bar] where SUBSEP is a string containing a non-printing character... which makes *enumerating* such arrays highly entertaining!

That said, the entire compiler for my language came out at 1611 lines of highly structured and fairly readable code; and it ran astonishingly fast, too. When I rewrote the compiler in itself, compiled it with the awk bootstrap compiler and tried the result, it turned out to be considerably slower than the awk version (at which point I largely lost interest).

awk is a great language for things within its problem domain --- for text parsing, it's still considerably more elegant than Lua. It's got scaling problems, but for things that don't hit those limits, it's well worth checking out. To me, it forms a very nice middle ground between sed and perl (which I can't stand). The C-like syntax is nice and familiar, and the built-in support for things like regexps are first-rate. It's an ideal example of why domain-specific languages can be good.

But I wouldn't recommend writing a compiler in it.

If anyone actually *cares*, my doomed toy language Mercat and both versions of the compiler can be found here:

http://www.cowlark.com/mercat.html

...in the core021.zip package. (core030.zip is a later version where the language has acquired features that no longer work with the awk compiler.)

--
David Given
[hidden email]