"Replacize" is one of a zillion ways to get the desired effect, but it does it well and with style, and I like it. More than that, it's the one thing in the script that gives it conceptual unity. If you highlight "replacize" in your browser and jump between the various occurrences, the structure of the program immediately leaps out.
This kind of terminological pidgin, unique to a given program, can be very helpful in making code clear without making it verbose. The trick is to make sure that each such term has exactly one well-defined meaning and that it's used consistently everywhere that it applies. Eric Evans has called this the "ubiquitous language" of a program. The current script is tiny, of course, but if I see a programmer taking that degree of care with their writing anywhere, it's a stroke in their favor.
The thing in there that makes my eyes water, if not bleed, is the unfortunate duplication between the async and sync versions of the logic. But that is hardly the script's fault. It would have to be rectified at the level of the language and/or platform; little can be done about it in a program like this. Error handling too.
I think the 'eyes bleeding'-type comments come from the author's rewriting sed in javascript. It seems almost like an exercise designed to provoke: rewriting one of the cornerstone nix utils (loved by many nerds everywhere) into a node.js package (despised by many nerds everywhere).
Like any good conversation starter, replace.js comes with a bit of incorrect information:
It's similar to sed but there are a few differences:
1. Modifies files when matches are found
Easy enough to do with sed: -i
2. Recursive search on directories with -r
find . -exec sed [...] does the same.
--
In my estimation, that's the reason for the vitriol. I am intentionally leaving out any analysis on the morality of the reactions to it, but the above should explain why some reactions were less than great. It wasn't about the code itself.
But also hated by some nerds. I don't like to bring up my critiques of unix, because people seem conditioned to love it and couldn't do much about it anyway. People ignore (or get defensive about) things they feel they can't change.
But there's lots of Unix-Haters out there. Kinda like Fight Club, except slightly more gender-inclusive. "Remember this. The people you're trying to dismiss, we're everyone you depend on. We're the people who write your embedded devices which cook your food. We make your toy Scheme implementations. We're monitoring your systems while you're asleep. Our systems route the ambulances. Our Erlang processes direct your call. We are Googlers and Facebook coders and we know everything about you. We process your insurance claims and credit card charges. We control every part of your life. So don't condescendingly quote man pages at us." (http://homes.cs.washington.edu/~weise/unix-haters.html)
The reason these people were sneering was because the code was written in Javascript, running on Node.js, and Node.js is perceived to be a threat to their own community, Ruby on Rails. They mock and belittle what they fear so they can feel better.
Thought provoking or not, but I think rewriting the nix-utils with your language-of-choise is one of the best opportunity to learn :) Learn more about your language and learn how damn much effort has gone into the nix-utils to get them where they are today.
But does that make the author a bad person? Worthy of ridicule for having thrown it online? Of course not. This is just a silly script, of the variety that most of us probably have sitting around in somewhere $HOME. It's not worth getting worked up over.
The ultimate irony is, I wonder how the critics would feel about the code of sed and grep. Have they bothered to look? I myself do have these loud, exaggerated, critical attitudes towards code quality, but at some point I realized that most of the code I rely on every day is probably not up to my standards, and yet I still willingly rely on it. A younger self might have been tempted to re-write all of it, but I only have one lifetime to do such things and I'm already busy as it is. There is a time for rewrites on the basis of code quality, I would advocate for it where it is constructive or even simply satisfying, but at some point you have to admit that many (most?) times you will have to pass on this impulse.
I have some very silly scripts hanging around. "killname.sh" dates from before I knew 'pkill' was a thing :)
To echo the larger point, I've written a bunch of similar scripts in my lifetime.
I remember the one weird thing was that `killall` used to behave weirdly on commercial Unix. It would ignore its arguments and simply attempt to kill all processes. It's been a long time since I've logged into such a system, but it was then that I got used to typing `pkill`.
Don't lump JS into this.
Out of all the code could say "eyes bleeding" that doesn't even come close? Only thing that stands out is the naming of "replacize".
I can understand if you hate JavaScript syntax and love sed, but I fail to see why anyone would pick on this out of all the other code out there. There's no shortage of crappy code in the world! (not that you should make fun of any of it on twitter)