News for hackers. Stuff that matters.
Re:I'm sorry by chubot on Thursday January 24, 2013 @12:00AM (#5107488)
OK... I usually don't involve myself in drama, but I looked at the code: https://github.com/harthur/replace/blob/master/replace.js

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)

Re:I'm sorry by gruseom on Thursday January 24, 2013 @12:18AM (#5107566)
I must stick up for "replacize"! I think it's the very best thing in the script. Yes, "replace" is better English, but that would make "replaceFile" misleading — it's not the file that's being replaced at all, but regex matches within the file. To get clarity you'd need something like "replaceMatchesInFile", and that is quite a bit longer. Moreover, it's generic. When your program has a specific and unique technical concept, it's better to give that concept a specific and unique name and use that name consistently everywhere. (Best of all is when the name is lexically unique so you can grep it to obtain every single instance of the concept in your program. That property is so valuable that it deserves to have an essay written about it.) Generic English words are not always an advantage in code. As a program grows, they're likely to appear in more and more (unrelated) places, which makes them less and less valuable for conveying the program's key semantics.

"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.

Re:I'm sorry by Domenic_S on Thursday January 24, 2013 @12:30AM (#5107625)
I'm going to tread as carefully as I can into this hornet's nest; keep in mind I'm not defending anyone:

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.

Re:I'm sorry by calibraxis on Thursday January 24, 2013 @03:01AM (#5108283)
> rewriting one of the cornerstone nix utils (loved by many nerds everywhere)

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)

Re:I'm sorry by barrkel on Thursday January 24, 2013 @02:27AM (#5108180)
No, that's not enough for vitriol; there has to be an emotional drive. If this code was written for you, and you were offended by the over-engineering, then you might feel slighted for being ripped off. But that's not the case here.

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.

Re:I'm sorry by tlear on Thursday January 24, 2013 @03:56AM (#5108460)
The crazyness of it all is that comparing Node to RoR is like comparing C++ to Cocoa it is just nuts and I do not get why people get up all in arms about it. I like and use both.
Re:I'm sorry by s_husso on Thursday January 24, 2013 @07:51AM (#5109228)
> It seems almost like an exercise designed to provoke: rewriting one of the cornerstone nix utils

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.

Re:I'm sorry by kyro on Thursday January 24, 2013 @12:14AM (#5107546)
Because acting like a childish asshole is how you maintain your web presence in the startup world.
Re:I'm sorry by asveikau on Thursday January 24, 2013 @01:30AM (#5107952)
Hmm, reading it I think I see where criticism comes from; my impression is that I, personally, will most likely stick to sed, grep, sh, etc.

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.

Re:I'm sorry by Nursie on Thursday January 24, 2013 @09:44AM (#5109707)
This is just a silly script, of the variety that most of us probably have sitting around in somewhere $HOME

I have some very silly scripts hanging around. "killname.sh" dates from before I knew 'pkill' was a thing :)

Re:I'm sorry by AlexandrB on Thursday January 24, 2013 @12:07PM (#5110629)
Thanks to this reply, I just learned that 'pkill' is a thing! I've generally relied on killall - though it's not available on some platforms AFAIK.

To echo the larger point, I've written a bunch of similar scripts in my lifetime.

Re:I'm sorry by asveikau on Thursday January 24, 2013 @02:46PM (#5111722)
For a long time OS X didn't have `pkill`. I think it's there now with 10.8, but was missing for too many years.

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`.

Re:I'm sorry by dmix on Thursday January 24, 2013 @12:07AM (#5107523)
This may have to do with rubyist who have a distaste for Node (and Javascript) in general (which is actually quite common) more than the JS itself.
Re:I'm sorry by codewright on Thursday January 24, 2013 @12:24AM (#5107589)
I'm a Pythonista that loves JavaScript and thinks Node.js is a waste of effort on the part of humanity.
Re:I'm sorry by scriptproof on Thursday January 24, 2013 @03:07AM (#5108302)
I fear that few programmers understand the perspectives brought by Node and JS.
Re:I'm sorry by codewright on Thursday January 24, 2013 @10:54PM (#5113852)
Node.js didn't bring anything new to the table. We've had event loops and non-blocking code for almost half a century.

Don't lump JS into this.

Re:I'm sorry by jmspring on Thursday January 24, 2013 @01:34AM (#5107977)
I'm mostly ambivalent. Node, to me, feels like an attempt to bring twisted to server side JS.
Re:I'm sorry by fourstar on Thursday January 24, 2013 @02:38AM (#5108216)
How much have you used it?
Re:I'm sorry by nkohari on Thursday January 24, 2013 @05:49PM (#5112779)
Hyperbolic much?
Re:I'm sorry by bodegajed on Thursday January 24, 2013 @12:52AM (#5107735)
That's an unfair presumption. That's just a coming from a few twitter users and it doesn't really represent the whole rubyist community.
Re:I'm sorry by GraemeLion on Thursday January 24, 2013 @08:59AM (#5109495)
I've found the whole rubyist community to be somewhat hateful towards any other languages. It makes it hard to want to use the language when the suggestions I get on my "gems" are "that's not ruby-enough of a name" or "You need to break out of your python mode, your name isn't clever enough" :P
Re:I'm sorry by askimto on Thursday January 24, 2013 @01:31AM (#5107954)
Looks reasonable to me.