On Sun, Sep 9, 2012 at 3:47 PM, Piotr Tarsa <[email protected]> wrote:

> Hi,
>
> I'm author of TarsaLZP - an lossless data compression algorithm - and I
> decided to port it to various languages. TarsaLZP was originally coded in
> x86 asm but that version is outdated now. Now there's a fresh Java version
> (located at: https://github.com/tarsa/TarsaLZP ) which I want to port to
> JavaScript. The question is: how to do it and where to get information
> about writing such things in JavaScript?
>
> Originally I planned to do a browser version of the JavaScript port but it
> turned out that it's impossible to do piping in browser JavaScript, there
> are not even a standardized and efficient way to save files from a
> JavaScript script. Now I'm thinking about making use of some V8 specific
> functions and run JavaScript from command line, but I can't find any
> information about such functions - particularly I'm interested about
> efficient buffered/ block binary input/ output, something like fread and
> fwrite from C's standard library. Is there something like that? How would
> you approach the problem? I also want to pass some options to the script,
> just like in command line Java version of my program.
>
> PS: I've started the porting initiative to compare performance of VMs/
> compilers and to learn something new :)
>
> Cheers,
> Piotr
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users



Hey Piotr,

I don't know if you want to have something like a website wherein you can
upload files and let the web application encode it for you - and give it
downloadable afterwards. That would be possible via the Drag & Drop and
File API, for example with its Blob Interface:
http://www.w3.org/TR/FileAPI/#blob

I only took a quick look over the core in your github repository, but as
long as you keep working buffer based, you should be able to use Typed
Arrays for it:
https://developer.mozilla.org/en-US/docs/JavaScript_typed_arrays

Most guys out there use the typed array implementation located here, or at
least ported it (like NodeJS):
https://github.com/tlrobinson/v8-typed-array/blob/master/typed-array.cc

TypedArrays are also available in SpiderMonkey/Firefox, if you are
targeting Web Browsers.


If you have binary output, you can theoretically convert it to a base64
encoded string afterwards and attach it to the DOM, having the user to
right click / save as... afterwards.

I think the main problem here is that your algorithm should include an
abstraction layer for how to get files and how to write file streams, so
that you can use them inside the BOM/DOM with different "HTML5 APIs" or if
you want to target Node - or V8 - with other low level APIs that are
available on the native side and offered to the JavaScript context.

If you are interesting in v8 based development and integrating custom data
types (like a File API via new File(url); or anything like that) you will
be forced to read much code, as there is pretty nothing in documentation.
For me it took a while to understand how the concept of the different
Templates in V8 are working.

Think you might take a look at the Texture data type that I introduced for
my V8GL runtime here, hope that helps you a bit:
https://github.com/martensms/lycheeJS-adk/blob/master/v8gl/src/api/texture.cpp


~Cheers,
Christoph

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to