HNHacker News
TopNewBestAskShowJobs

catpolice

666 karma · joined July 23, 2015

submissionscomments
catpolice··on A Brief Glance at How Various Text Editors Manage Their Textual Data (2015)
I think the claim is that this is true in practice (among the surveyed options) not that it is true in principle.
catpolice··on MS to Give Windows 10 a ‘Modern’ Overhaul with Light Weight Polaris Windows Core
Microsoft is the one who said it will be called Windows 10 when it's done. They've repeatedly stressed that Windows 10 is the last numbered update to Windows. That's not to say that the underlying technology won't change, even radically - it's just that this will be done through Windows Update as an upgrade to the existing OS rather than a new OS that you won't have access to without purchasing an upgrade.

They realized at some point that they had several concurrent versions of Windows out there that they had to support, and many customers had no apparent incentive to upgrade to new versions. So going forward they ostensibly have a single version that auto-updates, and they provide the OS "as a service".

catpolice··on CodeReddit – Reddit that looks like code
The market's pretty saturated with bootcamp grads right now. I get literally hundreds of responses every time I post an opening.
catpolice··on The Brutal Lifecycle of JavaScript Frameworks
I always have to show up to reiterate this is not a problem limited to Javascript. There have been framework fads for as long as there have been frameworks. I have dim memories of dozens of C++/Java/Python/Ruby/etc. next-big-things.

It does seem like there are more of them and they rise and fall faster in the Javascript world, but this is probably better explained by the sheer number of Javascript programmers than anything else. The labor statistics I can find peg the number of US software developers in 2002 at around 612,000 and around 3.87 million in 2016 - and most of the new ones focus on web development. There are way more web programmers out there than there have really ever been, so it makes sense that the rate of frameworks appearing (and to a degree, the overall lifecycle churn) would be accelerated.

catpolice··on What does code readability mean?
There's a sense of "unreadable" that I sometimes use that means "the code does not contain the information that you need to understand how it will typically function". E.g. things that have internal control flow determined by complex input processing where the input is ill-specified. It can be essentially impossible to put together a mental picture of the operation of the program, because key parts are essentially unspecified.

And there's a related sense that I occasionally use to describe code that's so difficult to follow (in the sense that the control flow or structure is needless obfuscated) that the process of trying to understand it doesn't really resemble simply "reading".

Some examples:

A function is called in many places in es6 code. I want to see its definition, my editor can't figure it out. I look at the import statement, it's imported from a file. I open that file, and all it does is export * from a dozen other files - so now all I know is that it's in one of these dozen files. I am reduced to doing something like grepping for the function name and looking for the case that looks more like a definition than a call. At one point I was reading the code, now I'm doing something related and more involved than just reading.

Or, in this system components emit message objects with a "title" field. The messages are dispatched to dozens of functions across files that inspect the title field to determine if they do anything with it. Only they don't just do a simple comparison against a string literal, they check if the title meets a regex. There are many of these different regexes. I read the code that emits the message and I want to know what behaviors the message being sent out triggers - how do I track that down? I can't even grep for the message title. In order to make a list of things this message might do, I have to look through everything that might possibly handle the message and try to figure out which regexes are triggered.

In this case, reading is involved in the same way that reading through a math book and solving the exercises does involve reading - that's not where most of the work comes from.

catpolice··on Use a Render Prop
I started today by setting out to write a response of the form "Certainly you couldn't rewrite MY HOC library to use render props, look at how it [etc]" and ended today having rewritten my HOC library to use render props. In the process, I was able to dramatically simplify the API and remove about a third of the overall code.

So, uh, thanks.

catpolice··on A regression is the kernel not giving the same result with the same user space
I think of the line from the Big Lebowski a lot: "You're not wrong, Walter. You're just an asshole."
catpolice··on A regression is the kernel not giving the same result with the same user space
Zero could be a perfectly "valid" value and still break your application if changing the function to always return zero breaks an implicit contract. Suppose the previous behavior of the function returned something you could use as an ID for some internal representation in a database that you could look up and write to. Before, the ID you got back depended on the input, but now it doesn't. And you can't tell you're not getting real IDs back anymore, so you just happily write to the database. Now you're corrupting your database because the implicit behavioral contract you were relying on was broken - I'd MUCH rather the program just crash than for it to continue "working" in a way that irrecoverably corrupts data.
catpolice··on Ask HN: What is your yearly passive income?
Many of the things I would be tempted to describe (and am seeing others here describe) as passive income aren't, at least in the strict sense: http://www.investopedia.com/terms/p/passiveincome.asp

In the colloquial sense, I made about 18k last year off of money I dumped into Betterment a while before. I don't do anything but periodically check on how much money I've made. I wish I'd started passively investing about a decade earlier. If you have anything beyond an emergency buffer just sitting in your checking account, just do it.

catpolice··on ProseMirror 1.0
Cool to see persistent data structures under the covers here. I tried to make a contentEditable editor some time ago and gave up when I realized how many edge cases there would be, but from what I learned when working on that, this general sort of approach seems like the right way.

What do you feel like you learned when working on this project? Will any of it make it back to Codemirror?

catpolice··on An impossibility theorem for gerrymandering
At this point I feel like it's worthwhile to remember to why we even have districts.

We could, in principle, get rid of the districts and just have some kind of statewide scheme for electing representatives proportional to the outcome of a popular vote. The idea behind retaining districts, as far as I understand it, is that people in similar locales will often have very correlated interests (e.g. with regard to decisions that affect that area) and that choosing representatives from particular locales is supposed to guarantee that people in that area are represented (and make the representatives to some degree beholden to them).

Ideally, we'd split the states into districts in a way that doesn't deviate from overall proportional representation very much, hence the idea of the efficiency gap. So gerrymandering can break that efficiency constraint.

But the notion of geographic correlation of interests makes it such that the population is unlikely to be distributed in the kind of uniformly random way you need to get weirdly shaped, efficient districts, and conversely having weirdly shaped districts at all effectively assumes that geographic correlation of interests isn't an important factor.

In other words: if we have to make weirdly shaped districts to maintain efficiency, then the assumptions that caused us to require districts in the first place probably fail and we should just ditch them.

catpolice··on The Land of Lisp
Perhaps they meant "idiosyncratic"
catpolice··on Diminishing returns of static typing
I think it depends on language and context a lot so I can only give some vauge advice. A lot of the idea is to write code that only does the one thing you know you need it to do, does it very simply and fails very obviously when it's not used correctly. In some cases your instinct is to make things as generic as possible at the first pass. Preemptive abstraction pays off more in statically typed languages, in my experience, because it saves you the time of refactoring a type system in place if you turn out to need flexibility later. But in dynamic languages it can introduce complexity that hides bugs.

Simple type-level errors come up the most when you have types that are easily conflated. That tends to happen when you have functions that accept more than one type of thing or output more than one type of thing - avoid that. Avoid polymorphism and OOP patterns that set up a complicated type hierarchy or override methods - you don't want any instance where you end up with something that looks a lot like one type of thing but isn't. Type hierarchies can often be factored out into behaviors provided by modules that supply functions that operate on plain data structures. For variables and parameters, stick to really simple types to whatever degree it's possible, e.g. language primitives, plain old data-container objects and "maybe" types (e.g. things that could be a primitive or null) when absolutely necessary (and check them whenever you might have one). Use union types extremely sparingly. Assignment/creation bottlenecks are useful: try to have only one source for objects of a certain type that always constructs them the same way (so you don't end up with missing fields).

A lot of programmers coming from a language with a stronger type system (especially when transitioning from OOP languages to functional or hybrid languages) tend to be nervous about writing functions without a guarantee about what kind of inputs they'll see, so they try to compensate for the lack of type safety by building functions that can cope with whatever is thrown at them. The idea is that this makes the function more robust but ironically, this tends to make bugs a lot harder to track down. In my experience it's better to write functions with specific expectations about their input that fast-fail if those aren't met, instead of trying to recover in some way - garbage-in-exceptions-out is better than garbage-in-garbage-out. If you send the wrong kind of thing to a function, you want it to throw an error then and there, and you'll likely catch it the first time you test that code.

A lot of the idea of this kind of advice is to shift the work that would be done by the compiler's type system to the very first pass of testing - if your program is basically a bunch of functions that only take one sort of thing in each argument slot, only emit one sort of thing as a result and fail fast when those expectations are violated, you'll typically see runtime type errors the first time those functions get executed, which is a lot like seeing them at compile time.

catpolice··on Diminishing returns of static typing
Static typing prevents bugs in code to the degree that the programmer can correctly encode the desired behavior of the program into the type system. Relatively little behavior can be encoded in inexpressive type systems, so there's a lot of room for bugs that have nothing to do with types. A lot more behavior (e.g. the sorts of invariants mentioned in agentultra's top level comment) can be encoded in a more expressive type system, but you then have the challenge of encoding it /correctly/. A lot of that kind of thinking is the same as the kind of thinking you'd have to do writing in a dynamic language, but you get more assurances when your type system gives you feedback about whether you're thinking about the problem right.

For my money, I work in a primarily dynamic language and I already have a set of practices that usually prevent relatively simple type mismatches so I very rarely see bugs slip into production that involve type mismatches that would be caught by a Go-level type system, and just that level of type information would add a lot of overhead to my code.

But if I were already using types, a more expressive system could probably catch a lot of invariance issues. So I feel like the sweet spot graph is more bimodal for me: the initial cost of switching to a basic static type system wouldn't buy me a lot in terms of effort-to-caught-bugs-ratio, but there's a kind of longer term payout that might make it worth it as the type system becomes more expressive.

catpolice··on Text Editor: Data Structures
One thing I think about a lot in these situations is how constraints that come in at the high level can end up influencing your low level design. I've spent the last couple months writing a codemirror replacement for an in-house DSL IDE (in Javascript).

My particular use case required that I parse whatever was written in the editor in a few ways: a lexer pass for syntax highlighting and a full parse for semantic feedback (much of which is provided somewhat unpredictably from AJAX calls, for various reasons). And I knew that touching the DOM (which I'd have to do to keep the syntax highlighting/semantic feedback up to date) is typically going to be a lot slower than doing a few thousand loop comparisons in JS.

I looked into structures like ropes and whatnot that would enable fast edits, but I realized that in the end I wasn't going to do better than linear in the worst case, for a few reasons, e.g.: 1. Suppose the user enters an open quote at the first character: every other character just flipped from outside a quote to inside or vice versa and I'm going to have to re-parse the whole document to update my semantic analysis (and syntax highlighting, though that would only require a partial re-parse). 2. Edits that change the line number associated with errors are going to require me to update that display and you can make a document with a number of errors that grow linearly, so entering a newline at the first character was potentially linear...

So I ended up just using a doubly linked list of tokens (as returned by the lexer) and re-lexing tiny sections around a cursor when the user enters text. Collectively the whole thing turns out linear and but it saves a ton of work by re-using the same structure when I'm doing parsing and semantic analysis. Doing it this way let me do my own DOM reconciliation and update the absolute minimum number of DOM nodes for every edit, which ultimately has a huge effect on performance because touching the DOM is expensive. And one can set this up so that (at least from the lexer's perspective) undo involves just snipping the old middle segments of the list back into place.

So it turned out that higher level requirements (eventually having to actually parse the text and update the display in various ways) made it so I wouldn't really save any work optimizing at the low level.

catpolice··on The rise and fall of Ext JS
I wish that I had been confused, it was an appalling thing to find. Basically, it was an interaction between the template system (https://docs.sencha.com/extjs/6.5.0/modern/src/Template.js.h...) and their dynamic class loader (https://docs.sencha.com/extjs/6.5.0/modern/src/Loader.js.htm...). The template system used regexes to look for JS expressions to evaluate inside HTML templates and then tried to figure out how to supply them with values. I had some /very/ complicated templates and IIRC it picked up on some commented out bits and ended up triggering the loader's dependency resolution. Again, I'm not saying it was running like a babel-style parser in the browser - it was just regexing for certain expressions and dynamically loading classes based on the results.
catpolice··on The rise and fall of Ext JS
I doubted it too, until I saw it and could come up with no other explanation. I don't think it was a full parse, just something like a dumb grep for certain patterns. It threw errors trying to import something that was only mentioned in a comment, and removing the comment fixed it. I wish I could find the bug report.
catpolice··on The rise and fall of Ext JS
I remember the moment when I drew a line in the sand and simply refused to use ExtJS any more: I discovered that the mysterious bug I'd been hunting all day went away if I removed a comment.

It turns out that ExtJS was building some kind of dependency tree by scanning my source code (at runtime!) and looking for things that looked like variable assignments. And it got confused by a commented-out assignment. I don't remember exactly how this caused things to break, but I do remember walking through the stack trace, slowly figuring out what it was doing, and then simply getting up and leaving for the day.

No thanks.

catpolice··on The end of Framework Churn
I guess I'm not saying that there aren't conceivable situations where you'd need an ID - it's just that they're typically small issues that are easily worked around. A duplicated "for" attribute problem is going to come up when you have two forms on a page and both of them use labels in this way and use conflicting IDs. There's a potential collision, but it's relatively easy to foresee and prevent, I've never seen it come up in practice and the worst outcome when it goes wrong would be something like the user's input focus going somewhere unexpected if they click a label instead of a control.

W.r.t. CSS name clashes, yeah they can come up especially in the contexts of independently developed React components. But in my experience over-encapsulation comes up far more often in the same context. I'm almost never in a situation where I want to slot a component in as-is. Instead, I want some find grained control over its styling or behavior, and if that's hidden behind an encapsulation barrier, that makes re-use even harder.

I do think the React component paradigm has some issues, but IMO they're the same sort of issues that come up in a lot of OO designs where abstraction and encapsulation happen in the wrong places. I still feel like Web Components solves some re-use problems I rarely if ever see in practice while doubling down on ones that I do.

catpolice··on The end of Framework Churn
I was really pumped about Web Components at first, largely because this sort of argument made a lot of sense to me. A few years on, I'm a lot less convinced that these are the problems that need to be solved.

Element IDs, for example, are useful if you're doing a kind of old-fashioned select-and-mutate approach to DOM management. But if you're using React idiomatically, you're never running query selectors or ever reading from the DOM at all (modulo trivial things like getClientHeight in lifecycle methods). It's hard to imagine when you'd have an ID conflict with React because it's hard to imagine when you'd need an ID.

Similarly, over the past few years I've had maybe two or three cases where CSS leaks due to under-encapsulation were a problem, and I was able to pick up on them and solve them with very little effort. Over the same period I've devoted much, much more effort to solving problems with over-encapsulation in cases where I needed to style a supposedly reusable component but some clever attempt at encapsulation (e.g. inline styling) prevented me from doing so and forced me to do a lot of work or re-implement the component wholesale.

I've known a few projects that were excited about things like Shadow DOM and went through a lot of work to incorporate them only to end up stripping them out (see Atom: http://blog.atom.io/2016/11/14/removing-shadow-dom-boundary-...) for related reasons.

So at this point I see a lot of the touted benefits to things like Web Components as a potentially painful set of solutions to a set of problems I've never really had. I don't really get it, but maybe they scratch some itch I don't have.

catpolice··on The end of Framework Churn
Yeah, this. I'm not actually sure the war is fully winnable - maybe it'll slow down at some point.

UI frameworks have churned in every language I've ever worked with. Java had AWT/SWT/Swing/JavaFX/etc. I can't remember all the C++ options. There have been more JS frameworks and the turn over rate is higher, but that makes sense given how UI-focused the web applications have to be and how fast the underlying platform has changed.

User interfaces have to react to (and inform) a lot of internal application state, which means they often need to be coupled to the application architecture. Furthermore, interfaces are often refactored and customized in ways that are hard to predict from the outset.

So for one thing, I've never really found components to deliver on the promise of re-usability and compatibility - I always end up having to dig into the internals and make some changes to get exactly the behavior I want in a way that fits in to my system's overall architectural requirements.

But also, this tends to spell trouble for opinionated frameworks in general - the assumptions you make aren't going to work for all applications, and the ecosystem of applications (e.g. the migration to SPAs) or platform technologies (e.g. ES language and web API changes) might change out from under you.

So my advice for most web devs is: stop thinking "when will this end?" and start thinking "how can I make myself less vulnerable to the worst parts of this?"

Using less opinionated frameworks is a good step. Big, do-everything, opinionated frameworks tend to have to be replaced wholesale if there's something missing or wrong with any part of them, or they're just not compatible with the approach you need to take for a given project. I can count a handful of things that were supposed to finally solve all the problems of web development that aren't officially supported at all anymore. React actually makes some progress on this front - it's a lot less opinionated than its early competitors, e.g. Angular, Ember, etc. More modular systems that are based on a few interacting libraries that can be swapped out are ironically more stable even though they're more vulnerable to low-level churn of changing bits and pieces because frequent small changes tend to be less traumatic than periodic big ones.

catpolice··on The design side of programming language design
Yeah, I was cringing the moment I saw it. No rake on the fork? All that extra frame weight, only to introduce joints that maximize /lateral/ flex? Imagine the stress that top tube joint must be under in even normal riding conditions. This is a bike designed by a graphic designer who intends to decorate a wall with it.
catpolice··on Why I Fell in Love with Arch Linux (2015)
Last time I did the research there wasn't a striiiictly better alternative to systemd, which is rather unfortunate. There are flame wars beyond number on the subject and I'd rather avoid starting another one. For my two cents: I don't like how it's gobbling up all the functionality that used to be owned by separately maintained and tried/tested processes, in a way that seems to limit my ability to put together a minimalistic system, and the developers' attitude toward security and how they've handled criticism is not so great. I'll use it, but I don't like it.

For me, there are ecosystem/adoption reasons for why any alternative is a tough sell - any distro basically has to have the startup system baked into their package manager, if you're going to be able to install packages that depend on daemons, etc. So if updated package availability is a concern (and it is for me), I need a popular enough distro. And basically all the popular distros use systemd. So unless I want to make some pretty big compromises or do a ton of work, I'm stuck with it.

catpolice··on Why I Fell in Love with Arch Linux (2015)
I used to love Arch wholeheartedly. The systemd transition left a bad taste in my mouth, and I haven't felt like I've had full control of my system since then, but I periodically try other Linux distributions but I always end up coming back to Arch. My experience with other distributions always goes something like this:

Oh this is nice and easy

Hm, there isn't a package for this thing I love. I guess I'll build it myself...

[Several hours pass]

Ok, looks like I just need to get XYZ working and I'm good, lemme google how to do that for this distro

It looks like this is automatically configured using some Windows-style control panel hidden somewhere. Google suggests seven different places I could look for this option, corresponding to previous versions of the distro...

Wouldn't editing a config in /etc/ be easier than this? I'm reinstalling Arch...

catpolice··on Wilson’s Algorithm
Ah, this is very similar to some old maze generation toys I was working on a few years back. I was experimenting with adding a little extra stochasticity to the mix. E.g. selecting from the last ~30 neighbors added creates interesting mazes with "multiple growth fronts" rather than one tendril or a uniform expansion at the edge. You can see a GIF example here: https://raw.githubusercontent.com/j-s-n/mazes/master/example...

(My code uses toroidal topology, which is why you can see things going off the edge and coming back on the other side.)

And things like varying whether new neighbors are added to the head or tail of the list adds a little perceptible chaos. It's too bad it looks like my demo site is down right now.

There's a (old, badly documented) JS demo here with about 6 variant algorithms: https://github.com/j-s-n/mazes-js

And a better documented but still out of date Python example (that hand-encodes an animated gif here): https://github.com/j-s-n/mazes

catpolice··on [dead]
I expected the answer to always be "you have no money, I just took it all".
catpolice··on Daylight Visualizer
"Daylight visualizer" is basically my job title.
catpolice··on Redesigning Android Emoji – Google Design
The previous emoji were almost uniformly better looking. It's a shame - they were one of my favorite features of Android.
catpolice··on Is Quantum Theory About Reality or What We Know?
Oh Hey, I know the author of this! In fact, I think I introduced him to that Spekkens paper. Small world.
catpolice··on What programming languages do you know and which ones do you want to learn?
Personal anecdote: the weirdest language I've ever used was a domain specific language that was adapted from punch cards used by a bank. It was basically a really weird assembly language. All the variables had 3-letter names, there were exactly 256 of them and they were all globally scoped. There was a custom IDE, but you couldn't freely edit the source as text, the programming was done via drop menus, where you selected the operation you wanted to perform, then scrolled through the list of 256 variables to select which variables to use as arguments...
← PreviousPage 3 of 5Next →