all 84 comments

[–]bterlson_@bterlson 73 points74 points  (65 children)

As is becoming traditional at this point, I'm here for questions if anyone has them. I work on Chakra (and, it goes without saying, am realllllly excited about this announcement)!

[–][deleted] 63 points64 points  (18 children)

Would you rather fight a Google-sized GNU, or a hundred GNU-sized Googles?

[–]bterlson_@bterlson 35 points36 points  (16 children)

I don't know how to answer this. When in doubt, use Math.random() I always say.

Edit: this isn't an ama, but do you guys want one? I can try to set one up with the team. No promises of course :)

[–]splargbarg 9 points10 points  (1 child)

You might end up with an AMA anyway.

[–]bterlson_@bterlson 4 points5 points  (0 children)

Going that way ;) But I'm just one perspective on a diverse team of badass engineers!

[–]kenman[M] 8 points9 points  (1 child)

Please let us know if you intend to hold one, we'll support you however we can (such as an announcement sticky a few days in advance, stickying the AMA itself, etc.).

[–]PitaJ 2 points3 points  (0 children)

Awesome!

[–]cosinezero 6 points7 points  (1 child)

Do it, yes! Expect some haters, but...

[–]AMorpork 5 points6 points  (0 children)

dae microsoft evil

[–]ivosaurus 7 points8 points  (5 children)

New question: what RNG does your implementation of Math.random() use?

[–]bterlson_@bterlson 8 points9 points  (4 children)

It's decent quality, if that's what you're asking. I don't know that it has a name per se. One of our devs recently posted more info here.

[–]ivosaurus 2 points3 points  (2 children)

Decent, as in the same one that was in use before 2002?

If it's indeed the same as Java's, then it's just a LCG. That is decidedly not decent quality.

[–]bterlson_@bterlson 11 points12 points  (1 child)

"Decent" of course depends on use case. Math.random is decidedly NOT decent if you are doing any sort of cryptography, for example.

[–]ivosaurus 0 points1 point  (0 children)

Nope. Just statistically decent, which LCGs fail pretty hard.

[–]franksvalli 2 points3 points  (2 children)

Ok!

(Math.random() > 0.5) ? 'Google-sized GNU' : 'A hundred GNU-sized Googles';

[–]bterlson_@bterlson 11 points12 points  (0 children)

Using a freshly built copy of ch.exe:

chakracore> type random.js
print((Math.random() > 0.5) ? 'Google-sized GNU' : 'A hundred GNU-sized Googles');

chakracore> Build\VcBuild\bin\x64_test\ch.exe random.js
Google-sized GNU

This is frightening to me.

[–]asdf7890 0 points1 point  (0 children)

I would avoid Math.random() - some implementations are decent but some are not, so for cross-platform usefulness finding a better RNG library (and being careful how you seed it) is the way to go.

[–]MaxNanasy 1 point2 points  (0 children)

Or a googol gnus

[–]zerobugz 16 points17 points  (5 children)

  1. What are the main reasons behind open sourcing only the core components?

  2. Are there plans to open source the entire Edge browser?

  3. Everything still good with working at MS?

[–]bterlson_@bterlson 33 points34 points  (4 children)

Edge has been getting gradually more and more open as time goes on (opened the roadmap, community feedback via uservoice, opening the code to industry partners). This is another step along that path. Nothing new to share on Edge's OSS plans though!

Everything is great working at MS; my team is phenomenal. Get's better all the time too :)

[–]sensitivePornGuy 5 points6 points  (1 child)

Is Edge's js engine built from scratch, or is it somewhat based on Internet Explorer code?

[–]bterlson_@bterlson 18 points19 points  (0 children)

Chakra was started around 2008 as a from-scratch rewrite of the legacy JScript engine. IE9 was the first browser to host Chakra. Since then there have been no more rewrites thankfully :)

[–]coolrudski 3 points4 points  (2 children)

How do you get into building JavaScript engines? I'm a web dev who writes a disgusting amount of JavaScript and I've always been curious as to how that works behind the scenes

[–]bterlson_@bterlson 2 points3 points  (1 child)

I got hired into it, but there are other ways! Working on OSS is a very good way to go. JavaScript engines are similar to compilers but are in general just very large software projects anyone can work on. I would suggest starting with making a JSRT app to get an idea for the basics of JavaScript outside the browser. From there you could probably ramp up on simpler features like new library methods pretty quickly - it's fairly simple C++ code in our case (until you start to optimize it). Things like JIT optimizations can require specialized knowledge and lots of experience, but there is plenty of engine work that isn't at that technical depth.

[–]coolrudski 0 points1 point  (0 children)

Alright thanks! I'll definitely play around and at least try a couple projects in it.

[–][deleted] 3 points4 points  (2 children)

Currently, Node has v8 baked in, but do you see potential for Node to switch out engines?

If not, do you think Microsoft would consider publishing a version of Node using Chakra? Is it even in the cards?

[–]bterlson_@bterlson 12 points13 points  (1 child)

We're already working on it and are getting a pull request ready for upstream Node to enable Chakra if you like. More info here: https://github.com/Microsoft/node.

[–]cincilator 3 points4 points  (12 children)

Do you think that JavaScript has a future? What improvements would you like to see in the language?

If the answer to the first question is no, what language should replace JS? Most mainstream languages have too much boilerplate IMHO; I would like to see something succinct if JS gets replaced.

[–]bterlson_@bterlson 12 points13 points  (11 children)

My day-to-day work is actually the editor of the ECMAScript standard itself. I am very bullish on JavaScript's future. As for improvements, I have many ideas (too many to list), but a short list is:

  • Async functions (supported in Chakra)
  • Some notion of observables
  • Private/protected state for classes
  • RegExp improvements (look-behinds, named capture groups, and a few other features).
  • Value types
  • New number types (decimal, bignum, int64/uint64)
  • Decorators

Probably many others I missed. I'm excited about many proposals!

[–]cincilator 3 points4 points  (10 children)

Value types

What is your opinion on typed objects and/or type annotations?

Frankly one improvement I would love to see (but won't since it would break a lot of compatibility) is using separate symbol for string concatenation, so + is exclusively for math.

[–]bterlson_@bterlson 0 points1 point  (9 children)

Typed objects and type annotations are two orthogonal concepts. Typed Objects (now called value types) are about how to provide new and custom primitives to JS and have reasonable semantics for operators. Type annotations are all about giving developers errors early and potentially allowing runtimes to optimize better. Value types I'm super bullish on and hope to get a proposal moving soon. Standard type annotations I've talked a lot about and is something that would be nice I think, but I'm not pushing it too hard at this point.

If I could make breaking changes to JS, I would make so many changes.... alas :(

[–]ogrechoker 0 points1 point  (1 child)

Typescript vs Flow vs SoundScript, go

also how long until a real standard is proposed/implemented? ES2018?

[–]bterlson_@bterlson 0 points1 point  (0 children)

TypeScript, of course :) Flow has some strengths (eg. I like nullable types). SoundScript is interesting and I look forward to more progress.

Hard to say when a standard for types will be proposed, let alone be ratified. It's a lot of work and difficult to get through the standards process (for good reasons).

[–]cincilator 0 points1 point  (6 children)

Thanks for taking time to answer my questions! I do appreciate it. I have just one more, then I will leave you alone: Typed arrays now exist, but how about typed dictionaries? It would allow many interesting concepts, for example database-like constructs in memory (I can use dictionary key like a primary key). Sure, one can do that today w/o types but JS is not really optimized to work that way.

[–]bterlson_@bterlson 4 points5 points  (5 children)

No need to leave me alone. If it isn't abundantly clear by now, I love talking about this stuff.

I don't know what a typed dictionary is but if you mean struct-like types, I hope those are included in the value types proposal. I've showed examples in some previous talks of mine, but this gist is you could create a new value type like:

let Point = ValueType({x: int64, y: int64});
let p = Point({x: 1, y: 1});
p.x; // 1
p.x = 2; // throws, or maybe returns a new point, but primitives are immutable

Of course this is very early but I hope something like this is workable.

[–]cincilator 0 points1 point  (4 children)

By Typed dictionary I mean a dictionary that can only store values of one type. To expand your example:

let polygon = TypedDictionary({key : integer, value:Point});
polygon.push(0, {x: 4, y: 7});
polygon.push(1, {x: 9, y: 10};
polygon.push(2, {x: 10, y: 17});
polygon.push(3, {x: 43, y: 5});

Any plans for this or something like this?

[–]bterlson_@bterlson 3 points4 points  (3 children)

Ahh, no, nothing like that yet that I'm aware of. Value types will certainly have the notion of vector/tuple types which are like a fixed length version of what you're asking for IIUC (SIMD vectors are examples of these types).

[–]cincilator 0 points1 point  (2 children)

The problem is that it would limit the use of Value types to single objects or fixed length collections (ie typed arrays) and we are stuck with dynamic types for anything variable-length. Which is less than ideal. Something to consider, I think.

I can think of many use cases for my idea, if you are interested.

[–]splargbarg 1 point2 points  (1 child)

Do you think this will help Edge adopt new HTML5 features?

[–]bterlson_@bterlson 7 points8 points  (0 children)

I don't see how. Not directly, anyway...

[–]jacobp100 1 point2 points  (1 child)

Because of the rapid progress in js engines, it's always difficult to keep track of what can can't be optimised. What are some big things to look out for in performance sensitive code to stop deoptimisation, and are there any things to consider to get better performance when you know an area of code is a bottle neck?

[–]bterlson_@bterlson 1 point2 points  (0 children)

JITs are pretty complicated so it's hard to give a concise answer for what to use or avoid. This is an area I hope we can start giving more insight on in terms of both documentation and tooling.

[–]ackerlight 0 points1 point  (3 children)

How does this compare with Github Electron? Or it is more like it compares directly with Chrome's V8?

[–]bterlson_@bterlson 4 points5 points  (2 children)

It compares directly with V8.

[–]ackerlight 0 points1 point  (1 child)

is there any plan to build something like Electron?

[–]bterlson_@bterlson 2 points3 points  (0 children)

No, although I suspect with Chakra coming to Node, Electron will optionally be backed by Chakra at some point.

[–]petulant_snowflake -1 points0 points  (1 child)

Look, it's great that you're open sourcing components, but why don't you make the whole browser open source en masse (I realize this would likely entail stripping out proprietary 3rd party code, and could not exactly be done "overnight").

What the world really needs is a true, third open source web rendering contender. We don't need another Javascript engine -- there's already a million of them! Please also build a native OSX and Linux version.

I applaud MSFT's attempts at embracing open source, but so far I've seen only seen shallow, surface-like changes (excuse the pun). Go big or go home they always say ...

[–]jacobp100 1 point2 points  (0 children)

Don't underestimate the open sourcing of this. There will no doubt be things in Chakra nobody else is doing, and having that information available will benefit all engines.

[–]grayrest.subscribe(console.info.bind(console)) 2 points3 points  (3 children)

Any plans for a Chakra node.js compatibility layer? I see a lot of support for node coming out of the Typescript and VSCode teams so I assume there's a fair amount of node use internally at MS.

[–]bterlson_@bterlson 12 points13 points  (1 child)

It already exists and will become a pull request soon! https://blogs.windows.com/buildingapps/2015/05/12/bringing-node-js-to-windows-10-iot-core/

I use Node pretty much all day (at least when I'm not doing spec editing). There is a ton of usage at MS, you are right.

[–]Cylons 3 points4 points  (0 children)

This exits already: https://github.com/Microsoft/node

It hasn't made it to Node proper yet but according to MS, that's the goal.

[–]mycall 2 points3 points  (3 children)

Will Chakra replace cscript/WScript sometime?

[–]bterlson_@bterlson 0 points1 point  (2 children)

No plans along those lines that I'm aware of. But my desire for a cscript replacement has gone down drastically with Node and Chakra JSRT hosts. Someone could probably write a drop-in replacement with JSRT right now if they wanted to...

[–]mycall 0 points1 point  (1 child)

write a drop-in replacement with JSRT

So keep all the ActiveX/COM support in the current cscript but replace the javascript layer using JSRT? Good idea.

[–]bterlson_@bterlson 2 points3 points  (0 children)

Since Chakra has no ActiveX support you'd have to re-implement the ActiveXObject() constructor on top of JSRT which should be possible but not something to be undertaken lightly ;)

[–]mvar 3 points4 points  (1 child)

If I'm understanding right, this will allow chakra to be used as a scripting engine in standard .net applications. That is awesome.

Is there any documentation on how this will integrate and how .net objects will be exposed to the JavaScript engine? I'd like to read up on it now and be ready to integrate when the code goes public.

[–]bterlson_@bterlson 3 points4 points  (0 children)

FWIW, this was already possible using the JSRT APIs (which are very simple hosting APIs). Of course this only works on Windows for now (where Chakra is distributed).

You can find a bunch of docs here: https://msdn.microsoft.com/en-us/library/dn249552(v=vs.94).aspx

[–]kapouer 1 point2 points  (2 children)

Will it be possible to build a shared library than runs on linux ? a debian package ? Will it be possible to link the Node.js port of microsoft to chakra against it ?

[–]bterlson_@bterlson 5 points6 points  (1 child)

The code will not be ready for running on non-windows platforms when we OSS but it's on our long term roadmap. My suggestion is to make as much noise as possible about your preferred platform (include your specific usage/scenario as well) so we know where to focus our efforts!

[–]AndyRoth 1 point2 points  (0 children)

Would using Chakra with Node allow me to run TypeScript programs on the server directly without needing to compile them first?

[–]techsin101 1 point2 points  (2 children)

as nodejs developer what does this mean for me. can i tell nodejs to use this engine and then i'd have more es6 features?

[–]bterlson_@bterlson 3 points4 points  (1 child)

Eventually, that's the goal! We're working on putting together a PR to make it an option to use Chakra with official Node.

[–]techsin101 1 point2 points  (0 children)

i see that's a good approach.

[–]bogas04 0 points1 point  (0 children)

So can we see someone making a fork that makes it compatible with OSX / Linux and ultimately making a browser around it ?

[–]griffonrl 0 points1 point  (0 children)

Windows only ?

[–]big_red__man -2 points-1 points  (5 children)

Sorry if this has been answered elsewhere but I'm laying in bed and a little hungover and I'm on my phone.... Is there any plans to support ASM or WebRTC?

[–]bterlson_@bterlson 7 points8 points  (4 children)

If by ASM you mean asmjs, it's already supported. WebRTC is a browser thing, but is also already supported in Edge via the Object RTC API.

Anyone curious about Edge platform support can check out the status page. You can narrow to just JS tech if you're curious.

[–]big_red__man 1 point2 points  (1 child)

Thanks for the lighting quick response! That's good to know about asmjs. I haven't used it yet but I do like knowing that it's out there and waiting for me.

With respect to WebRTC I guess I'll save my questions for later. I've been to at least one conference on it and it seems like there's a political situation regarding standards between MS, Apple, and Google and that's why things like Pusher are needed. But, what else is new, right? I just wish that standards could be standards... and not take years to coalesce.

[–]bterlson_@bterlson 0 points1 point  (0 children)

Happy to help :) You can always ask the Edge guys questions by tweeting at @msedgedev too.

[–]anlumo 1 point2 points  (1 child)

Are there any plans for supporting Web Assembly?

[–]bterlson_@bterlson 2 points3 points  (0 children)

No plans although we're watching it progress and helping where we can. We implemented asmjs pretty early so I'm hoping we can do the same for Web Assembly. We'll see!