HNHacker News
TopNewBestAskShowJobs

jpochtar

584 karma · joined October 10, 2013

I'm https://jpochtar.me/ and I like devtools

https://calendly.com/jpochtar

submissionscomments
jpochtar··on New Grad vs. Senior Dev
There are though, when it checks for '\0'.

`starts()` looks like it's not checking if len(source) < len(query), but if, say, query="foobar" and source="foo", when i = 3 the line

   if (source[i] != query[i])
      return false;
will evaluate to

   if ('\0' != 'b')
      return false;
so `starts()` will correctly return false.

Always if len(source) < len(query), we'll return false when we get to i=len(source), because source[len(source)] != query[len(source)] as source[len(source)] == '\0' and query[len(source)] != '\0' since len(query) > len(source).

jpochtar··on New Grad vs. Senior Dev
Can someone explain the bugs in the code samples? The author says they're there but I honestly can't find them.
jpochtar··on Adding tests when you don't have time to
I like to "make the change easy, then make the easy change". This looks like 2 commits: 1st a refactor to make code more straightforward around the area I'm about to change, and 2nd to actually make the change. Ideally, the 2nd should be a small, local, easy to reason about change, enabled by code cleanup in the 1st.

The 1st commit in this sequence is a pure refactor, and definitionally should change no behavior. The "snapshot test" described sounds perfect for this, especially in unfamiliar code. Ideally, I'd go even further, and have a compiler prove for me that my refactor produced a perfectly equivalent program from a black-box perspective. Snapshot testing is great because it gets pretty close, very cheaply, whereas the full program equivalence problem is impossible.

jpochtar··on Margin considered harmful
> completely flies in the face of separating view from the program layer

HTML is the view layer. The "program" layer is JS manipulating JSON (ultimately fetched from a DB).

Separating HTML and CSS made sense when content lived in HTML, and styling lived in CSS. Content hasn't lived in HTML in a long time— it lives in a DB now. (Maybe markdown if you're making a static site.) Separating HTML from CSS is separating view layer from view layer— just an unnecessary and expensive indirection

jpochtar··on Margin considered harmful
HTML is for styling. JSON is for content.

If you've heard "separate content from presentation" all your career, you might autonomically hear it as "separate HTML from CSS". I used to.

In a React app world, your content hasn't lived in HTML for a long time. It lives in your DB, and comes to you through JSON.

Your React codebase exists to style that JSON. That includes "HTML" (JSX), CSS, and whatever else you've got in there.

Since your HTML is for styling, and your CSS if for styling, why separate them? If you do, you're not separating content from presentation, you're separating presentation from presentation, and that's just wasteful.

Personally, I'd prefer to use inline styles for everything, though of course will use CSS for :hover of @media queries where I have to.

jpochtar··on Launch HN: Fly.io (YC W20) – Deploy app servers close to your users
Why not just have the rails app exposing GQL also expose the customer UI/etc?
jpochtar··on Docker is a dangerous gamble which we will regret (2018)
By expecting Docker users to know more than they do, the author thinks they're dumber than they are.

Docker users are mostly folks who specialize in other areas of programming, to whom Docker popularized affecting "fat binaries" out of PHP/Ruby/Python/node apps via chroot. Chroot was already well known to ops folks, but was arcane to most webapp devs.

We're not ops experts who have been confounded by marketing, we're ops amateurs for whom Docker cracked the nut of chroot legibility.

The author hates on Docker in comparison to other fat binary techniques; he ignores that pro-Docker advocates are comparing it to not using fat binaries at all.

jpochtar··on Debuggers Suck
As someone who's also worked on a debugger, I'm sad to say many programmers aren't working on problems that needed complex debugging. I couldn't understand why friends weren't interested in what I was working on, until I realized they were building CRUD apps all day.

There's little control flow to speak of in there, so if they had a problem, they could just dump locals() to get a good view of everything that happened.

When I went back to doing compilers work, I missed my debugger dearly. I also realized why I needed a debugger and my friends didn't: debuggers like this are particularly useful for work with compiler-like characteristics, of which there is unfortunately not enough.

jpochtar··on Simple-twitter: A bare-bones Twitter clone implemented in a single file
Small, easy to write/maintain approaches are at an evolutionary disadvantage vs classically "enterprise" styles.

Easier to work with -> fewer people needed -> fewer people hired -> fewer people learn -> fewer people know.

Now there's fewer people in the market who know Simple, vs many people who've learned OverEngineered (TM). Leadership wants to pick a language/style they'll be able to hire for as-needed. OverEngineered has a much larger talent pool.

jpochtar··on In Defense of Utility-First CSS (2018)
Just use inline styles and simplify your life. If you’re using React/Angular/Vue/etc, your markup is styling; so why are you separating styling (html) from other styling (css)??
jpochtar··on When XML Beats JSON: UI Layouts
Are you sure you want hierarchy though?

  [
    ["the ", {}],
    ["JSON format", {"link": "https://www.json.org/"}],
    ["was invented by ", {}],
    ["Douglas Crockford", {"bold": true}],
    [".", {}]
  ]
jpochtar··on Goodbye, Flash
I worked on a WYSIWYG HTML editor (Pagedraw) for a while, and came to the conclusion it's overkill for the problem of browser layout.

For CRUD apps, you really just want HStacks, VStacks, and ZStacks like they have in SwiftUI.

They nicely express reflow behavior without driving you crazy or bloating your code. They're a bit more work than drag-and-drop because they make you be explicit about resizing/reflow, but you should be thinking about that anyway.

You'll want to skip that step when iterating quickly on design, but that's why you design in a separate design tool, which is visual and uses position:absolute.

When you're ready to parameterize the design over varying content and screen sizes you'll have to specify resizing constraints somehow, and in my experience, VStacks/HStacks in code are a pretty good way to do it.

I recommend adding building these abstractions on top of flexbox, and adding them to your standard library.

This is all specifically for CRUD apps. If you're making an animation, or something else that would feel wrong to call a "document", you probably want a completely different set of tools.

jpochtar··on Ask HN: What is the most beautiful piece of code you've ever read?
Because of Norvig's spelling corrector, my measure for good code is whether or not I can understand what it's supposed to be doing, and how it's supposed to work, from reading it in one pass.

This code passes that test. Before reading it I would have never thought that could be a goal— I couldn't imagine it was possible to know what a program does without comments and documentation.

When I heard the word "readable" from others, I understood it as "parsable". From an OO context, I thought readable meant neatly formatted lines that let you say "ah, yes, this is an if statement", "this is a constructor", and so on, but with no idea what the code actually does or means to do.

Norvig's spelling corrector is better read without comments. The names of the functions tell you what you need to know— their purpose, and their implementations tell you exactly what the author thinks they mean.

It's "declarative": "def correction(word):..." means exactly "the correction of a word is ___", "def candidates(word):..." means exactly "the candidate corrections of a word are ___". There's a strong functional/LISP influence here, which I only learned later.

Because this code demonstrated it was possible, my standard for all code is that it should tell you what it does from one reading. Most code (including my own!) doesn't come close, but aiming for that goal has tons of good effects on difficult code.

jpochtar··on Ask HN: What is the most beautiful piece of code you've ever read?
https://norvig.com/spell-correct.html

Changed the way I think about code

jpochtar··on “C is not how the computer works” can lead to inefficient code
;)
jpochtar··on “C is not how the computer works” can lead to inefficient code
For many people, "C" means C+{gcc/clang}+{x86/arm}, which has much more specific semantics than the C99 abstract machine.

They'll ask interview questions like "what's sizeof(int)" expecting a number, and will find "it depends on the compiler/architecture" evasive, unless you follow it up with "but it's always 4". To be fair, this is how 99% of people use C in practice, and x86/arm behave pretty similarly to each other in the scheme of things (vs, say, a LISP machine).

Taking into account ABI constraints, including x-{language,module} call safety, threading expectations, and more, a typical C programmer has to have a decent idea of how the machine works, relative to a Python/JS/Ruby programmer.

I don't love that someone "learning C to learn how the machine works" will think malloc()/free() are how the machine works, and will get have wrong expectations ideas about memory when using, say, V8's bump allocated nursery + compacting GC. But it's not a bad first step for someone who doesn't know what a pointer is to the machine.

jpochtar··on React Concurrent Mode
Rails is probably a better fit for your needs. If you're primarily concerned with sending forms to and showing data from a server, React isn't going to give you much.

React is great for Figma, Dropbox Paper, Coda, and Pagedraw: apps that are basically entirely local, and may or may not happen to be syncing with a server in the background.

CRUD is a special case of app, and the modern HTML/CSS/JS browser is pretty well tailored to handle all the needs for the client side of one. Maybe sprinkle in some Turbolinks [1] if you want some fancier page transitions.

It'll take time before someone makes a good CRUD framework on top of React. Until then, Rails is a great CRUD framework, and isn't missing much I'd expect to see React solve.

[1] https://github.com/turbolinks/turbolinks

jpochtar··on SF to Establish Office of Emerging Technology
Welcome to New York! [1]

[1] https://www.youtube.com/watch?v=L0N3C6DsisQ

jpochtar··on Code Is Not Literature (2014)
Most code is unreadable, but that doesn't mean there isn't beautiful code out there worth reading.

https://norvig.com/spell-correct.html is like poetry— or at least what I imagine poetry is like to people who like poetry.

Reading it changed the way I look at code, and inverted what I consider good code.

If it's not in a super high level language it probably won't be beautiful, at least not in the same way as Norvig's spelling corrector. For lower-level code, approaching it like a scientist, as OP suggests, may be right; I wouldn't give up on a reading group for sufficiently high-level code.

jpochtar··on Learning Python and Haskell has not improved my programming (2006)
I compare it to Morty experiencing “true level” [0]

[0] https://youtu.be/w-wbWGwZ7_k

jpochtar··on Bill Gates Resume (1974)
This is the first I've seen mention Bill Gates knows LISP. Are there any famous programmers who don't know LISP?
jpochtar··on Documentation to set up a simple macOS VM in QEMU, accelerated by KVM
Spaces on Leopard (pre-Mission Control) fit my brain like a glove. I'd love to get them back. I have 9 "spaces" in a horizontal row in Mission Control, but in the original Spaces they were in a 2D grid. The 2D gave me a sense of spacial reasoning about where things were.
jpochtar··on What Went Down at WWDC 2019
Why not just auto-update the OS??????????

Non-auto-updating software is the problem

jpochtar··on Chromium and the Browser Monoculture Problem
This is a good take. Standards were a weapon to fight Microsoft's closed source IE— emphasis on closed source. Why? Competing browsers needed to be IE-compatible to matter, and without standards spec-ing out what IE's doing, it's hard for other vendors to know if they were 100% compliant.

Now that the major browser everyone's coding against is open source, and competitors can freely borrow their engine, I'd say we don't really need the W3C anymore.

jpochtar··on SwiftUI
Fantastic work you've done here!
jpochtar··on SwiftUI
fmr founder of Pagedraw here... this looks amazing. I wish we'd built it! :)
jpochtar··on The Economics of Package Management
I think I'm out of the loop... can someone fill me in on relevant NPM drama? Are they monetizing successfully? Unsuccessfully? Unethically?
jpochtar··on How to use array reduce for more than just numbers
reduce() is how you get imperative programming in a functional setting. JS is a perfectly good imperative language; for all these examples, you may as well use a for loop.

Personally I prefer a functional style, but if you're going to use an imperative style, just use JS's built-in imperative for loop and assignment operators.

jpochtar··on San Francisco bans facial recognition technology by municipal agencies
New York. Having lived in both NY and SF, New York is so much better re: the homeless.

Also Tokyo seems pretty great, but I haven't lived there.

jpochtar··on Immediate Mode GUI
I mean, React is essentially a hack to get an immediate mode API on top of a retain mode platform (DOM), because the immediate mode API scales better to handle complex state.

I'd push that yes, you do have to maintain your state externally in an immediate mode UI, but when you have a lot of "state" that's really just a function of other state, that's exactly what you want.

← PreviousPage 2 of 5Next →