469 karma · joined November 28, 2023
const foo = () => ({foo: 'bar'})
If you omit the parentheses it gets interpreted as a block with a label and a string literal: const baz = () => {baz: 'bar'}
https://astexplorer.net/#/gist/9a86e0b61fda312dce2ea9d10d37f...Server side developers yearn for their favorite language in the browser, but are used to living in a world where language deprecations mean "this feature will disappear from all modern version of the language eventually" not "you can opt-out of this feature by placing a string somewhere in your code". To me that's a hollow definition of 'update'. Golang for example completely changed the semantics of for loops this year [1]. Moving forward, if you use a modern version of Go, you will accept the way for loops work now — there's no magical 'use old for loops' string. It's awesome that they were able to unilaterally make a breaking change to the language and force users to accept it moving forward. We can't do that in JS, that's the point I'm making.
import { produce } from 'immer'
let i = 1
const a = produce({ x: 0 }, draftState => i++)
const b = produce({ x: 0 }, draftState => void i++)
const c = produce({ x: 0 }, draftState => {
i++
})
console.log({ a, b, c }) // Logs: { a: 1, b: { x: 0 }, c: { x: 0 } }
The immer docs have a section about this pattern: https://immerjs.github.io/immer/return#inline-shortcuts-usin...This is an important point that I think gets overlooked quite a bit in these discussions. Web tech is essentially append only — you can add things but it's incredibly difficult for a browser vendor to make a breaking change because no vendor wants to be perceived as the one that "breaks the Web". Even technologies that were never technically standardized like Web SQL end up sticking around for far too long. I'm not sure if many programming language communities would like to be constrained by this and the slow TC39 language proposal process.
Agreed. I've never found it difficult to manage this. I already tend to configure SSH hosts in my ~/.ssh/config file anyway so that I don't have to remember every IP and port combination for every host I have access to when I want to use SSH (or something that relies on the SSH protocol like rsync or scp).
Yup. Last time I installed an Adobe app on a Mac it refused to install unless I entered an administrator password (and didn't describe why that was necessary), and then made itself persistent so that the Creative Cloud background process restarted whenever I rebooted the computer. Ended up downloading KnockKnock to figure out how it was persisting itself: https://objective-see.org/products/knockknock.html
[1] https://www.mayank.co/blog/safari-focus#keyboard-navigation
[1] https://news.ycombinator.com/item?id=40313171
const result = (() => {
try {
return new URL(someString)
} catch {
return null
}
})()
It's not pretty though, and I think the do expressions proposal would rid my codebases of this pattern: https://github.com/tc39/proposal-do-expressionsYou can publish an extension to the Chrome Web Store for a one time fee of 5$ (and you don't need XCode or a Mac to do it). You can build a website behind a login wall using social sign in via oAuth for free without building a homegrown authentication system (rather than paying 100$ a year for Sign in with Apple which doesn't even adhere to the oAuth spec properly).
Not only do they want to sell you an iPad and a separate computer, but they would ideally like to sell your family multiple iPads, which is why you can't have more than one user account on an iPad (unless you have a business or educational account with Apple [1]).
[1] https://support.apple.com/guide/deployment/shared-ipad-overv...
This point gets parroted so often on HN [1]. You can install packages with the --ignore-scripts flag to disable this behavior, or just set the option globally in your NPM config file. I do like the way Bun disables lifecycle scripts by default [2], but it takes me all of two seconds to run `npm config set ignore-scripts=true` on a new machine, so it's basically a non-issue for me.