Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Community] What are you building with ChakraCore? #2575

Closed
dilijev opened this issue Feb 22, 2017 · 55 comments
Closed

[Community] What are you building with ChakraCore? #2575

dilijev opened this issue Feb 22, 2017 · 55 comments

Comments

@dilijev
Copy link
Contributor

dilijev commented Feb 22, 2017

With our efforts to enable cross-platform development, and recently, to enable the use of NuGet packages for ChakraCore development with .NET and Native apps (#85), as well as other work we've been doing to enable other scenarios, we're interested in hearing from the community about what you've been building with ChakraCore, and what you would like to build.

Besides the issues you file, the feedback you give us on Gitter, and other tags of the ChakraCore project, we don't have as much visibility into your needs as we would like, we're hoping to hear from you about anything you'd like to share with us about your projects.

Some questions we have in mind:

  • What projects are you working on?
  • What have your experiences been when working with ChakraCore?
  • Is our documentation helpful? If not, how can we improve? Were you able to find answers to your questions?
  • Have you written any blog posts or made any other public documentation about your experiences with ChakraCore? We'd love to read them!
  • Is there anything we can do to improve your development experiences?
  • Are you interested in contributing to ChakraCore but something is blocking you from making progress?

Below, I’m tagging some folks who replied to #85, various other GitHub issues, and/or on Gitter with interest in a NuGet package for .NET and/or Native apps, or have otherwise indicated interest in developing with ChakraCore:

@resnyanskiy @gulbanana @ormico @jimmcslim @Oceanswave @matthargett @Pre10der @MartinJohns @Fishrock123 @wickeda @JackTheRipper @dthompso99 @CatCatCatDog @fubar-coder @alexhultman @snowmantw @kphillisjr @TomSeymour @navidR @liydu @likidu @lwansbrough @atanasovg @galvesribeiro @ReubenBond @ninlar @kostaspl @lwansbrough, etc.

/cc @digitalinfinity @boingoing @liminzhu @bterlson @aruneshchandra @EdMaurer @sethgaurav

@kphillisjr
Copy link
Contributor

Just as a quick Note, I tend to be blunt, but Here's the feedback...

What projects are you working on?

Nothing involving ChakraCore... I lost interest in ChakraCore due to issues with getting changes into the main development branches.

What have your experiences been when working with ChakraCore?

Poor. Although some of this is timezone differences and lack of feedback, but in general things are in a fashion where things mostly feel like things are being completely ignored. Although Some of my issue is that I can't afford a more modern Mac OSX system. The Mac I own is a laptop using an Intel Core 2 Duo chip, and takes more than 30 minutes to even attempt to compile ChakraCore.

Is our documentation helpful? If not, how can we improve? Were you able to find answers to your questions?

More detailed guidelines on what is required to get code changes integrated into the main development tree.

Have you written any blog posts or made any other public documentation about your experiences with ChakraCore? We'd love to read them!

I have some documentation I wrote, and created a pull request for the chakracore samples involving OSX/Linux.

Is there anything we can do to improve your development experiences?

Making better use of the CMake build engine will greatly improve overall end user experience. A system similar to how GLFW and/or libSDL in general show a reasonable solution for embedding. All of this is part of my pull requests.

Are you interested in contributing to ChakraCore but something is blocking you from making progress?

I was, but not anymore due to the poor experience I had when trying to get things merged into the development branches. I had multiple pull requests I submitted over 3 months ago and none of them where accepted. Also, as a quick note, It's generally a well accepted practice for major change sets to occur as multiple commits with a single pull request. I see multiple commits per pull request in the Linux kernel development, Xorg/X11 development and more.

@ghost
Copy link

ghost commented Feb 22, 2017

Hi,

Currently I am discovering the technology on my side.

I am really interesting in it because of your benchmarks.

I have been thinking about distributing my own NodeJS binary embedding my business logic in order to provide a way to write some code in Javascript as it follows:

const myAPIAction = require('my-api-action');
const promise = myAPIAction.Do();

promise.then(() => {
  // do your stuff
}).catch(() => {
  // do your stuff
});

All the transactions with my APIs are done with a faster protocol than HTTP. My customer can focus on his API implementation and his front-end without having to develop all the part communicating with my APIs.

Using the Node-ChakraCore providing the Neutral VM I can also provide a proper working environment to my developers and whoever want to use my APIs.

I could have done that using node-gyp but too many troubles when it comes to cross-platform compilation.

The idea could look strange however I am already communicating with some other APIs. So here instead of HTTP -> HTTP -> HTTP I could provide HTTP -> PROTOBUF -> HTTP. This way I can do what ever I want between my customer and me without having to ask him to use something else than HTTP (HTTPS).

It's an idea I am currently exploring.

About what I have done so far:

For the other points, nothing to say. For now it's pretty cool.

Maybe not the place to talk about it. But it's not the same deal with the uwp npm module. I have been struggling with it all the week end for building a bluetooth scanner on my Raspberry Pi. The documentation is not that helpful.

@jasongin
Copy link
Contributor

@JackTheRipper , the node-uwp module does not work with Node-ChakraCore. It requires Node-Chakra, which is different (and is not being developed anymore as far as I know).

If you're working with bluetooth on Node.js on Windows, you might take a look at my noble-uwp project, which works with both Node-ChakraCore and Node-V8.

@ReubenBond
Copy link

ReubenBond commented Feb 23, 2017

For context, I work on dotnet/orleans with @galvesribeiro. Orleans is a framework for building distributed systems with .NET, used by a bunch of teams within MS (Halo, Skype, & teams in Azure) and outside of MS.

What projects are you working on?

The intention is to build support for writing Actors using JavaScript/TypeScript, currently we support .NET languages. Actors are inherently distributed, so strong support for async/await from both JS & .NET is important.

What have your experiences been when working with ChakraCore?

So far, quite good. Gitter helps and the team seem quite receptive and willing to help. I haven't had to modify or compile it yet.

Is our documentation helpful? If not, how can we improve? Were you able to find answers to your questions?

It was helpful, the samples were especially useful. Continuing to flesh out the API reference and samples will be useful. For example, JsValue is used in APIs, but the JsValue often has an expected runtime type (eg, a function), and that ought to be documented.

@Oceanswave
Copy link
Contributor

What projects are you working on?

I work on BaristaLabs/barista-sharepoint which is a SharePoint service application that allows devs to create microservices using JavaScript at runtime without requiring additional deployments to the farm environment.

The current version of Barista uses Jurassic as a JavaScript engine. I'm aiming to create a more general-purpose project - BaristaLabs/barista-core - with ChakraCore in the vein of AWS Lambda and Azure Functions except open-source, xplat that can be deployed to commodity level hardware.

Also, I maintain ChakraSharp that generates a low level ChakraCore C# binding using CppSharp

What have your experiences been when working with ChakraCore?

Great so far! The team is responsive and much thanks to @obastemur for getting the remaining api in for xplat. I have ChakraCore building on Linux/OSx/Win as part of my CI and things couldn't be better. Now I just need more time to devote to the project ;)

Is our documentation helpful? If not, how can we improve? Were you able to find answers to your questions?

Sufficient. Xml Code Comments and examples within are great.

Is there anything we can do to improve your development experiences?

Maybe more high-level design type documentation. Also perhaps release notes, there's been a lot of work put into 1.4, for example, but it's unclear to me as an external what the goals of 1.4 are

WebAssembly api seems daunting right now, but haven't had a chance to look much into it.

Are you interested in contributing to ChakraCore but something is blocking you from making progress?

Only myself and gaining an understanding of the ChakraCore codebase.

@JohnMasen
Copy link

something is wrong with the GitHub editor, can't preview and set the format.

[What projects are you working on?]
A dotnetcore project target to add scripting feature to dotnetcore applications. https://github.com/JohnMasen/ChakraCore.NET

[What have your experiences been when working with ChakraCore?]
fun and challenging, intergrating 2 runtimes requires very a large effort.

[Is our documentation helpful? If not, how can we improve? Were you able to find answers to your questions?]
No, the document lacks of basic explanation. not even close to dotnet documents. it costs me 2 days to figure out the first parameter of JSCallFunction should be thisArg. the document never mentioned it's actually a prototype call. the good thing is after I've complained at the community and the author modified the document.

[Have you written any blog posts or made any other public documentation about your experiences with ChakraCore? We'd love to read them!]
Not yet, Chakracore.NET is my first project, spent a lot of time on this. too busy to write a document. however, I plan to write some documents to explain how to write a runtime bridge between dotnet and chakracore.
[Is there anything we can do to improve your development experiences?]

  1. Improve the document
  2. A JSRT 2.0 API with porting friendly API (example: JSCallFunction2 without the thisArg, prototype call makes callback to javascript very limited)
    [Are you interested in contributing to ChakraCore but something is blocking you from making progress?]
    yes, but just don't have enough spare time.

@ghost
Copy link

ghost commented Feb 23, 2017

  • What projects are you working on?
    • I played with the idea of a JS server
  • What have your experiences been when working with ChakraCore?
    • Very minimal interface, fast compilation and minimal library and number of dependencies. C interface reminds me of Lua.
  • Is our documentation helpful? If not, how can we improve? Were you able to find answers to your questions?
    • It certainly lacks in comparison to V8 but once you gather the basics you have enough to build most things. Again, very minimal interface.
  • Have you written any blog posts or made any other public documentation about your experiences with ChakraCore? We'd love to read them!
    • No
  • Is there anything we can do to improve your development experiences?
    • I had some performance issues with the GC but this was apparently fixed after my test
  • Are you interested in contributing to ChakraCore but something is blocking you from making progress?
    • Only if Microsoft hire me

@gulbanana
Copy link

i'm building enterprise web applications using ChakraCore for SSR of React uis. for my purposes it's a nice alternative to V8

@dianahinz
Copy link

What projects are you working on?

full-stack projects.

What have your experiences been when working with ChakraCore?

Seamless. I've been using chakracore to test script blocks on my mac. Kudos @obastemur

Is our documentation helpful? If not, how can we improve? Were you able to find answers to your questions?

I didn't need any documentation so far. Only build instructions.

Have you written any blog posts or made any other public documentation about your experiences with ChakraCore? We'd love to read them!

Not yet :/

Is there anything we can do to improve your development experiences?

  • Appreciate a clear explanation among the chakracore and edge browser versions.

  • Nightly builds for OSX

Are you interested in contributing to ChakraCore but something is blocking you from making progress?

I am interested. If you set ...Accepting PR... label to simpler issues I can gladly take one or two.

@jaredwy
Copy link

jaredwy commented Feb 25, 2017

I will write up a bigger list in the near future. Something that could be addressed for xplat is marking the win32 only functions. https://github.com/Microsoft/ChakraCore/wiki/JsPointerToString for example. This took me a while to figure out why a simple sample wasn't compiling.

@ghost
Copy link

ghost commented Feb 25, 2017

@jasongin Node-Chakra is build from a fork (https://github.com/ms-iot/node/releases) of the Node-ChakraCore. Anyway thank you for the tip !

@likle
Copy link

likle commented Feb 26, 2017

What projects are you working on?

I would like to use ChakraCore to filter data by user-submitted javascript snippets.
Currently I am trying to do that on Ubuntu and Windows 10.

What have your experiences been when working with ChakraCore?

I have had better experiences, but I am sure that's mostly bad luck.

Trying to embed ChakraCore in a cmake project seems more difficult than I thought it would be. To be honest, cmake was one of the reasons choosing ChakraCore over v8. I found the following a little disappointing:

  • I couldn't find a way to change the compiler on linux
  • Seems like I can't use cmake on windows, have to figure out the path to msbuild and add the appropriate flags
  • Couldn't figure out so far how to build statically on windows
  • Seems like I have to use OS switches in my own cmake file in order to build ChakraCore

In most other libraries I use add_subdirectory to embed it. Unfortunately it seems much more difficult here. A good example of ChakraCore embedded using cmake would already be very helpful.

Is our documentation helpful? If not, how can we improve? Were you able to find answers to your questions?

I believe that examples on the function pages for the JSRT references would improve a lot.

Have you written any blog posts or made any other public documentation about your experiences with ChakraCore? We'd love to read them!

No.

Is there anything we can do to improve your development experiences?

Yes, allow embedding using add_subdirectory :-). Reducing compilation time might also help.

@jaredwy
Copy link

jaredwy commented Feb 26, 2017

@likle have you looked at the cmake PR on chakracore? Been meaning to check it out in an actual project but it appears to use cmake better and exposes the static library in a way consumable via cmake.

@likle
Copy link

likle commented Feb 27, 2017

@jaredwy yes I did. As far as I remember there were more than one PRs regarding cmake/static linking. I was hoping it would be merged. Thanks for pointing that out !

@obastemur
Copy link
Collaborator

A good example of ChakraCore embedded using cmake would already be very helpful

microsoft/Chakra-Samples#68

I couldn't find a way to change the compiler on linux

#2038

@liminzhu
Copy link
Collaborator

We've got some amazing insights and feedback from you guys from the past week. Thanks everyone for replying!

@liminzhu
Copy link
Collaborator

@kphillisjr you were definitely right about improving cmake embedding experience and thanks for bringing that to us! Sorry to hear you dissatisfaction, I think there were some pointers given at the time (1, 2, 3, etc.), but unfortunately people's opinions on things had diverged on those issues. We've done some work and checked in a cmake sample yesterday, which should achieve the initial goal of improving cmake embedding. There's also #2129 which we'll happily merge once some comments there got addressed.

@liminzhu
Copy link
Collaborator

@JackTheRipper fascinating usage of node-chakracore 😄 If you have any feedback, feel free to let @digitalinfinity or @aruneshchandra know.

@liminzhu
Copy link
Collaborator

@ReubenBond great to hear from you! It was fun chatting with you and @galvesribeiro on Gitter too. Hope you find the new JsCreatePromise useful.

Continuing to flesh out the API reference and samples will be useful. For example, JsValue is used in APIs, but the JsValue often has an expected runtime type (eg, a function), and that ought to be documented.

Totally right. We will continue to publish samples and snippets and if you find a particular API reference is lackluster, I'm more than happy to edit it.

@galvesribeiro
Copy link

@liminzhu once it got released on ChakraCore we will start using it and will definitively reach you guys back with feedback.

@liminzhu
Copy link
Collaborator

@galvesribeiro awesome! Feel free to play with release/2.0 br now as well if you want to experiment early.

@liminzhu
Copy link
Collaborator

@Oceanswave great to hear your scenario and glad you seem to be having fun! You can actually find release notes on the release page but we usually keep things on a high level. In case you're interested in webassembly, consensus was reached by four browser vendors today on the MVP design (see mail to CG).

@obastemur
Copy link
Collaborator

@liminzhu What @Oceanswave did with Mono/Net is interesting and could be helpful for others. I recall something similar for Rust from another user. We might have a part in wiki to promote those cool work though.

@liminzhu
Copy link
Collaborator

@obastemur yeah, I think having a derivative work wiki (or a sec in the resource wiki) for interesting projects like what @Oceanswave has would be great. Let me look into it.

@dilijev
Copy link
Contributor Author

dilijev commented Feb 28, 2017

@Oceanswave to tag on to @liminzhu's reply: https://github.com/Microsoft/ChakraCore/wiki/Release-Notes contains the high-level release notes for all released versions.

@dilijev
Copy link
Contributor Author

dilijev commented Feb 28, 2017

@obastemur

I recall something similar for Rust from another user.

Looks like @Fishrock123 and @darfink had done some work on that. See #1492 and #1441 for some discussion.

@liminzhu
Copy link
Collaborator

@JohnMasen thanks for the feedback! I think you and I have already chatted on some thread to edit the JsCallFunction. If there're more things you'd wish to see, I'm happy to hear it.

A JSRT 2.0 API with porting friendly API (example: JSCallFunction2 without the thisArg, prototype call makes callback to javascript very limited)

JsCallFunction mimics Function.prototype.call which takes thisArg. I'm not that sure about shipping a similar extra API because JSRT is meant to be a small interface and only gives basic building blocks, but an issue is probably the better place to discuss it in more details if you wish 😄 . If you find the current API interface lacking some basic functionalities, I'm totally open to hear suggestions as well.

@liminzhu
Copy link
Collaborator

@alexhultman glad to hear you're playing with ChakraCore and thanks for the feedback! Is there any documentation enhancement that you would've found helpful back when you were learning the basics?

@dilijev
Copy link
Contributor Author

dilijev commented Feb 28, 2017

@liminzhu

I think having a derivative work wiki (or a sec in the resource wiki) for interesting projects like what @Oceanswave has would be great. Let me look into it.

I think the Resources page would be a good place for it.

There have also been a few community projects which embed JSRT APIs in .NET and we could maybe link to those repos if we don't mind the implication of "officially" "endorsing" those projects.

@liminzhu
Copy link
Collaborator

@likle thanks for the feedback and hope this new cmake sample can help you!

I believe that examples on the function pages for the JSRT references would improve a lot.

My perspective is that adding snippets about how to do basic things would probably be more helpful than adding individual examples for each APIs. Thoughts?

Yes, allow embedding using add_subdirectory :-). Reducing compilation time might also help.

@obastemur ?

@ghost
Copy link

ghost commented Feb 28, 2017

@liminzhu it is really interesting.

Currently I am preparing a Docker image which builds only the .o

Another image come on top of that one adding my .o. My top level image run the build and make the binary available :D

It's not done yet but it looks sexy

@ghost
Copy link

ghost commented Feb 28, 2017

In fact I described my stuff already to @matthargett

@likle
Copy link

likle commented Feb 28, 2017

@liminzhu thank you and of course @obastemur for the helpful example.

I personally really like the way others (e.g. cppreference, msdn and especially mdn) provide basic usage examples (usually in the bottom of the page). But I guess that is a matter of taste. Adding snippets about how to do basic things would of course also help a lot. :-)

@liminzhu
Copy link
Collaborator

@dilijev opened an issue microsoft/ChakraCore-wiki#28 :).

@dilijev
Copy link
Contributor Author

dilijev commented Feb 28, 2017

... provide basic usage examples (usually in the bottom of the page) [on each API's documentation page]

@likle I think we could probably arrange that. It's extra overhead to maintain documentation separate from the samples, so I'll leave the final call on that to @liminzhu but I've added this issue to track this request. microsoft/ChakraCore-wiki#29

@voidstorm
Copy link

voidstorm commented Mar 1, 2017

Is there anything we can do to improve your development experiences?

Yes, there is :). Adding debug support outside of nodejs. Not being able to debug scripts when embedding the runtime into a C/C++ application is really almost a showstopper. It would really be great if chakracore offered a possibitly to just attach vs code without having to run the scripts inside chakra node js.

@navidR
Copy link
Contributor

navidR commented Mar 1, 2017

I am saying this as senior year student who reads ChakraCore source code for learning purpose, and have plan to work on it as my hobby open source project (although I was very busy in last months and haven't worked on any specific thing other than small eval flag for "ch").

Lack of documentation is the most difficult barrier I have faced.
I do understand ChakraCore is not community driven project like Linux kernel or FreeBSD kernel or Rust (They document everything in source code, almost "everything"). But if you don't document your code and reader should figure it out, then you should have complete wiki about internal architecture of ChakraCore if you want contribution from outside of MS (If we can have both the documentation and a complete wiki about internal architecture it would be awesome, but one would suffice for a serious developer who wants to work on codebase). I do understand it may not worth the effort to document everything like those project I named, but at least we could/should have documentation about internal of ChakraCore (which parts interact with which parts, how do they interact, etc). Personally I take note about different aspect of source code when I read them and I would love to contribute to documentation, but I think we don't have a specific place or rule to contribute documentation at all , also before contributing any serious source code to any project it is very common for open source developers to contribute to its documentation.

Second, I may be wrong, but I am not aware of any coding style enforced from Microsoft on developers. V8 does follow Google C++ Coding Style. I think ChakraCore should have a complete code style too, something like what Google does have. BTW by coding style I don't mean only putting brackets in new line or things like these, I mean you should define a subset of C++ which allowed to use. (I am saying this again, I may be wrong about this, but at least I haven't seen any coding guideline)

Third, Testing in ChakraCore is not that obvious. By obvious (other than lack of documentation of course) I mean we could have much better output than what we have currently in test outputs. Personally most of the time I am afraid to even look at the test output after I run tests. By cleaning output of test code the cycle of Implement->Compile->Test would be much easier. IIRC there was a way to run specific tests, but I am talking about more broader picture here, we should make testing as easy as possible.

Four, I would love to see this thread to stay alive, we can share our experience with official developers here, and get answers, It would be much better experience definitely. I know we have gitter, but let do technical discussion in gitter.

@liminzhu
Copy link
Collaborator

liminzhu commented Mar 1, 2017

@voidstorm thanks for the suggestion! What we have now is debugging APIs sitting in ChakraDebug.h, which is one of the headers that need to be included for embedding ChakraCore. Our team is using it to shim the V8 debugging APIs and implement debugger for NodeChakraCore, which you may already know. I definitely understand your pain here, doing a bunch of work to implement a debugger is not ideal 😄 . My concern is that there's a huge chunk of things that just shouldn't be owned by a JavaScript VM and requirements very much vary for different hosts, e.g. debugger implementation, interfacing with debugging UI (VSCode), etc. That said, with our node efforts, maybe we can carve something out and make a library for other ChakraCore embedders. It won't be a plug-and-good-to-go debugger, but it can be something that at least makes life easier. AFAIK the debugging situation is similar between all standalone JS engines. Correct me if I'm wrong and I'd be happy to look more into it.

@dilijev
Copy link
Contributor Author

dilijev commented Mar 1, 2017

@navidR

I think ChakraCore should have a complete code style too, something like what Google does have.

This Coding Convention is the style we adhere to when coding ChakraCore. Microsoft at large leaves style up to the individual teams and we're happy to have that flexibility. We made the deliberate decision not to arbitrarily restrict the kind of code developers should write, preferring this minimal Coding Convention (i.e. style guide) to make code as legible as possible (with uniformity as a secondary concern). (Keep in mind, as stated in the coding convention, for older code which is formatted differently, we try to keep mainly to the style in the surrounding code.)

@jaredwy
Copy link

jaredwy commented Mar 1, 2017

@liminzhu @voidstorm this is correct. V8 for example provides the api for interfacing with the engine via a debugger https://v8docs.nodesource.com/node-0.8/de/d13/classv8_1_1_debug.html , but does not implement it for you. You can see the implementation of the node debugger here https://github.com/nodejs/node/blob/master/src/debug-agent.cc This uses the new chrome inspector protocol that is being pushed down into V8.

@dilijev
Copy link
Contributor Author

dilijev commented Mar 1, 2017

@navidR

Personally I take note about different aspect of source code when I read them and I would love to contribute to documentation, but I think we don't have a specific place or rule to contribute documentation at all , also before contributing any serious source code to any project it is very common for open source developers to contribute to its documentation.

We definitely would not turn away PRs which add non-trivial doc comments. We don't especially like the pattern of documenting Every Single Method™ because if a method is short or the naming is good, its purpose is largely self-explanatory. Generally, we like (or don't dislike) having some internal source code documentation for long or unintuitive methods, in the form of doc-style comments, as well as comments within the code.

Additions of documentation within the code that explain the general purpose and usage of our classes would be welcomed.

To somewhat justify the state of things: one of the reasons we don't have many documentation comments is that the overall design of classes can sometimes change rapidly while developing new features, adding optimizations, and fixing bugs, and we're more interested in implementing good quality code (reinforced with tests) than we are in documenting the behavior in prose comments (and more importantly, we don't want to always have to ensure that the documentation stays current and accurate as we evolve the code).

For more abstract documentation about design, we feel source code comments are not the best place for this. Blog posts and Wiki entries would be better suited. We acknowledge that we should expand our Wiki documentation.

@dilijev
Copy link
Contributor Author

dilijev commented Mar 1, 2017

@navidR

Third, Testing in ChakraCore is not that obvious. By obvious (other than lack of documentation of course) I mean we could have much better output than what we have currently in test outputs. Personally most of the time I am afraid to even look at the test output after I run tests. By cleaning output of test code the cycle of Implement->Compile->Test would be much easier. IIRC there was a way to run specific tests, but I am talking about more broader picture here, we should make testing as easy as possible.

The test output (i.e. baselines) were not really designed to be human-readable. We acknowledge this is a deficiency and are slowly converting tests as they need it. For the tests which have baseline files, the best approach is to diff the output (piped to a file) with the baseline file. Usually reducing the test to a simpler script with a repro of the exact issue is the best way to diagnose and fix a failure.

We have a unit test framework which we introduced relatively recently which emphasizes testing through assertions, with emphasis on printing output ONLY when something is wrong. Some tests use this (especially the many tests with no corresponding .baseline file). Many older tests have not been converted to use this. For some tests it doesn't necessarily make sense to use it. It also makes running tests a little bit less straightforward (the working directory matters to load the test framework library). There's a low-priority PR open (see Issue #269 and PR #1399 by @Cellule) which tries to improve this.

See rlexedirs.xml and the various rlexe.xml files for test definitions. Baselines are usually named after the tests so if you go looking through the tests directory you should be able to find them.

Again, we acknowledge documentation needs to be improved in this area. There's a wiki issue open to track this: microsoft/ChakraCore-wiki#7

@dilijev
Copy link
Contributor Author

dilijev commented Mar 1, 2017

@navidR

I would love to see this thread to stay alive, we can share our experience with official developers here

Agreed. Will add though:

  • GitHub issues are good for relatively slow-moving topical discussions. (Probably would recommend new issues for each broad topic area if there's going to be more than a few comments on one topic.)
  • One downside of GitHub issues is that by the default sort order, older issues are less visible. You can sort differently to see recent updates, but it's one of the deficiencies of using GitHub issues like a forum.
  • Gitter is probably best for quick Q&A on various topics, including general technical discussion.

@JohnMasen
Copy link

hi Guys,
I created a dotnet wrapper which supports dotnet code interop with chakracore.
the target is create a easy to learn and use library which brings scripting feature to dotnet application.

https://github.com/JohnMasen/ChakraCore.NET

key features:

Read/Write javascript values
Call javascript function from dotnet, support callback to dotnet
Expose dotnet function to javascript, support callback to javascript
Flexible value converter system
Transfer dotnet class instance to a proxy object in javascript
Transfer dotnet structure to a javascript value
Build-in value converters support String,int,double,single,bool,byte,decimal,Guid
Support ArrayBuffer,TypedArray,DataView
Support Task <-> Promise convert

@dilijev
Copy link
Contributor Author

dilijev commented Mar 3, 2017

@JohnMasen Thanks for posting the link to the project here! I've had my eye on that project and reference it occasionally among the team as an example of a third-party .NET wrapper for JSRT.

@JohnMasen
Copy link

@dilijev My Pleasure :)

@JohnMasen
Copy link

@dilijev
I don't know how to send private message. so leave my message here.
Can I ask you a favor to spread my library chakracore.NET. I spend many times on that, I believe you can identity that is a good library. It supports a lot of features and I believe by looking into it's source, it can answer many integration questions here.
I can't do it may self now, as I need to take care of my wife from now on. I don't know when she will be fine, I will not give up her. Please take care of your family when you can.
The library costs me a large of effort, 5 refectories in 2 months , maybe I spent too much time on coding. I may not able to maintain it anymore, I just don't want it to be wasted, this library costs me a lot.

@liminzhu
Copy link
Collaborator

liminzhu commented Mar 9, 2017

Hi @JohnMasen. Hope everything goes well with the family. We appreciate the interest and effort you’ve put into building something with ChakraCore. While we are not structured to support or promote third party stuff, we are thinking of creative ways of how we could share derivative projects build using ChakraCore with the community, incl. things like derivative projects wiki. Once established, we could surely add your project to that.

@JohnMasen
Copy link

Hi @liminzhu :
Thanks for your reply. what I'm asking is not an official recommendation. I just want you guys can help post some threads on technical forums, not as Microsoft, just as a developer. I may not able to maintain this code anymore. I put my 17 years experience into this library. I just don't want it to be wasted. I can't do it my self, I'm too sad to do this.

@liminzhu
Copy link
Collaborator

@JohnMasen ah okay it's a note for everyone on the thread then. If anyone is interested, he/she can also fork the project and maintain it if that's okay with you @JohnMasen?

@ninlar
Copy link
Contributor

ninlar commented Mar 28, 2017

Hope I'm not too late to the party:

What projects are you working on?

I guess our project is most similar to DocumentDB's use of ChakraCore. The equivalent of stored procedures or in our case: calculations and analytics. We allow users to create custom logic that triggers as new events hit our database or they can trigger based off of web hooks or time based scheduling as well.

Like DocumentDB which is a PaaS offering in Azure. Our database, which is optimized for streaming data, is also a PaaS offering in Azure. So we host ChakraCore in a multi-tenant cluster which is where the challenge lies.

What have your experiences been when working with ChakraCore?

We started the project using V8, and right as we completed the initial prototype to get the go ahead from the higher ups, ChakraCore was open sourced. I've been writing software since 1998, so I started in the object-oriented world of paradigms. C++ was more attractive to me, even though, there are ton of gotchas that will let you shoot yourself in the foot. I liked V8's C++ API, but at the same time hated it. The way that GC handles were exposed were annoying having to promote from local to global and vice versa.

Initially I wasn't too much of a fan of the JSRT. The fact that ChakraCore is a bunch of C++ classes and then the API is a C abstraction that just typedefs everything to void* was annoying, but makes sense with a loosely typed language. Also doing something simple like extending the Date object required getting the global object and navigating to the prototype via JsGetProperty calls seemed verbose; however, I decided to give it a shot and see if I could switch out V8 for ChakraCore and started to like the JSRT more over time. I wrote simple classes like JavaScriptEngine to wrap the runtime and context, and JavaScriptObject to wrap the calls needed to fetch properties, set them, define them, control reference count, and add methods to them. After those were in place, it was easy. I even had promises working with async / await via JsNativeFunctions before the JsCreatePromise was added.

So I didn't just switch out ChakraCore for V8 over Microsoft fanboism. In a multi-tenant cluster, you need to control the noisy neighbor problem. You need to cap memory for each "calculation," and you need to terminate scripts that are consuming too much CPU. V8 supported the memory cap, but ChakraCore supported the ability to have the JITter introduce more checks to see if you want to terminate the script via the runtime attributes. Also the experimental features already supported the asncy / await keywords with existing promises, and I loved that.

Is our documentation helpful? If not, how can we improve? Were you able to find answers to your questions?

The best asset for documentation as of now is the OpenGL example. It covered everything from creating objects, adding native methods, Creating a class or setting up a prototype. It was a bigger help than the documentation. I think the documentation is lacking quite a bit. As of now ChakraCore.h contains a bunch of new APIs not yet included in the Wiki. In addition APIs like JsDefineProperty are abhorrent. There is nothing there that says the JsValueRef you pass in should be an object that contains the getters and setters, etc. Luckily Gitter resolved that. Documentation is the weakest part. Also defining properties should be easier. See V8 which easily allows you define properties with C++ callbacks including indexed properties.

Is there anything we can do to improve your development experiences?

So as I mentioned, we host it in a cluster in Azure (Service Fabric). ChakraCore is not quite optimized for having many different scripts loaded in different isolated environments. Since these need to run in parallel a lot, we have to essentially create a pool of runtimes with a single context that all have the same script loaded. It would be nice if either contexts could have multiple threads invoking a function in parallel. Or the ability to clone a runtime with some sort of copy-on-write setup. We have to create a lot of runtimes and it adds up. The biggest challenge we have is asynchronous code. Chakra is loaded by our mixed mode DLL. Most of our other logic is C# which uses Async everywhere. Getting that to work with the JSRT was big challenge. If Chakra had better async support that would help. That doesn't mean it has to place nice with .NET Tasks, but some sort of async APIs that we could wrap as a TaskCompletionSource helps. Finally I hate the fact the context is set as thread local storage. In an async world, you are never guaranteed that your function resumes on the same thread, so your JSRT calls with fail due to the context being not set or incorrect. As of now, we need to marshal all async call back to the thread that started invoking the engine to prevent it. That marshaling comes at a big cost. An overload to the APIs that allows the context to be passed could help with this, but would not be compatible with the current model.

Additional features to help with the noisy neighbor problem helps too. Maybe a JSRT API that gives access to the Abstract Syntax Tree, so we can maybe do some static analysis to vet this user written code that we have to host. Or even better, maybe this already happens, but Chakra could have some APIs that do some form of static analysis looking for potential forever loops, etc.

Finally, I'd like to contribute more and the existing "architecture" section of the wiki just doesn't cut it. Some wiki entries explaining the types "RecycleableObject" and other internal types would help us understand.

@liminzhu
Copy link
Collaborator

@ninlar thanks for sharing your perspective. It was a very nice and construtive post.

Initially I wasn't too much of a fan of the JSRT. The fact that ChakraCore is a bunch of C++ classes and then the API is a C abstraction that just typedefs everything to void* was annoying, but makes sense with a loosely typed language. Also doing something simple like extending the Date object required getting the global object and navigating to the prototype via JsGetProperty calls seemed verbose; however, I decided to give it a shot and see if I could switch out V8 for ChakraCore and started to like the JSRT more over time. I wrote simple classes like JavaScriptEngine to wrap the runtime and context, and JavaScriptObject to wrap the calls needed to fetch properties, set them, define them, control reference count, and add methods to them. After those were in place, it was easy. I even had promises working with async / await via JsNativeFunctions before the JsCreatePromise was added.

As you probably noticed, JSRT APIs are by design very atomic :).

As of now ChakraCore.h contains a bunch of new APIs not yet included in the Wiki.

Yep I agree that documentation for some of the experimental APIs is not there is a problem. AFAIK the missing ones are the module APIs in ChakraCore.h and diagnotic APIs in ChakraDebug.h, which are ones most subject to change. Will spend time to add them in the wiki and mark as experimental.

In addition APIs like JsDefineProperty are abhorrent. There is nothing there that says the JsValueRef you pass in should be an object that contains the getters and setters, etc.

API ref for JsDefineProperty does say propertyDescriptor is the property descriptor.

ChakraCore is not quite optimized for having many different scripts loaded in different isolated environments. Since these need to run in parallel a lot, we have to essentially create a pool of runtimes with a single context that all have the same script loaded. It would be nice if either contexts could have multiple threads invoking a function in parallel. Or the ability to clone a runtime with some sort of copy-on-write setup. We have to create a lot of runtimes and it adds up.

Not sure I fully understand why you have to use a single context since you mentioned 'in different isolated environments'. Do all scripts need to access the same data within a context? Nevertheless, a clean JavaScript way to think about paralellism is through SharedArrayBuffer (behind experimental flag in ChakraCore). You can implement something like a webworker that shares data between contexts (ofc it breaks the isolation and needs some special care). Then you can spin up multilple runtimes to map/reduce. JavaScript is a single-threaded model so it doesn't make much sense to allow multiple threads partying in the same context. For testing SAB, we probably will need to implement agent for ch, which you can look into.

The biggest challenge we have is asynchronous code. Chakra is loaded by our mixed mode DLL. Most of our other logic is C# which uses Async everywhere. Getting that to work with the JSRT was big challenge. If Chakra had better async support that would help. That doesn't mean it has to place nice with .NET Tasks, but some sort of async APIs that we could wrap as a TaskCompletionSource helps. Finally I hate the fact the context is set as thread local storage.

JsCreatePromise is your friend. See thread.

Additional features to help with the noisy neighbor problem helps too. Maybe a JSRT API that gives access to the Abstract Syntax Tree, so we can maybe do some static analysis to vet this user written code that we have to host. Or even better, maybe this already happens, but Chakra could have some APIs that do some form of static analysis looking for potential forever loops, etc.

Yep we've had similar requests before about parsing AST though for different purposes. The reason we didn't do it is that our AST structure is unstable. It needs the flexibility to changes all the time as we implement new language features.

Finally, I'd like to contribute more and the existing "architecture" section of the wiki just doesn't cut it. Some wiki entries explaining the types "RecycleableObject" and other internal types would help us understand.

We could definitely use a PR there :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests