Hacker News new | ask | show | jobs
by Waterluvian 1126 days ago
Feels like code golf. The two run examples are basically the same, but now I have to reason about what ‘run’ is and I’ve made my stack trace more complicated.

I am in love with “everything is an expression” from my time with Rust. I regularly use a ‘let’ and wish I could just have the entire conditional feed into a ‘const’ given it’s never going to change after the block of code responsible for assignment.

I wish there were more generations of ‘use strict’ so that we could make bolder, more breaking changes to the language without breaking stuff or dying in a horrible fire of “just roll your own dialect using compiler plugins.”

4 comments

> I regularly use a ‘let’ and wish I could just have the entire conditional feed into a ‘const’ given it’s never going to change after the block of code responsible for assignment.

I'm currently doing a lot of audio work, where I kind of want to define some parameters early on that won't change, except if something "magic" happens. So, a kind of "unlockable" constant. Think in terms of, a bunch of filter coefficients that are predetermined by the design of the filter but need to be calculated to match a given sample rate.

Just a kind of "set and forget" variable, that ought not be written to more than once, or maybe only written to by the thing that first wrote it.

> I am in love with “everything is an expression” from my time with Rust

Totally agreed! I wish JS had if expressions (maybe in the future?). It doesn't seem like such a huge change if it were rolled out slowly like other new syntax features but maybe I have no idea what I'm talking about.

Hopefully things like `run` can help move the needle on this. I like it because it feels more FP and intentional than IIFE's everywhere.

Not even code golf given that the example is a single character longer. Naming it "r" would be code golf (and "r" is definitely worse than "run" for reasoning).
What some people call "code golf," others call "syntactic sugar." :-)