HNHacker News
TopNewBestAskShowJobs

wwwigham

674 karma · joined April 15, 2015

[ my public key: https://keybase.io/www; my proof: https://keybase.io/www/sigs/Z47alkN-fwsa7FlMQZTF9A24_7hjUiskAbc5coXsxkw ]
submissionscomments
wwwigham··on Higher-Order Type-Level Programming in Haskell [pdf]
This is just a guess, but since TS is structural and it's inference engine is based on pattern matching instead of constraint solving some of this already applies. Minimally, the generalized type traversal constructors described as a use for higher kinds are already possible.[1] Then again, it was _also_ already similarly possible in Haskell, just _incredibly_ verbose, as it is there. The concepts don't quite transfer 1:1, due to implementation and type system differences (for example, TS doesn't have a solver relying on certain identities holding to generate new inferences or equations), but I think the gist of it (adding what amounts to a "is possibly a higher kind" constraint) could be portable and form the basis of a higher-kinded algebra in TS and allow for a wider array of patterns to be expressed more succinctly. Unfortunately I'm not immediately sure how structural subtyping would work out for something with that kind of constraint, which would need to be solved, too.

[1] https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast...

wwwigham··on Higher-Order Type-Level Programming in Haskell [pdf]
The readability of the arrow seems unimportant, as it's primary use is, from what I can tell, to express a new kind of constraint which can then be produced by inference and used to typecheck a wider gamut of input code with more succinct type annotations. Generally the inference engine assumes all type constructors are matchable - meaning they're both generative and injective (while type families are neither). However, if you want to work with an arbitrary type with unapplied generics, you can't really consider it injective, since you don't know what kind it is, or weather the `f a ~ f b => a ~ b` injective relationship actually holds (it could be a type family for which it wouldn't hold). Generativity, on the other hand, primarily impacts inference and the ability to break a type apart to perform inferences on its parts (where, if assumed for higher kinds, could cause the inference engine to potentially "skip past" the desired inferences, from what I can tell). What the paper seems to be about is that by adding this novel constraint, you can start to work with partially applied types, since you simply need to acknowledge that these two rules need not always hold (when dealing with type constructors), and that so long as the solver is aware of where these rules do not hold, a well-typed and sound program can still be produced.

While _some_ higher-kinded manipulating code needs the explicit ->> syntax to be well-typed, the authors determined that explicitly requiring it (or, likewise, the polymorphic arrow syntax ->^U) would prevent the intent of older code from changing, while the improved inferences allowed just by the new constraint kinds existing allows new flexibility.

Also: I don't think there's anything you could write in the double arrow's place that would be "readable" or "just make sense". I think it's difficult to acquire an innane "sense" for what a higher kinded operation actually _is_. By sticking close to familiar syntax, it should hopefully be easier to grasp as a related concept.

wwwigham··on 38% of bugs at Airbnb could have been prevented by using types
> null/undefined is an inhabitant of every type in typescript, I would suggest purescript instead.

If you want absolute certainty in your types with TS, you should be using the `--strict` flag, which makes it so this is not the case.

wwwigham··on Porting 30K lines of code from Flow to TypeScript
> I went from "fast and convenient" with JS to constantly fighting against the TS compiler and linter above cryptic type errors

Would you, perchance, be able to share an example of such an error? We generally strive to improve error clarity where possible~

> I found out that using JSdoc comments and relying on the linting abilities of my IDE

Ah. Well, spoiler alert: if your IDE is vscode or VS that JSDoc is actually still getting typechecked by TypeScript ;)

wwwigham··on Organizational Debt
I really empathize with the community interaction aspects of these comments - having spent a few months triaging everything that comes into our (admittedly less organized) repo, I can very much understand. It can be truly draining to only see the negatives and the nits and the nags and the bugs and the bothers and the badgers of a product. Heck, it makes it easy to forget about all the people who love it, those who've never once complained and silently continue about their business, able to ignore the fact that work had ever been done (and continues to be done).

But... It's swell when you meet someone and they offhandedly mention using the thing you work on, heck, even recommend it or straight up take it for granted. I know those moments probably can't sustain open source maintainers (and that leads into the second point about capturing funding), but, at least in my experience, they really help keep a more healthily balanced perspective. And that's at least a part of being able to stay happy working on such a project.

With respect to funding... As a relatively young compiler dev, I've pretty much always taken compiler software for granted. It's (almost) always been that languages have been freely available, and usually the source available, too. If I'm honest, at the price point of "free", it's almost hard to picture how compiler engineers get paid at all. Normally people sell tools, but... Programming languages are now tools freely given. And now even their advanced refactoring tools and IDE support. Strange to think about it, if I'm honest.

wwwigham··on Flutter: the good, the bad and the ugly
I got a reply here on hn awhile back with a similar question[1].

> Dart really is a big part of why the Flutter framework is as it is. Obviously you could design similar frameworks in other languages and have similar results, but there's really a very nice synergy between Dart's design and the Flutter framework, all the way down to small details like how garbage collection works in Dart vs how the framework happens to allocate objects.

So the rationalization seems to be performance.

[1]https://news.ycombinator.com/item?id=16476886

wwwigham··on TypeScript support added to Create React App
The TS team implemented the TS parsing support in Babel. You are correct that the TS compiler is still needed for the typechecker, however.
wwwigham··on The Costs of Programming Language Fragmentation
Fragmentation yields a distribution of effort which yields theoretically inferior products, compared to the theoretical output of all the individual parts working towards the same goal. (Debatable, but we'll assume it.)

Centralization yields a lack of competition yields a lack of a drive to improve inferior products yields stagnation and disenfranchisement. (Also debatable, but probably safe to assume here as well.)

Startup costs in this area (basic compiler stuff, usually handled by llvm and other varied metacompiler frameworks nowadays) become vanishingly small with time, while the long tail becomes ever larger (libraries, tooling, ecosystem goodness, all are expected now).

Given these two observations, when a language becomes popular despite starting in a fragmented ecosystem, it slowly grows, starts to take advantage of network effects, and gains the benefits of growing centralization as it becomes "the defacto choice" in some area (usually at the cost of other players in the space, be they large or small). Eventually, it stagnates, parts of the community become disenfranchised and go and spawn their own languages and variants (taking ideas from their origin, along with their grievances and ideas from other areas with them), and the process begins anew. However because of the growing long tail, each time this cycle takes place, the time between expansion and explosion takes longer and longer.

At least, that's how I've been led to believe systems like these tend to work.

It seems like the call to be _mindful_ of what you're doing when you make a language is sensible; if you contribute to the cycle, you're contributing to what will eventually be 2 years of long-tail work for what will be the de-facto norm for developer tooling 40 years from now; but that's a terrible way to look at it. Wouldn't you rather get in closer to the ground floor and be part of the first iterations that set the standards for the iterations which come after? Isn't thinking of it any other way just being defeatist? (Since it amounts to concluding that future generations of developers must be better at this than you, and so are worth more early-cycle-iteration time?) So what if it's indulging the ego some; if that's the cost of improvement, then so be it. The languages we have today wouldn't have been made without their predecessors, and the languages of tomorrow won't exist without the ones we have today. Is it also equally possible that deciding _not_ to make some new language potentially delaying the progress of the programming language field as a whole? Is making that value judgement in the purview of anything other than hindsight? I can't begin to imagine in what ways future languages may improve life as a developer, but if they're anything like the stark contrasts we've seen recently in certain PL areas (ie, systems languages), it's sure to be exciting.

wwwigham··on How Discord Handles Two and Half Million Concurrent Voice Users Using WebRTC
Yeah. Typically it starts with a priority speaker giving a speech, ends with a Q&A moderated via text chat.
wwwigham··on TypeScript at Google
> The type system is frankly disappointing, and the errors the compiler spits out at you (besides the most obvious ones) are almost always useless or gibberish and at times even more harmful than helpful.

I'd love to see examples of such errors. (And, ideally, accompanying code example)

wwwigham··on TypeScript at Google
> If you go all the way and make it sound with variance annotations

Variance annotations aren't quite what would make the language (in strict mode) sound. Specifically, what makes it unsound is the `any` type (generally) and the lack of enforced variance on methods, non-function properties, and index signatures. It doesn't need annotations to determine variance - type parameter variance can be inferred from where in a type a type parameter is used. It already does so for functions (that's the strict flag's strictFunctionTypes subflag). The real issue is that far, far too many people rely on, eg, unsound array assignments (array aughta be invariant over what it contains but it's often treated covariantly), for it to be reasonable to be a default. However it could always be changed (or added) in the future - that's what the strictness flags are for, ideally; providing ways to ratchet up the safety such that it won't permanently break longtime users of the language.

wwwigham··on TypeScript at Google
> But I agree with your example of symbol in dict. I would be surprised if it isn't already on the roadmap. Have you tried reaching out to the typescript people?

It's not just on the roadmap, it's in code review/iteration as of last week: https://github.com/Microsoft/TypeScript/pull/26797

wwwigham··on What Does “One JS” Mean in a World of Transpilers?
JS took over not just because it ran everywhere but also because of the network effects of everyone learning it because it ran everywhere. wasm has no such benefits, as an intermediary format. Nobody's ever going to get a job as a "wasm expert" building anything other than a wasm build pipeline. wasm may afford us more freedom, but that very freedom is in opposition to its broad adoption. It'll certainly be interesting to watch it play out over the next few years.

Oh, and:

> Alternatively, if you focus on getting web assembly up to speed, you can compile any flavor of JavaScript you want directly to web assembly

You can already compile any flavor of JavaScript to... JavaScript. It even maps better than wasm. wasm really doesn't help there. Today's ecosystem _is_ that ecosystem. Except there's some hope that some variants become future core language, unlike if you were using wasm, where you wouldn't even have such a thought because you'd be using a compiler forever. But... If you're ok with that, why wouldn't you be ok with transpiling forever?

wwwigham··on Introducing TensorFlow.js: Machine Learning in JavaScript
> I think my favorite part of this is that inevitably people will write type definitions for TensorFlow.js in TypeScript

Actually, it already ships with typescript definitions - it's written in TypeScript![1]

[1] https://github.com/tensorflow/tfjs/blob/master/src/index.ts

wwwigham··on A Proposal for Package Versioning in Go
> I'm excited to see Go trying something new here.

"Semantic import versioning" is equivalent to versioned APIs in the web world, no? Though I have never seen anyone utilize the same concepts for language-level packages; it certainly maps well!

wwwigham··on Announcing Flutter beta 1: Build beautiful native apps
No, the efficacy of the direct GL canvas native bindings and the view composition architecture are why it's efficient. Yes, there's little runtime language overhead because it's AOT compiled, but that alone wouldn't cause it to win over another AOT compiled mobile device strategy, such as an AOT xamarin project. (And all the other points in that article apply equally to xamarin, for example; and some are just opinion like the xml vs code for layout debate) I'm sorry, but I don't see how any of flutter's real performance wins are truly tied to its' choice of language, and it's a competitive market. I'll be happy if I'm proven wrong in a year or two's time, however.
wwwigham··on Announcing Flutter beta 1: Build beautiful native apps
> -Flutter renders the UI itself rather than using native components, so you get the same experience on both iOS and Android.

I thought this was an antipattern in modern mobile device Dev, since you're supposed to make your app "look and feel native" by always using native widgets where possible (and was a major argument for why, eg. Cordova was inferior to react native). Has the collective agreement turned on this, or it is simply contentious?

wwwigham··on Announcing Flutter beta 1: Build beautiful native apps
The most attractive thing about flutter (compared to some other crossplat mobile UI frameworks) is the efficient underlying UI framework, so I'm sure if it starts to fail because of Dart they'll be able to eject that coupling and pivot fairly quickly and become more like the competition. However if it succeeds in spite of it's reliance on Dart, then they'll have maybe untarnished its perception a bit.
wwwigham··on Speed Without Wizardry
It's also probably not worth overtly begging the question of weather maintaining multiple languages within one project is worth the burden (seriously the full build for the `source-map` package is complex in comparison to the usual JS state of affairs if you want to experiment with the now-Rust bits), especially considering that at least part of the reason node became popular was to have one language for all needs, since focusing on that would invite that charged discussion. As a polyglot developer, I welcome all the mixing of the languages that wasm is bringing (certainly, it makes my flexible skillset more valuable); but honestly I do think we're leaving _something_ of the past homogeneity behind in doing so. (Was FFI quality all that was stopping us from mixing tons of languages in our non-browser projects before?)

Circling back; both authors have their biases - it's best to read both articles skeptically, and IMO, take away the sage bits of advice they both echo and not anything about a specific technology: You should make the right choices for your project and your design, performance, and maintenance needs (including making your own evaluations), rather than jumping on some bandwagon without being properly informed. Also that profile-guided algorithmic improvements are usually the easiest place to make sweet, sweet perf gains (in any language) before you have to get into hairy maintainability trade-off decisions.

wwwigham··on Zombie Processes Are Eating Your Memory
> Synaptics driver leaked memory whenever a process was created

Funny! I found out the same issue last week and ended up just uninstalling the driver (not sure how permanent that is, but I'd like to think it is). I thought I was going crazy - why I was hitting pagefile after 28 days of uptime but only using around 8/32 real GB of memory! I loaded up the ram viewer tool and was aghast - hundreds of thousands of zombie processes! Death by a thousand cuts!

wwwigham··on Announcing TypeScript 2.7
Much like casts and nonnull assertions. The general consensus is that you can enable a tslint rule to categorically forbid them.
wwwigham··on Partial Application and Lambda Parameter Syntax for JavaScript
If you really like the idea of syntactic partial application in your JavaScript, you should check out the stage 1 tc39 proposal for exactly that: https://github.com/rbuckton/proposal-partial-application It's slowly being worked through the committee, so if you care enough about the feature, you should consider voicing your support.
wwwigham··on Ask HN: Which TypeScript codebase should I study to get better?
We do use classes in the test harness, services layer, and to polyfill es6 Map. We just don't use them in the design of any compiler subsystems.
wwwigham··on Logitech announces a development kit for using keyboards in virtual reality
I'm more impressed by the videos of the hand tracking around the keyboard than the tracker in the keyboard! Is that fidelity just using the Vive's outward facing camera? They don't show any tracking gloves in the mockups.
wwwigham··on Diagnosing a Linux-only unit test failure
Travis actually has this[1], too, if you ask their support to have the feature beta enabled for your repo. A while back, I was having a CI only test failure that was a massive pain to try and debug, and this helped enormously as I could explore the build state and try alternatives without waiting on the typical build time.

[1]https://docs.travis-ci.com/user/running-build-in-debug-mode/

wwwigham··on Reservations about TypeScript
Not to pry, but do you have a Java background? I see you're using the global 'Boolean' and 'String' interfaces in your examples (which correspond to the equivalent JavaScript constructor objects), rather than the 'boolean' and 'string' primitive types. While it kinda works to use the interfaces instead of the primitives, the primitives, IMO have much more expected behavior in the type system, since, unlike the interfaces, they do not get compared structurally - TypeScript uses a structural type system for all objects, after all.
wwwigham··on Afraid of Makefiles? Don't be
> It'd be interesting to hear everyone's go to build tools.

A script written in whatever the primary language of the project is (usually with some library support), ideally; to reduce the minimum required knowledge to be a first time contributor to the project. Some kind of js build tool for js projects, fake for f#, and so on. I don't want people to need to learn "the one build tool DSL to rule them all" (be that makefile syntax, bazel rules, or whatever) to contribute to a project's infrastructure, on top of the project's primary language.

wwwigham··on Show HN: Chaotic Life – deterministic behavior from unsynchronized threads
This is a decent, if space inefficient, implementation of an optimistically concurrent algorithm. The general idea is that all threads have the same "goal", so if one thread notices partial work done by another thread (in this case, unupdated neighbors), then it does the work itself (checking to make sure its not already done before writing it) or moves on to work elsewhere instead. Many lock-free queues are based on this concept of work-finishing.

This is, however, storing 31 bits of generation-counter per bit of state to try to make the ABA linearization problem unlikely. Except it's using signed ints and doesn't account for overflow, so I think the behavior is going to get a bit less intended once the generation count hits 0x3FFFFFFF, rather than 0x7FFFFFFF; but I'm no expert on integer overflow in Java.

The claim that this is unsynchronized feels dubious, however! (Lock-free, sure! Unsynchronized? Not so fast!) This looks like it doesn't have synchronization primitives, but it _does_ - it has atomic reads and writes of ints [1]. (Thanks, Java!) So it never has to worry about reading partially updated data from a cell. If you were to try this in C, you'd potentially get piles of garbage as your thread is preempted partway through reading an int32 without a proper atomic intrinsic operation call.

[1] https://stackoverflow.com/questions/1006655/are-java-primiti...

wwwigham··on JavaScript for People Who Hate JavaScript
> Kotlin's Any is pretty much the opposite of TypeScript's any. In TS it disables type checking completely (according to the docs). In Kotlin it's the top type (similar to Java's Object type), which anything conforms with, but doesn't expose any operations at all (except for the stuff that the JVM provides for free).

If you want top-type like behavior in TS, you want to use `{}` instead of any, since the language is structural. Anything satisfies it, but it exposes no members without a cast or guard to a more specific type.

wwwigham··on AltspaceVR is Closing Down
More like their 90% use case was subsumed by the new steamvr lobbies...
← PreviousPage 3 of 5Next →