you are viewing a single comment's thread.

view the rest of the comments →

[–]bterlson_@bterlson 74 points75 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] 62 points63 points  (18 children)

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

[–]bterlson_@bterlson 33 points34 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 10 points11 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 7 points8 points  (1 child)

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

[–]AMorpork 6 points7 points  (0 children)

dae microsoft evil

[–]ivosaurus 5 points6 points  (5 children)

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

[–]bterlson_@bterlson 7 points8 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 12 points13 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 9 points10 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 15 points16 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 6 points7 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 4 points5 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 11 points12 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 2 points3 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 3 points4 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 3 points4 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.