HNHacker News
TopNewBestAskShowJobs

joshwcomeau

2,790 karma · joined February 14, 2016

Software developer. Javascript and stuff.
submissionscomments
joshwcomeau··on The World of CSS Transforms
Oh! This is a helpful insight, thanks. Updating the blog post.
joshwcomeau··on The World of CSS Transforms
Appreciate the heads-up — Which version and OS? And is it all of the interactive demos, or only some of them?
joshwcomeau··on The World of CSS Transforms
Eep, sorry to hear that!

I haven't heard any other reports, and it's working on my fully-updated iPhone hoping this was just a hiccup.

joshwcomeau··on How to Become a Bad Developer
+1, came here to say this. The comprehensibility of the code matters way more than the length. It’s not like the bugs sneak in once every 50 characters typed.

As I’ve gotten more experienced, my code has gotten less fancy and more verbose. A single terse expression is broken out into 3 or 4 statements, defining variables that capture and name fragments.

But yeah, otherwise really enjoyed the article!

joshwcomeau··on The art of Front end Engineering
Yep. In addition to being toxic and wrong and pointless, it also reveals that OP isn’t actually very good at the non-JS parts of front-end engineering. It’s easy to assume that something is basic when you only have a basic understanding of it.
joshwcomeau··on Real-world CSS vs. CSS-in-JS performance comparison
I think an important caveat here is that in a serverside-rendered context, linaria’s 70kb of CSS would be a bigger issue than styled-component’s additional JS. The page can’t render until it has downloaded the CSS.

Granted, many react apps aren’t serverside-rendered, so these numbers are still useful and interesting. But I would say that if performance is a priority, moving to an SSR solution (or away from React altogether) would have a way bigger impact on performance.

joshwcomeau··on Typing, RSI, and what I do differently
I wish I found your comment a year ago! I had cubital tunnel syndrome as well, and was days from spending a lot of money on the ulnar transposition surgery. It’s been ~4 months since then and it’s 95% better, and improving steadily
joshwcomeau··on Typing, RSI, and what I do differently
I’ve learned a lot about RSI over the past year, having spent about 8 months completely unable to type or use a mouse, trying dozens of things and talking to dozens of people. And the main thing I’ve learned is that every story is unique; the right thing for one person might be an absolutely terrible idea for another.

Folks in the comments seem to be making pretty broad statements about what is good or bad, and I just want to let readers know to take everything with a huge grain of salt.

In my case, fear of making things worse was the biggest obstacle — pushing myself to trust that typing isn’t dangerous, even though it hurt, was critical in my recovery. This is awful advice for many people with RSI, though.

My advice: see a physical therapist first. They can often help, or point you in the right direction. If months pass and nothing seems to help, seek out alternative explanations and keep an open mind. Check out The Mindbody Prescription” by Dr Sarno. It was the missing puzzle piece for me.

joshwcomeau··on Show HN: Operator Lookup, a search engine for JavaScript operators
Hey HN!

I created this project because I was sick of how hard it was to google for JavaScript operators; Google ignores certain characters like "?". I would remember the syntax, but not what it was called, or exactly how it worked… and it was surprisingly difficult to research!

This little tool allows users to write the syntax for a given operator, and it provides a name, a description, some examples, and a link to the MDN documentation.

I expect it to be a useful bookmark, for the next time you can't remember what the heck the "?." (Nullish Coalescing) or "??=" (Logical Nullish Assignment) operators are called :)

joshwcomeau··on Hands-Free Coding: How I develop software using dictation and eye-tracking
Appreciate all the discussion!

I touch on this in the article, but I should say: I'm an edge-case when it comes to CTS. Most cases resolve spontaneously. Part of it is that my nerve dislocates when I bend my elbow, and this mobility causes a bunch of additional friction / inflammation. This happens naturally to about 13% of the population, and mine is particularly pronounced.

All this to say, if you ever do start to get a burning or tingling in your elbows or wrists, or get numbness in the hands, it'll likely go away on its own, or with conservative treatment (a physical therapist is a great first step!).

And, for those who also fall into my unlucky percentile, hopefully it helps to know that there are tools and a community that exist to let you keep working without needing to use your hands at all!

joshwcomeau··on Hands-Free Coding: How I develop software using dictation and eye-tracking
Interesting! Maybe I'll look into a voice trainer.
joshwcomeau··on Full-Bleed Layout Using CSS Grid
This doesn't work because `65ch` means very different things depending on the font-size. You need to apply it to a parent class, so that it picks the base font size (I'm not actually sure how this works but in practice it seems to base it on the child <p> tag).

I also don't like the idea of "reaching in" and setting widths on all children. Feels like this could cause problems, especially on replaced elements like images/videos. Not to mention that it just feels wrong when combined with a component architecture, where I might expect a <Heading> component to control its own destiny. In fairness, my solution also reaches in to apply a grid-column, but grid-column is a property that only makes sense when combined with a parent's `display: grid`. So it bothers me less.

Enough people have brought this up that I wonder if I should have addressed it in the article... but then I realize, it's not my job to argue against or "disprove" all alternative ideas. I'm not claiming that my way is the best way, I'm just sharing a cool trick I found :)

joshwcomeau··on Full-Bleed Layout Using CSS Grid
Hi there! Author here.

What I meant is that there is no way to tell certain children to disregard the constraints of a container; if a parent is 800px wide, there isn't a way to say "keep this child in-flow, but fill the viewport".

The alternative you propose is problematic for a couple reasons:

- I don't like "reaching in" to child elements. Especially in a component-focused architecture, it's a quick way to make a mess. My solution DOES reach in to apply a grid column, but that property only makes sense within the context of a grid, so it doesn't seem as problematic to me.

- the `ch` unit doesn't work properly when applied individually to different elements; an `h1` with 65ch width is going to be much wider than a `p` with 65ch width. You need the width to be applied to the parent, so that it remains consistent

- It's likely that you already have a constrained container, if you're adapting this solution to a page that already exists. If so, your approach isn't really workable without a major overhaul.

I'd also just add, the nice thing about using Grid is that it's super extensible. If you want to add a sidebar, it's quick and straightforward.

joshwcomeau··on Build a hit counter for Gatsby with React, AWS Lambda, and FaunaDB
Glad to hear it was helpful :D
joshwcomeau··on Build a hit counter for Gatsby with React, AWS Lambda, and FaunaDB
Ah, I thought “load” was a jQuery plug-in. In that case it’s real code, but it’s only handling the data-fetching; I don’t need React to do that either, but I’d need to generate the hit counter itself (for it to be exactly equivalent, it would need to generate the numbers with SVG as well as add aria labels for screen readers).

The only React-specific thing is the useEffect call, which is essentially comparable to window.onLoad.

joshwcomeau··on Build a hit counter for Gatsby with React, AWS Lambda, and FaunaDB
Really??? Who knew

My point is that my example is complex because some client-side code is necessary. The snippet you shared is nice pseudo-code but a real implementation would be comparable in complexity. Either way you need to learn some stuff, and then it’s a few lines of code.

joshwcomeau··on Build a hit counter for Gatsby with React, AWS Lambda, and FaunaDB
Hey folks! Author here. Just a quick clarification, this is NOT a sponsored post by Fauna, as some have claimed. As the article states, the choice for database is somewhat arbitrary, you can swap it out for Mongo or whatever else you’d like and not much code would need to change.
joshwcomeau··on Build a hit counter for Gatsby with React, AWS Lambda, and FaunaDB
To be clear I am not advocating switching to React in order to add a hit counter. The article is meant for folks who already have a Gatsby/Next site.
joshwcomeau··on Build a hit counter for Gatsby with React, AWS Lambda, and FaunaDB
This article is meant for folks who already have a static React site, and want to dip their toes into doing some backend stuff. It isn’t really meant to be the simplest way to build a hit counter.

That said, I challenge the assumption that this way is _that_ much more complicated. I’ve built similar things with PHP, a long long time ago, and it was a lot of the same pieces. The only part that feels truly more complex is the re-render necessary in React, since the data comes in async, but this is hugely beneficial since it means the page doesn’t need to be server-rendered / the user isn’t staring at a white page waiting for the RPC to the database.

Edit: realizing that there are ways to do this in PHP that aren’t blocking, like if you use an image tag that resolves to the right image, but honestly that way seems wayyy more complex to me, especially when factoring in accessibility / screen-reader-friendliness.

joshwcomeau··on Show HN: A tactical guide for building a dev portfolio that appeals to employers
Hi HN! Author here.

Sharing a book I released today about building developer portfolio sites.

A few months ago I reviewed several hundred dev portfolios on twitter, and found I was giving the same feedback over and over. I also had a lot to say on the subject; I've been involved with hiring for many of the orgs I've worked for, and I've reviewed a whole lot of portfolios in that capacity. I also work as a career coach for a local bootcamp, helping recent grads land their first role.

The book distills everything I've learned into a tactical guide. A portfolio site is only one small part of the job hunt, but I believe doing it well can offer a huge advantage.

I've made it free-to-download because it's targeted at folks looking to break into the industry, people who just invested their life savings into a bootcamp or graduated college with debt. I feel weird charging for this.

(Sorry for the double-post: forgot the "Show HN" prefix, and couldn't delete the original!)

joshwcomeau··on “Building an Effective Dev Portfolio”, a free guide for junior devs
Hi HN! Author here.

Sharing a book I released today about building developer portfolio sites.

A few months ago I reviewed several hundred dev portfolios on twitter, and found I was giving the same feedback over and over. I also had a lot to say on the subject; I've been involved with hiring for many of the orgs I've worked for, and I've reviewed a whole lot of portfolios in that capacity. I also work as a career coach for a local bootcamp, helping recent grads land their first role.

The book distills everything I've learned into a tactical guide. A portfolio site is only one small part of the job hunt, but I believe doing it well can offer a huge advantage.

I hope it's helpful!

joshwcomeau··on Show HN: Royalty-Free SVG Illustrations and Animations
Awesome! Great work
joshwcomeau··on The Quest for the Perfect Dark Mode (Gatsby/React)
Hey thread, author here.

I don't have the energy to debunk some of these replies, but let me quickly say:

1. The reason that this is a hard problem has nothing to do with React, or Gatsby. It has to do with the strategy of precompiling HTML and not having a runtime server, an approach with many many benefits (described here: https://joshwcomeau.com/gatsby/a-static-future/). If you're wondering why anyone would put up with all this tomfoolery for a dark mode, please read that so you can understand the benefits to this approach.

2. "React is overkill for static sites" is a debate I am not trying to have, but I can say that for my blog (the site that this post is about), React has allowed me to do lots of cool things that would have been much harder otherwise. And using Gatsby means that I have first-meaningful-paint performance that beats a PHP template with no JS, since my site doesn't have to do any database lookups or real-time HTML generation. I am not saying that this is the right approach for every website, but it was 100% the right choice for this one.

4. Many of these replies are making suggestions that are discussed in the article itself. CSS variables are not an alternative to this solution, they _are_ the solution (my solution wouldn't work without them!). Please read the post before forming an opinion about it.

I hope that helps clarify some things! Hope you're all doing alright and staying home.

joshwcomeau··on Show HN: Use-sound, a React hook for sound effects on the web
Right, so the reasons this needs to be a hook:

- As someone else said, it manages playback state. This is technically managed by a third-party library, but we expose an `isPlaying` boolean which is held in React state

- It lazy-loads Howler, the underlying audio dependency. This means the bundle cost is ~1kb instead of 11kb (gzip)

- It memoizes all the callback functions to avoid breaking React.memo / PureComponent components

joshwcomeau··on Show HN: Use-sound, a React hook for sound effects on the web
Other commenters beat me to it, but yeah, it's an ergonomics thing. If you have multiple sounds, you can do:

const [playBell, bellOptions] = useSound();

const [playBoom, boomOptions] = useSound();

It follows the convention of other React hooks, like useState.

joshwcomeau··on RFC: Adopt a modern JavaScript framework for use with MediaWiki
A lot of the questions you're rhetorically asking are answered in the RFC you're commenting on.

Specifically, they had real problems with their current system, which they documented here: https://phabricator.wikimedia.org/T225453. Then they explored the available options in the ecosystem and came up with the one they thought would best fit their needs.

If you're gonna be critical, at least take the time to understand what they're doing and why.

joshwcomeau··on The Perils of Rehydration – A Realization about Gatsby and React
Often, the data lives in localStorage, so it isn't really "loading". If your data needs to be fetched asynchronously, a loading state is a fine solution.

Even in this case, a loading solution works just fine, but it's the exact same pattern. You'd just `return <Spinner />` instead of `return null`. You also face the same issue, if you don't wait until post-mount.

joshwcomeau··on Persisting React State in LocalStorage
That's a neat idea!

In the case of something like a blog, though, you anticipate folks sharing the URL. It'd be kinda strange to inadvertently share persisted settings (or worse, stuff that's maybe a little personal)

joshwcomeau··on Persisting React State in LocalStorage
Ah, good catch! Yeah, I changed this partway through, missed that!

Thanks for the heads-up.

joshwcomeau··on Ask HN: What are good solo developer blogs that you enjoy reading?
Shameless self-plug: I blog about React, interaction/animation, and remote work. It's a bit of a pot pourri, but people seem to like it!

https://www.joshwcomeau.com/

← PreviousPage 2 of 7Next →