HackerTrans
TopNewTrendsCommentsPastAskShowJobs

mgreenw

no profile record

Submissions

'Do' More with 'Run'

maxgreenwald.me
43 points·by mgreenw·3 jaar geleden·30 comments

comments

mgreenw
·vorig jaar·discuss
Puck is a marvel of drag and drop engineering and a wonderful open source project. Kudos to the team for this release!
mgreenw
·2 jaar geleden·discuss
GCP charges for egress though. Agreed with OP, please bring Neon to GCP! Why Azure first?
mgreenw
·2 jaar geleden·discuss
‘Twas a joke about JSON Web Tokens _sigh_

Note: my original comment said “JWT”
mgreenw
·2 jaar geleden·discuss
Are we sure they verified the claims in that JSON Web Token?
mgreenw
·3 jaar geleden·discuss
Exactly! I wrote a post about this pattern: https://maxgreenwald.me/blog/do-more-with-run
mgreenw
·3 jaar geleden·discuss
I wrote a blog post about my experience with Dvorak!

TL;DR It's great, but if you're interested you should use Colemak. Once you switch you won't go back.

https://maxgreenwald.me/blog/switching-to-dvorak
mgreenw
·3 jaar geleden·discuss
Try using `run` in the return of a React (or similar) component and you'll never go back ;)

There is always a balance here. I'm not saying to never extract a named function, and there is certainly good reason to do that, especially if the function is called elsewhere or is quite complex.

But, in many cases, the inline logic is more readable because it's right there, and the function really doesn't need a name.
mgreenw
·3 jaar geleden·discuss
Same, I've written this so many times. Node just added this as a built-in utility FWIW

https://nodejs.org/api/timers.html#timerspromisessettimeoutd...
mgreenw
·3 jaar geleden·discuss
> 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.
mgreenw
·3 jaar geleden·discuss
Yes, I do think the extra parens are less readable.

Its not about number of characters, its about reasoning that the inline function that you just wrapped in parens is then called later, potentially after many lines. At least with `run` it's immediately clear based on the name that you are running the function.

Edit: This is pretty funny. I'm a parensaphobe! (not really) https://www.reddit.com/r/ProgrammerHumor/comments/qawpws/the...
mgreenw
·3 jaar geleden·discuss
Completely agreed, and I use this if-based early return syntax frequently! That being said, I like using `if` and `else if` and `else`, but maybe that's just me! I don't think there's a substantial difference in readability or utility.
mgreenw
·3 jaar geleden·discuss
Well you definitely can do that to my somewhat contrived example that is loosely based off of an example from the `do` expression proposal, but I'm not sure its better.

Part of the beauty of `run` is that you don't have to declare and name a function `calcX`. In longer and more complex examples, declaring a function inline like this is potentially confusing because you don't get to see where it is used, whereas with `run` you assign the return value immediately to a variable.
mgreenw
·3 jaar geleden·discuss
Great, but the design and usability is still terrible compared to Slack. Not sure that can ever be fixed.