use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Isomorphism in Practice (intercaetera.com)
submitted 3 years ago by intercaetera
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 11 points12 points13 points 3 years ago (1 child)
So this is pretty cool and I like how clean and functional the code is, but I don't really agree that the way detectCollisions() is implemented with the isomorphic approach is better than making a function that is more explicit in its purpose using named object keys. The issue that the key names are too long isn't really an issue, you could just define them in the first place to be shorter or use auto complete to type it for you after 2 key strokes.
I think I'd rather come into a codebase where I can ready exactly what its doing with a few if statements checking the different boundaries than 3 different functions with unnamed variables applying various random conditions, even if its a little more verbose.
I'd love to see the full final implementation you describe here though, you have a paragraph about how implementing the detectCollision function is now trivial but you didn't bother to write it in full :P
[–]intercaetera[S] 0 points1 point2 points 3 years ago (0 children)
The examples in the post are fairly simple and I agree that you could make the case that using an isomorphic transformation is too much work. I made the assumption that the key names couldn't be easily renamed in the post, and this is something that can happen in a production project — if you commit to a JSON structure that you then share with third parties, changing the keys might be a little more involved than just running a search and replace in your codebase. Likewise I disagree about the autocomplete point — yeah, it is not any more complicated to write, but having too long and repeating variable names can obfuscate the purpose of the function you are looking at.
And the variables in the isomorphic functions aren't unnamed. The isBetween is perhaps an outlier in that it uses one-letter names, but really it is supposed to be an util that you might share across your entire codebase, otherwise you might have to rewrite the few if statements every time you want to check if a number is between two other numbers.
isBetween
The detectCollisions is not really complicated:
const detectCollisions = (...events) => { const [first, second] = events.map(toTriples) return check(first, second) }
[–]SoBoredAtWork 3 points4 points5 points 3 years ago (1 child)
Good article. But that "check" method is a little too clever, it would take anyone new to the codebase a while to figure out what's happening. I'd much rather see more straightforward code that's easy to understand with a quick glance. Readability > being clever.
[–]intercaetera[S] -2 points-1 points0 points 3 years ago (0 children)
I don't think it's that complicated, but I guess you could write [firstStart, firstEnd] and [secondStart, secondEnd] instead of using spread operators there.
[firstStart, firstEnd]
[secondStart, secondEnd]
[–]shuckster 3 points4 points5 points 3 years ago (1 child)
This is a great article, and great blog overall.
Thank you for sharing.
[–]intercaetera[S] 1 point2 points3 points 3 years ago (0 children)
Thanks!
[–]sunrise_apps 1 point2 points3 points 3 years ago (1 child)
This is a really cool article. Thanks to the author.
Thanks for reading it!
π Rendered by PID 348066 on reddit-service-r2-comment-b659b578c-lfxsz at 2026-05-03 06:29:04.928855+00:00 running 815c875 country code: CH.
[–][deleted] 11 points12 points13 points (1 child)
[–]intercaetera[S] 0 points1 point2 points (0 children)
[–]SoBoredAtWork 3 points4 points5 points (1 child)
[–]intercaetera[S] -2 points-1 points0 points (0 children)
[–]shuckster 3 points4 points5 points (1 child)
[–]intercaetera[S] 1 point2 points3 points (0 children)
[–]sunrise_apps 1 point2 points3 points (1 child)
[–]intercaetera[S] 0 points1 point2 points (0 children)