Re: Is that possible to implement Sqlite.jsm with ctypes so that is can works in the worker?

2015-11-21 Thread Philip Chee
On 20/11/2015 19:51, Till Schneidereit wrote:
> On Fri, Nov 20, 2015 at 12:23 PM, David Rajchenbach-Teller <
> dtel...@mozilla.com> wrote:
> 
>> It could be improved a bit, but the real issue is that JavaScript is a
>> high-level, garbage-collected, dynamic programming language, while C is
>> a low-level, memory-unsafe, type-unsafe, statically compiled programming
>> language.
>>
>> I have heard a few ideas floating around on how this could be improved,
>> by using a radical redesign of js-ctypes based on asm.js/WebAsm, but at
>> the moment, I don't think that anybody is working on it.
>>
> 
> Reimplementing js-ctypes on top of TypedObjects would also work. But those
> still aren't anywhere near being standardized, so it'll be a while until
> that's a possibility.

A quick bit of googling brings up the Lua C API which is based on the
concept of a virtual stack.

[quote]
A major component in the communication between Lua and C is an
omnipresent virtual stack. Almost all API calls operate on values on
this stack. All data exchange from Lua to C and from C to Lua occurs
through this stack. Moreover, you can use the stack to keep intermediate
results too. The stack helps to solve two impedance mismatches between
Lua and C: The first is caused by Lua being garbage collected, whereas C
requires explicit deallocation; the second results from the shock
between dynamic typing in Lua versus the static typing of C.
[/quote]

Phil

-- 
Philip Chee , 
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Is that possible to implement Sqlite.jsm with ctypes so that is can works in the worker?

2015-11-20 Thread David Rajchenbach-Teller
It could be improved a bit, but the real issue is that JavaScript is a
high-level, garbage-collected, dynamic programming language, while C is
a low-level, memory-unsafe, type-unsafe, statically compiled programming
language.

I have heard a few ideas floating around on how this could be improved,
by using a radical redesign of js-ctypes based on asm.js/WebAsm, but at
the moment, I don't think that anybody is working on it.

Cheers,
 David

On 20/11/15 12:03, Philip Chee wrote:
> On 18/11/2015 16:04, David Rajchenbach-Teller wrote:
>> Well, the main problem is that js-ctypes is very hard to use, even
>> harder to use without causing memory leaks or crashing the process.
>> Think the worst parts of both C and JavaScript together.
> 
> Are these problems inherent in ctypes or is it just that our
> implementation is broken?

___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Is that possible to implement Sqlite.jsm with ctypes so that is can works in the worker?

2015-11-20 Thread Philip Chee
On 18/11/2015 16:04, David Rajchenbach-Teller wrote:
> Well, the main problem is that js-ctypes is very hard to use, even
> harder to use without causing memory leaks or crashing the process.
> Think the worst parts of both C and JavaScript together.

Are these problems inherent in ctypes or is it just that our
implementation is broken?

> Cheers,
>  David
> 
> On 18/11/15 08:57, Philip Chee wrote:
>> On 14/11/2015 18:21, David Rajchenbach-Teller wrote:
>>> Actually, Sqlite.jsm does most of its work off the main thread.
>>>
>>> But yes, it would clearly be possible to reimplement Sqlite.jsm using
>>> js-ctypes for workers. If you wish to work on this, I can try and help
>>> mentoring.
>> 
>> I thought people were being encouraged to avoid using js-ctypes because
>> of "problems". However nobody has gone into detail about what those
>> alleged problems are.
>> 
>> Phil
>> 


-- 
-==-
Philip Chee , 
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Is that possible to implement Sqlite.jsm with ctypes so that is can works in the worker?

2015-11-18 Thread Philip Chee
On 14/11/2015 18:21, David Rajchenbach-Teller wrote:
> Actually, Sqlite.jsm does most of its work off the main thread.
> 
> But yes, it would clearly be possible to reimplement Sqlite.jsm using
> js-ctypes for workers. If you wish to work on this, I can try and help
> mentoring.

I thought people were being encouraged to avoid using js-ctypes because
of "problems". However nobody has gone into detail about what those
alleged problems are.

Phil

-- 
Philip Chee , 
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Is that possible to implement Sqlite.jsm with ctypes so that is can works in the worker?

2015-11-18 Thread David Rajchenbach-Teller
Well, the main problem is that js-ctypes is very hard to use, even
harder to use without causing memory leaks or crashing the process.
Think the worst parts of both C and JavaScript together.

Cheers,
 David

On 18/11/15 08:57, Philip Chee wrote:
> On 14/11/2015 18:21, David Rajchenbach-Teller wrote:
>> Actually, Sqlite.jsm does most of its work off the main thread.
>>
>> But yes, it would clearly be possible to reimplement Sqlite.jsm using
>> js-ctypes for workers. If you wish to work on this, I can try and help
>> mentoring.
> 
> I thought people were being encouraged to avoid using js-ctypes because
> of "problems". However nobody has gone into detail about what those
> alleged problems are.
> 
> Phil
> 
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Is that possible to implement Sqlite.jsm with ctypes so that is can works in the worker?

2015-11-14 Thread David Rajchenbach-Teller
Actually, Sqlite.jsm does most of its work off the main thread.

But yes, it would clearly be possible to reimplement Sqlite.jsm using
js-ctypes for workers. If you wish to work on this, I can try and help
mentoring.


Cheers,
David

On 14/11/15 10:45, Yonggang Luo wrote:
> The current Sqlite.jsm can only work in main thread, that's would be a
problem when inserting a lot of data.
> ___
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Is that possible to implement Sqlite.jsm with ctypes so that is can works in the worker?

2015-11-14 Thread Yonggang Luo
On Saturday, November 14, 2015 at 6:21:34 PM UTC+8, David Rajchenbach-Teller 
wrote:
> Actually, Sqlite.jsm does most of its work off the main thread.
> 
> But yes, it would clearly be possible to reimplement Sqlite.jsm using
> js-ctypes for workers. If you wish to work on this, I can try and help
> mentoring.
> 
About js-ctypes, is that possible to port the mozilla's js-ctypes to v8 engine 
and other javascript engines, so that if I write down the js binding for 
sqlite, other js engines can also use the same API, and I am interested know if 
the node-ffi have advantages above mozilla's js-ctypes.
> 
> Cheers,
> David
> 
> On 14/11/15 10:45, Yonggang Luo wrote:
> > The current Sqlite.jsm can only work in main thread, that's would be a
> problem when inserting a lot of data.
> > ___
> > dev-platform mailing list
> > dev-platform@lists.mozilla.org
> > https://lists.mozilla.org/listinfo/dev-platform
> >

___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform