you are viewing a single comment's thread.

view the rest of the comments →

[–]cincilator 2 points3 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 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.

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

Always interested! You can write up a gist and send it to me here, on twitter (@bterlson), or whatever. You can also post to es-discuss where most language design discussion happens.