[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can Lua replace awk?
- From: HyperHacker <hyperhacker@...>
- Date: Mon, 7 Mar 2011 04:05:57 -0700
On Mon, Mar 7, 2011 at 03:30, David Given <dg@cowlark.com> wrote:
> On 07/03/11 09:54, Alex Bradbury wrote:
>> On 7 March 2011 09:29, Axel Kittenberger <axkibe@gmail.com> wrote:
>>> Sure it can for you, but on a global "can lua replace awk", I'll say
>>> no. First awk is a quasi-standard, that is you can always asume it be
>>> installed on any *nix machine
>>
>> Even better than quasi-standard:
>> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html
>
> Hrm.
>
> Many years ago, when I was younger and a lot more stupid, I wrote a
> compiler in awk --- a full recursive descent compiler with types for a
> simple bytecode-based VM. The awk version was the bootstrap compiler and
> was about 1600 lines of code.
>
> awk is a really simple but slightly elegant language --- you can do a
> suprising amount in it for a language that doesn't even need a garbage
> collector! But the existing implementations are painfully slow; gawk is
> horrible, and the de factor default installation, mawk, is only a bit
> better.
>
> So it occurs to me it's probably possible to programmatically translate
> awk scripts into Lua and run them on the Lua VM (with optional JITing).
> With luck the result ought to be quite a lot faster. It would depend
> heavily on a decent regex library, of course. The ability to trivially
> extend awk scripts by adding Lua code to interface to the outside world
> could well be valuable to people with a large awk codebase.
>
> (If anyone cares, look at http://www.cowlark.com/mercat/ and it's
> com.awk inside the 'core' package. I eventually gave up when, after
> considerable effort, I ported the bootstrap compiler into my language
> and discovered that the awk version was substantially faster...)
>
> --
> ┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
> │ "Thou who might be our Father, who perhaps may be in Heaven, hallowed
> │ be Thy Name, if Name Thou hast and any desire to see it hallowed..."
> │ --- _Creatures of Light and Darkness_, Roger Zelazny
>
>
*Can* Lua replace awk? Sure, it's turing-complete. *Should* it?
Probably not. They serve quite different purposes.
--
Sent from my toaster.
- References:
- any easy 'batteries-included' way of installing Lua on linux (ubuntu to be specific), Jayanth Acharya
- Re: any easy 'batteries-included' way of installing Lua on linux (ubuntu to be specific), steve donovan
- Re: any easy 'batteries-included' way of installing Lua on linux (ubuntu to be specific), Jayanth Acharya
- Re: any easy 'batteries-included' way of installing Lua on linux (ubuntu to be specific), Matthew Wild
- Re: any easy 'batteries-included' way of installing Lua on linux (ubuntu to be specific), steve donovan
- Re: any easy 'batteries-included' way of installing Lua on linux (ubuntu to be specific), steve donovan
- Can Lua replace awk?, Dirk Laurie
- Re: Can Lua replace awk?, Axel Kittenberger
- Re: Can Lua replace awk?, Alex Bradbury
- Re: Can Lua replace awk?, David Given