Message from discussion
Luerl - Lua in Erlang
Received: by 10.204.132.72 with SMTP id a8mr1514068bkt.5.1329745290599;
Mon, 20 Feb 2012 05:41:30 -0800 (PST)
X-BeenThere: erlang-programming@googlegroups.com
Received: by 10.204.45.87 with SMTP id d23ls5670806bkf.2.gmail; Mon, 20 Feb
2012 05:41:30 -0800 (PST)
Received: by 10.205.129.8 with SMTP id hg8mr1509042bkc.6.1329745290084;
Mon, 20 Feb 2012 05:41:30 -0800 (PST)
Received: by 10.205.129.8 with SMTP id hg8mr1509041bkc.6.1329745290056;
Mon, 20 Feb 2012 05:41:30 -0800 (PST)
Return-Path: <erlang-questions-boun...@erlang.org>
Received: from hades.cslab.ericsson.net (hades.cslab.ericsson.net. [192.121.151.104])
by gmr-mx.google.com with ESMTP id o5si22711695bkz.0.2012.02.20.05.41.29;
Mon, 20 Feb 2012 05:41:30 -0800 (PST)
Received-SPF: pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) client-ip=192.121.151.104;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) smtp.mail=erlang-questions-boun...@erlang.org
Received: from hades.cslab.ericsson.net (hades [192.121.151.104])
by hades.cslab.ericsson.net (Postfix) with ESMTP id 53E725C1FE;
Mon, 20 Feb 2012 14:41:22 +0100 (CET)
X-Original-To: erlang-questi...@erlang.org
Delivered-To: erlang-questi...@erlang.org
Received: from zimbra.erlangsystems.com (zimbra.erlangsystems.com
[93.93.131.195])
by hades.cslab.ericsson.net (Postfix) with ESMTP id 127A35C004
for <erlang-questi...@erlang.org>; Mon, 20 Feb 2012 14:41:20 +0100 (CET)
Received: from localhost (localhost.localdomain [127.0.0.1])
by zimbra.erlangsystems.com (Postfix) with ESMTP id 7FC34182E00A;
Mon, 20 Feb 2012 13:41:19 +0000 (GMT)
X-Virus-Scanned: amavisd-new at zimbra.erlangsystems.com
Received: from zimbra.erlangsystems.com ([127.0.0.1])
by localhost (zimbra.erlangsystems.com [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id W7xT8TcoNk2H; Mon, 20 Feb 2012 13:41:15 +0000 (GMT)
Received: from zimbra.erlangsystems.com (zimbra.erlangsystems.com
[93.93.131.195])
by zimbra.erlangsystems.com (Postfix) with ESMTP id 3F418182E008;
Mon, 20 Feb 2012 13:41:15 +0000 (GMT)
Date: Mon, 20 Feb 2012 13:41:15 -0000 (GMT)
From: Robert Virding <robert.vird...@erlang-solutions.com>
To: Henning Diedrich <hd2...@eonblast.com>
Message-ID: <ab31cfcc-c3a8-48d1-b57a-e1ac7e6d18a8@knuth>
In-Reply-To: <4F41D746....@eonblast.com>
MIME-Version: 1.0
X-Originating-IP: [192.165.126.77]
X-Mailer: Zimbra 7.1.1_GA_3196 (ZimbraWebClient - FF3.0 (Mac)/7.1.1_GA_3196)
Cc: Erlang Questions <erlang-questi...@erlang.org>
Subject: Re: [erlang-questions] Luerl - Lua in Erlang
X-BeenThere: erlang-questi...@erlang.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: General Erlang/OTP discussions <erlang-questions.erlang.org>
List-Unsubscribe: <http://erlang.org/mailman/options/erlang-questions>,
<mailto:erlang-questions-requ...@erlang.org?subject=unsubscribe>
List-Archive: <http://erlang.org/pipermail/erlang-questions>
List-Post: <mailto:erlang-questi...@erlang.org>
List-Help: <mailto:erlang-questions-requ...@erlang.org?subject=help>
List-Subscribe: <http://erlang.org/mailman/listinfo/erlang-questions>,
<mailto:erlang-questions-requ...@erlang.org?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============2738170773953745041=="
Errors-To: erlang-questions-boun...@erlang.org
Sender: erlang-questions-boun...@erlang.org
--===============2738170773953745041==
Content-Type: multipart/alternative;
boundary="=_bebe90b8-a64a-468e-9680-7c8ceaa14109"
--=_bebe90b8-a64a-468e-9680-7c8ceaa14109
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Hi Henning,
----- Original Message -----
> On 2/20/12 3:38 AM, Robert Virding wrote:
> > I have given some more comments in
> > http://news.ycombinator.com/item?id=3610332 .
>
> > Suggestions are welcome.
>
> >> Re ycombinator:
> >> "Lua is a nice, small, relatively clean language."
> I experience Lua as very magic, in the non-least surprising sense.
> It can be so overloaded that it can be hard to guess what a simple
> bit of Lua code really does. Which is maybe not ideal for an DSL
> Since __metatable is on the TODO list, maybe Luerl hasn't yet run
> into those waters.
I do implement metatables. What I meant was that in getmetatable and setmetatable I don't check for the __metatable key in the metatable, I just happily get/set the metatable. A bit of laziness from my side.
> I'd expect challenges there because the magic stems from Lua's
> formidable small- & cleanness -- or maybe Erlang turns out a
> marvelous fit. Certainly a very exciting side of the experiment.
> >> "However, the interface between Erlang and Lua in luerl is
> >> definitely faster so for smaller amounts of work it may be
> >> better."
> This is a very exciting point - and all it needs for an answer to the
> 'practical use' question. I'm anxious to see how you will eventually
> implement the tables.
I now implement tables using orddict, it mightn't be the most efficient for larger tables but for smaller tables it is good. It is also an easy data-structure to explicitly handle, which I need to do in some of the libraries. The global data record, #luerl{}, contains a tabs field which is the table store. Tables are referenced by index in the store, 0,1,2,3,4,... . Initially the store is also an orddict but I have versions where it is an array, the process dictionary and ETS tables. It works through macros. Orddicts are easy to read when testing/developing. #luerl{} also has fields for free indexes and the next index into the table store. There is a simple garbage collector for freeing/reclaiming unused table indexes.
You could vary the table implementation depending on their size; I have no feeling for how big tables get.
I also use tables for the block/function environments. It could probably done more efficiently, but most of the environments I have seen are quite small.
> To go for speed, wouldn't you have to make a choice based on table
> size? Isn't there an absolute threshold where lists and trees just
> become to expensive to 'udate'? I measured structures once and the
> cost of flat vs deep structures' mutations was as expected [1].
> Is it known lore from when on ets are more performant than, say,
> trees?
A bit difficult to say, it depends on the number of elements and their size. Ets is efficient on looking up elements, at least with their key, but copying large elements costs. I will get the different versions doing properly and do some proper timing.
> The table structure in Lua has been endlessly debated on the Lua
> list. Good thing you are probably striving for a true image rather
> than a 'better' Lua. The temptations would be endless.
> However, if you were to restrict yourself to a version that e.g.
> leaves metatables out, it would not really be Lua, but as a DSL
> still very useful. Maybe -- even more so.
Metatables are IN, they are definitely one of the more powerful features of Lua. I definitely want a "proper" Lua so I am striving to do as lua does.
Robert
> Henning
> [1] http://www.eonblast.com/blog/cost-of-mutation/
--=_bebe90b8-a64a-468e-9680-7c8ceaa14109
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<html><head><style type=3D'text/css'>p { margin: 0; }</style></head><body><=
div style=3D'font-family: Times New Roman; font-size: 12pt; color: #000000'=
>Hi Henning,<br><br><hr id=3D"zwchr"><blockquote id=3D"DWT585" style=3D"bor=
der-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;color:=
#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:=
Helvetica,Arial,sans-serif;font-size:12pt;">
On 2/20/12 3:38 AM, Robert Virding wrote:
<blockquote cite=3D"mid:aea670d2-54a4-4dbc-9334-cd60e9c74e30@knuth">
<pre>I have given some more comments in <a class=3D"moz-txt-link-free=
text" href=3D"http://news.ycombinator.com/item?id=3D3610332" target=3D"_bla=
nk">http://news.ycombinator.com/item?id=3D3610332</a> .
Suggestions are welcome.
</pre>
</blockquote>
>> Re ycombinator: <br>
>> "Lua is a nice, small, relatively clean language."<br>
<br>
I experience Lua as very magic, in the non-least surprising sense. <br>=
<br>
It can be so overloaded that it can be hard to guess what a simple
bit of Lua code really does. Which is maybe not ideal for an DSL<br>
<br>
Since __metatable is on the TODO list, maybe Luerl hasn't yet run
into those waters.<br></blockquote><br>I do implement metatables. What =
I meant was that in getmetatable and setmetatable I don't check for the __m=
etatable key in the metatable, I just happily get/set the metatable. A bit =
of laziness from my side.<br><br><blockquote id=3D"DWT586" style=3D"border-=
left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; colo=
r: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: =
none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;">
I'd expect challenges there because the magic stems from Lua's
formidable small- & cleanness -- or maybe Erlang turns out a
marvelous fit. Certainly a very exciting side of the experiment.<br>
<br>
>> "However, the interface between Erlang and Lua in luerl is
definitely faster so for smaller amounts of work it may be better."<br>=
<br>
This is a very exciting point - and all it needs for an answer to
the 'practical use' question. I'm anxious to see how you will
eventually implement the tables.<br></blockquote><br>I now implement ta=
bles using orddict, it mightn't be the most efficient for larger tables but=
for smaller tables it is good. It is also an easy data-structure to explic=
itly handle, which I need to do in some of the libraries. The global data r=
ecord, #luerl{}, contains a tabs field which is the table store. Tables are=
referenced by index in the store, 0,1,2,3,4,... . Initially the store is a=
lso an orddict but I have versions where it is an array, the process dictio=
nary and ETS tables. It works through macros. Orddicts are easy to read whe=
n testing/developing. #luerl{} also has fields for free indexes and the nex=
t index into the table store. There is a simple garbage collector for freei=
ng/reclaiming unused table indexes.<br><br>You could vary the table impleme=
ntation depending on their size; I have no feeling for how big tables get.<=
br><br>I also use tables for the block/function environments. It could prob=
ably done more efficiently, but most of the environments I have seen are qu=
ite small.<br><br><blockquote id=3D"DWT587" style=3D"border-left: 2px solid=
rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0)=
; font-weight: normal; font-style: normal; text-decoration: none; font-fami=
ly: Helvetica,Arial,sans-serif; font-size: 12pt;">
To go for speed, wouldn't you have to make a choice based on table size=
? Isn't there an absolute threshold where lists and trees just
become to expensive to 'udate'? I measured structures once and the
cost of flat vs deep structures' mutations was as expected [1]. <br>
<br>
Is it known lore from when on ets are more performant than, say,
trees?<br></blockquote><br>A bit difficult to say, it depends on the nu=
mber of elements and their size. Ets is efficient on looking up elements, a=
t least with their key, but copying large elements costs. I will get the di=
fferent versions doing properly and do some proper timing.<br><br><blockquo=
te id=3D"DWT588" style=3D"border-left: 2px solid rgb(16, 16, 255); margin-l=
eft: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font=
-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-se=
rif; font-size: 12pt;">
The table structure in Lua has been endlessly debated on the Lua
list. Good thing you are probably striving for a true image rather
than a 'better' Lua. The temptations would be endless.<br>
<br>
However, if you were to restrict yourself to a version that e.g.
leaves metatables out, it would not really be Lua, but as a DSL
still very useful. Maybe -- even more so.<br></blockquote><br>Metatable=
s are IN, they are definitely one of the more powerful features of Lua. I d=
efinitely want a "proper" Lua so I am striving to do as lua does.<br><br>Ro=
bert<br><blockquote style=3D"border-left: 2px solid rgb(16, 16, 255); margi=
n-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; f=
ont-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans=
-serif; font-size: 12pt;">
<br>
Henning<br>
<br>
<br>
[1] <a class=3D"moz-txt-link-freetext" href=3D"http://www.eonblast.com/=
blog/cost-of-mutation/" target=3D"_blank">http://www.eonblast.com/blog/cost=
-of-mutation/</a><br>
<br>
</blockquote><br></div></body></html>
--=_bebe90b8-a64a-468e-9680-7c8ceaa14109--
--===============2738170773953745041==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
--===============2738170773953745041==--