In my FB interview I was told I wasn't allowed to run the code, which seemed completely ridiculous to me. It was even more frustrating when my interviewer told me I'd missed an edge case when I was certain I'd covered it - I'm still not sure who was right.
I went to an interview where there were no spare computers, so I was asked to write out a blackjack game in Java with pencil and paper. That was a lot worse than any of the whiteboard ones I've had.
Pattern matching is a really important feature but I strongly dislike that proposal because it feels like it introduces a bunch of single purpose syntax that's going to restrict the ability to evolve the language in future. It feels like it's an addon, not a holistic solution.
I would much, much rather that type annotation syntax gets standardised first, because it is comparatively easy to build pattern matching when that's in place but going the opposite direction is difficult. What is a type if not a pattern?
It seems that only `when` and `->`is the new syntax, no? The arrow seems something that could be replaced with `=>`, but anyway, neither seems to be very restrictive with regards to future syntax. (After all they are only defined in a `case` context, so the can be reused for whatever future purpose outside.)
Plus it's a stage1 proposal, meaning it's far from serious.
Could you link the type annotation proposal, I can't find it.
Do you have a specific example of code that's hard to annotate in TypeScript? I've been using it for about a year without major issues (except somewhat slow compile times).
Because there's essentially nothing to leverage. The one thing that they promise (interoperability between frameworks) is both not true in my experience and not compelling enough to warrant the massive amount of complexity required to work around their shortcomings. If you want nightmares go read Polymer or Oracle JET's source code, both are WC based frameworks, both had to go to extreme lengths to offer a semi-reasonable end user API.
> The one thing that they promise (interoperability between frameworks) is both not true
Who is promising that? Web components are just a set of APIs in the browser. All they can really do is make the same promise of all the other browser APIs, which is availability.
Web Components are a very good solution if you're YouTube or Twitter and you want to let people embed your content while providing your own styling/behavior for it. It's basically a lower-overhead version of <iframe> that can set its own dimensions.
Web Components are probably also a good solution if you're a news site that serves 90% static text but occasionally wants to embed an interactive chart or something. It's basically a slightly more standardized, isolated version of the `<div id="chart"></div> <script>$("#chart").makeInteractive()</script>`-style code that sites like that normally use.
They might also work if you're trying to build a library of standard components (like "toggle switch" or "stepper control") to be used in apps written with a variety of different UI frameworks. Although this depends on good "cross-framework" support which hasn't really materialized yet.
Web Components might not be the best solution if you want to render your entire site in client-side JavaScript, SPA-style. But on the whole, there aren't many websites that want to do that—remember, 30% of the Internet is WordPress blogs!—and there are even fewer where it's actually a good idea.
You could use WCs for that stuff, but WCs aren't best for those purposes.
1) YouTube/Twitter widget: Use an iframe, because WCs don't render at all with JS disabled.
2) Interactive chart: You don't need WCs for this case; they make nothing easier and many things harder. Just use DOM APIs directly if your requirements lightweight, or use a popular framework if you need more support.
3) Standard library: That's the interop problem they're talking about up thread. That's literally the only thing WCs are good for, and even then, the fact that they don't render at all with JS disabled means that they're never going to be better/faster than rendering UI server side.
I think web components fall back to regular elements if JavaScript doesn't run. So <twitter-tweet>Cats are the best!</twitter-tweet> and <button is="very-fancy-material-design-button">Click here!</button> would still show up for JS-disabled users, they just wouldn't have the extra JavaScript functionality.
On this planet it is possible to do runtime type validation with typescript. It's not an out of the box feature but a number of libraries allow it, e.g. https://github.com/gcanti/io-ts