Hacker Newsnew | past | comments | ask | show | jobs | submit | more phpnode's commentslogin

it's simple enough that it has probably been rediscovered independently many times throughout history.


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.


At least you got to type your code. I had to write mine out on a whiteboard (actually, a patch of wall with whiteboard paint).


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.


Reminds me of programming tests at my college.


Yes indeed, much easier. The problem is that the places where you need desalination tend to be the places without much rain.


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.


There is no type annotation proposal.


TypeScript is becoming the de facto type annotations proposal.


Let me know when (type inference of) partial function application and object literals are easy in Typescript and I’ll consider 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).



In JS, the pattern is the type. That is the point of duck typing.


> In JS, the pattern is the type.

How do you match against a `Buffer` pattern/type?


In the current proposal,

    case (value) {
        when { constructor: Buffer } ->
            console.log("It's a Buffer!")
    }
that doesn't handle subtying though and doesn't work across realms.


Oh interesting you can match on that!

However I think my point stands that javascript has runtime conceptions of types that go beyond duck typing.


They totally changed the API once already, renaming their initial implementation "v0".


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.

They solve the wrong problem the wrong way. The creator of Ember recently tweeted about this: https://twitter.com/tomdale/status/1153309794226147330


> 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.


> Who is promising that?

This was very much the narrative back when WCs were first announced / released. If that's no longer a focus then what is their selling point now?


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.


In practice this would be

    <twitter-tweet id="424242424242"></twitter-tweet>

What you're saying is true only for the simplest of components.


This article is about the UK where the NHS has been chronically underfunded for the last decade.


The NHS has been chronically underfunded for 40 years.

In 2007, before the crash, after 10 years of New Labour, the U.S. spent 15% of its GDP on healthcare. German 10%, the Netherlands 9%.

The UK spent 7.4%.

In fact it's over the last 10 years that the UK has begun to catch up with the rest of Europe.

http://imgur.com/mUI9oWil.png


Life Expectancy at Birth

Netherlands 81.6

U.K. 81.2

Germany 81.1

USA 78.6

https://data.oecd.org/healthstat/life-expectancy-at-birth.ht...


Which just goes to show how superior the NHS is. It’s still underfunded though.


Yes, yes it is.


Looks a lot like css in JS to me, have you considered simply using the platform instead?


This passes the CSS text to CSSStyleSheet.replace(), so it very much is using the platform.

CSS Modules will make it possible to directly import a Stylesheet: https://github.com/w3c/webcomponents/issues/759


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


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: