Recent

Author Topic: i need JavaScript Engine for FreePascal - like V8  (Read 16615 times)

Coldzer0

  • Jr. Member
  • **
  • Posts: 50
i need JavaScript Engine for FreePascal - like V8
« on: August 19, 2018, 06:11:35 am »
hello all

i'm working on a project , and i need to implement js as plugin base script lang for the easy of use
the project will be open source .


i found besen engine but it's old and not supported anymore ( will use it if i didn't find any newer alternative )

i found this https://github.com/zolagiggszhou/v8delphiwrapper

i try to fix it to work with FPC but it uses RTTI and it's not compatible with FPC

so if there's any other js script engine like these please give a hint even if it's paid

thanks

Thaddy

  • Hero Member
  • *****
  • Posts: 14166
  • Probably until I exterminate Putin.
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #1 on: August 19, 2018, 06:18:54 am »
FPC already has a very powerful java script engine in pas2js. targets node.js and browsers.
You probably need trunk. see http://wiki.freepascal.org/pas2js.
Specialize a type, not a var.

Coldzer0

  • Jr. Member
  • **
  • Posts: 50
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #2 on: August 19, 2018, 06:43:27 am »
FPC already has a very powerful java script engine in pas2js. targets node.js and browsers.
You probably need trunk. see http://wiki.freepascal.org/pas2js.

i don't want convert pas to js

i want to to implement js inside a native fpc app like Besen and V8

this's a sample with besen https://gist.github.com/frostney/954706 << that's what i need

but as i say before besen is now old and not supported anymore


Thaddy

  • Hero Member
  • *****
  • Posts: 14166
  • Probably until I exterminate Putin.
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #4 on: August 19, 2018, 11:54:40 am »
Under windows you can use the Microsoft scripting engine to do that. For KOL I wrote a complete example that you can find here:
http://members.chello.nl/t.koning8/kolaxscript.zip

You need the ocx, just the dll's You can choose between vbs and js.

It is easy to rewrite for LCL. It also still works with KOL in Lazarus.
« Last Edit: August 19, 2018, 11:56:16 am by Thaddy »
Specialize a type, not a var.

salvadordf

  • New Member
  • *
  • Posts: 47
    • BriskBard
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #5 on: August 19, 2018, 12:25:16 pm »
Besides the v8 Delphi wrapper given in the first post :
https://github.com/zolagiggszhou/v8delphiwrapper

You also have a Chakracore wrapper for Delphi and Free Pascal :
https://github.com/tondrej/chakracore-delphi

There's a Javascript engine for delphi based on spidermonkey :
https://code.google.com/archive/p/delphi-javascript/

Maintainer of the CEF4Delphi, WebView4Delphi, WebUI4Delphi and WebUI4CSharp projects

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #6 on: August 19, 2018, 12:34:49 pm »
hello all

i'm working on a project , and i need to implement js as plugin base script lang for the easy of use
the project will be open source .


i found besen engine but it's old and not supported anymore ( will use it if i didn't find any newer alternative )

i found this https://github.com/zolagiggszhou/v8delphiwrapper

i try to fix it to work with FPC but it uses RTTI and it's not compatible with FPC

so if there's any other js script engine like these please give a hint even if it's paid

thanks
here is a javascript engine written in pascal no external libraries required https://github.com/BeRo1985/besen
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Coldzer0

  • Jr. Member
  • **
  • Posts: 50
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #7 on: August 19, 2018, 12:58:01 pm »
Perhaps Synode from the mORMot ?!
https://github.com/synopse/mORMot/tree/master/SyNode
https://synopse.info/forum/viewforum.php?id=22

DonAlfredo thanks so much
i download the project and build SM on Mac and it works fine  8-)

but the problem now with the "libmozjs-52.dylib" the size is "24 MB"

thanks again for posting the links  ;)

Under windows you can use the Microsoft scripting engine to do that. For KOL I wrote a complete example that you can find here:
http://members.chello.nl/t.koning8/kolaxscript.zip

You need the ocx, just the dll's You can choose between vbs and js.

It is easy to rewrite for LCL. It also still works with KOL in Lazarus.

it's a very good example but as my project is for Mac , win , linux
i think something like SpiderMonkey or V8 is good

Besides the v8 Delphi wrapper given in the first post :
https://github.com/zolagiggszhou/v8delphiwrapper

You also have a Chakracore wrapper for Delphi and Free Pascal :
https://github.com/tondrej/chakracore-delphi

There's a Javascript engine for delphi based on spidermonkey :
https://code.google.com/archive/p/delphi-javascript/


v8delphiwrapper not compatible with FPC :D

and chakracore library is big there's no way i'm using it  %)

and about SM the synopse implementation is really good and i tested it and it works fine
but as i said the library size is "24MB" compare to besen which is like "2 MB" or even V8 "13 MB"

here is a javascript engine written in pascal no external libraries required https://github.com/BeRo1985/besen

i know about it , if you read my first post you will see that

Quote
i found besen engine but it's old and not supported anymore ( will use it if i didn't find any newer alternative )

one of my friends point me to https://www.apexdatasolutions.net/products/muse
but i don't know where to download it


i think i'll try to implement "synopse SpiderMonkey" into my project as it's working very well
and i'll do the same with >> "besen" << cuz it's the easiest and smallest

now i'm searching for >> V8 Wrapper for FPC << not in priority

again thanks guys for your time and comments

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #8 on: August 19, 2018, 01:19:14 pm »
Perhaps Synode from the mORMot ?!
https://github.com/synopse/mORMot/tree/master/SyNode
https://synopse.info/forum/viewforum.php?id=22

DonAlfredo thanks so much
i download the project and build SM on Mac and it works fine  8-)

but the problem now with the "libmozjs-52.dylib" the size is "24 MB"

thanks again for posting the links  ;)

Under windows you can use the Microsoft scripting engine to do that. For KOL I wrote a complete example that you can find here:
http://members.chello.nl/t.koning8/kolaxscript.zip

You need the ocx, just the dll's You can choose between vbs and js.

It is easy to rewrite for LCL. It also still works with KOL in Lazarus.

it's a very good example but as my project is for Mac , win , linux
i think something like SpiderMonkey or V8 is good

Besides the v8 Delphi wrapper given in the first post :
https://github.com/zolagiggszhou/v8delphiwrapper

You also have a Chakracore wrapper for Delphi and Free Pascal :
https://github.com/tondrej/chakracore-delphi

There's a Javascript engine for delphi based on spidermonkey :
https://code.google.com/archive/p/delphi-javascript/


v8delphiwrapper not compatible with FPC :D

and chakracore library is big there's no way i'm using it  %)

and about SM the synopse implementation is really good and i tested it and it works fine
but as i said the library size is "24MB" compare to besen which is like "2 MB" or even V8 "13 MB"

here is a javascript engine written in pascal no external libraries required https://github.com/BeRo1985/besen

i know about it , if you read my first post you will see that

Quote
i found besen engine but it's old and not supported anymore ( will use it if i didn't find any newer alternative )

one of my friends point me to https://www.apexdatasolutions.net/products/muse
but i don't know where to download it


i think i'll try to implement "synopse SpiderMonkey" into my project as it's working very well
and i'll do the same with >> "besen" << cuz it's the easiest and smallest

now i'm searching for >> V8 Wrapper for FPC << not in priority

again thanks guys for your time and comments
As far as I know the author of besen is active in this forums from time to time, you could also try to contact him through github for support. There is not much suppor a script engine needs. if it is stable and extentable then the missing bits you might be able to write them your self (with out touching the engine's code).
Apex muse (if my crystal ball is working properly) is an evolution of the paxCompiler which was a very good engine if you want more info on the product you should contact apex keep in mind that is a commercial product and not open source.
In any case good luck and have fun.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

JernejL

  • Jr. Member
  • **
  • Posts: 92
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #9 on: August 20, 2018, 01:08:50 pm »
I don't see a problem with using besen, it's a mature project, with full and native source code (more portable than linking to libraries) and it has decent performance.
 
A few more examples would be nice, but these 2 projects are examples enough: 
 
This example was already linked to:
https://gist.github.com/frostney/954706
 
There is also this web socket server using besen, looks fully implemented:
https://github.com/reddor/besenws
 

Coldzer0

  • Jr. Member
  • **
  • Posts: 50
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #10 on: August 21, 2018, 09:23:55 pm »
As far as I know the author of besen is active in this forums from time to time, you could also try to contact him through github for support. There is not much suppor a script engine needs. if it is stable and extentable then the missing bits you might be able to write them your self (with out touching the engine's code).
Apex muse (if my crystal ball is working properly) is an evolution of the paxCompiler which was a very good engine if you want more info on the product you should contact apex keep in mind that is a commercial product and not open source.
In any case good luck and have fun.

i already try to contact Apex but no response  ::)

I don't see a problem with using besen, it's a mature project, with full and native source code (more portable than linking to libraries) and it has decent performance.
 
A few more examples would be nice, but these 2 projects are examples enough: 
 
This example was already linked to:
https://gist.github.com/frostney/954706
 
There is also this web socket server using besen, looks fully implemented:
https://github.com/reddor/besenws
 


i already chose it , it's the Smallest and for my need it's the best choice  :D
i really hope that BeRo can support this project cuz in some cases it's slow
but in total it's very good choice if anyone want to implement a bridge between his app and JS  8)

JernejL

  • Jr. Member
  • **
  • Posts: 92
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #11 on: August 22, 2018, 12:51:47 pm »
ope that BeRo can support this project cuz in some cases it's slow
but in total it's very good choice if anyone want to implement a bridge between his app and JS  8)

I hope we get some updates too, also have you tried strict js code?
 
Quote
Strict code runs faster than non-strict code, for that reason please use preferably "use strict" where is it possible, because at strict code is the arguments object creation cheaper at funtion calls, for example no setter/getter creation for each function argument in the arguments object.

tondrej

  • Newbie
  • Posts: 3
    • Ondrej Kelle
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #12 on: August 29, 2018, 01:33:17 pm »

You also have a Chakracore wrapper for Delphi and Free Pascal :
https://github.com/tondrej/chakracore-delphi

and chakracore library is big there's no way i'm using it  %)

For example, current (v1.11.0) ChakraCore Windows DLL is 4.6 MB for win32, 6.2 MB for win64.

Trenatos

  • Hero Member
  • *****
  • Posts: 533
    • MarcusFernstrom.com
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #13 on: August 29, 2018, 03:59:03 pm »
Wow, hadn't seen besenws before, definitely taking a look at that!

Thaddy

  • Hero Member
  • *****
  • Posts: 14166
  • Probably until I exterminate Putin.
Re: i need JavaScript Engine for FreePascal - like V8
« Reply #14 on: August 29, 2018, 05:04:42 pm »
For example, current (v1.11.0) ChakraCore Windows DLL is 4.6 MB for win32, 6.2 MB for win64.
Quite reasonable, considering it contains a JIT engine. (btw good job writing the interface)
What gets me annoyed is people here complaining about small but slow and want small and fast.
The larger size is due to the JIT engines. If they want fast, use one of the wrappers, if you want less code, go for an interpreter, but don't mix them up.
The V8 engine is also a couple of megabytes.
Specialize a type, not a var.

 

TinyPortal © 2005-2018