Re: half OOT, plv8js group created ^^ - Mailing list pgsql-hackers
From | Hitoshi Harada |
---|---|
Subject | Re: half OOT, plv8js group created ^^ |
Date | |
Msg-id | e08cc0400910300444t658fe6b0y8b943c959320912@mail.gmail.com Whole thread Raw |
In response to | Re: half OOT, plv8js group created ^^ (Andrew Dunstan <andrew@dunslane.net>) |
Responses |
Re: half OOT, plv8js group created ^^
|
List | pgsql-hackers |
2009/10/27 Andrew Dunstan <andrew@dunslane.net>: > > > Merlin Moncure wrote: >> >> On Mon, Oct 26, 2009 at 11:18 PM, Andrew Dunstan <andrew@dunslane.net> >> wrote: >> >>> >>> Kiswono Prayogo wrote: >>> >>>> >>>> plv8js is a procedural language add-on for PostgreSQL, which means you >>>> can define Javascript functions that run inside a PostgreSQL server >>>> using google V8 Engine. >>>> >>>> anyone who want to contribute in plv8js please visit this group ^^ >>>> http://code.google.com/p/plv8js/ >>>> i'm still new in postgresql and v8, need MASSIVELY LOT of study and >>>> help ^^, thank you.. >>>> >>> >>> Well, I see you are apparently ignoring the advice we already gave you >>> that >>> V8 is not likely to be the best fit for a PostgreSQL JS procedural >>> language, >>> so that's not a good start. >>> >> >> that's a little harsh...he was mostly given some vague advice >> ("spidermonkey might be better..."). Maybe it isn't the best, but >> that doesn't mean it's not worth trying! >> >> >> > > > Very well, if I was harsh I apologise, but maybe you should look at the > embedding guide here <http://code.google.com/apis/v8/embed.html> and decide > how well it is likely to work for PostgreSQL in pure C. The advice was not > just "spidermonkey might be better". It was that a C++ oriented API like > this (throwing exceptions among other things) was not likely to work, or at > least to work as well as a pure C API. > > And, frankly, pure PL speed in a language like JS, that is likely to be used > mainly as glue, is not likely to be a concern for most uses. +1 for v8 is the best engine for PL so far. SpiderMonkey has yield syntax which helps setof function to be made but quite slower than v8 in general purpose (and I want "fast" and flexible PL). Recent JavaScriptCore from Apple is so fast, may be than v8, but its build process is too complicated, it's because it is assumed that the engine is a part of Webkit. Of course there are concerns about C++ exception mechanism, annoying destructors, despite of that v8 is compact enough to be embedded. So, by chance, I have been working on plv8 for my own purpose and query like below is done: regression=# CREATE OR REPLACE FUNCTION plv8_test(keys text[], vals text[]) RETURNS text AS $$ var o = {}; for(var i=0; i<keys.length; i++){ o[keys[i]] = vals[i]; } return JSON.stringify(o); $$ LANGUAGE plv8 IMMUTABLE STRICT; CREATE FUNCTION regression=# SELECT plv8_test(ARRAY['name', 'age'], ARRAY['Tom', '29']); plv8_test ---------------------------{"name":"Tom","age":"29"} (1 row) There are still too many TODOs such like type conversion between JS and SQL, build system, and memory allocation. If you want I'll send you my code. > > If someone is going to work on a JS engine for PostgreSQL (which I think is > a good idea, actually) I want them to work on one that is likely to succeed. > Yeah, through these researches I concluded that a JS engine written by pure C is quite cool for PL. Most engines are assumed to be embedded in system like web browsers where optimization is "page-oriented" for example. And if we have such great feature like saving binary JSON in disk format, which is not done by any engine, PL/JavaScript would be the most powerful language. > cheers > > andrew > > -- > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers > Regards, -- Hitoshi Harada
pgsql-hackers by date: