Hacker News new | ask | show | jobs
by TheDong 3736 days ago
Critique:

1) no LICENSE file

2) not configurable

3) not idiomatic ruby (e.g. camelCase not snake_case)

4) overtly complicated. A better, and shorter version, is:

    bad_whitespace = " "
    ARGF.inplace_mode = ""
    ARGF.each_line do |line|
      print line.gsub(" ", bad_whitespace)
    end
5) bad commenting. The style of commenting each line for what it does is often silly. Something like "fileModified.close # Close file" tells me exactly nothing more than reading the code. Having "noisy" comments makes important comments less obvious, and thus actually makes the overall commenting worse.

This is a sign of a college coder who had some class where the teacher said "you're required to have at least this much commenting", or a beginner programmer.

And finally, this is obviously a dumb toy program.

This isn't useful to show-hn. This isn't anything novel, or even interesting. It's not hard to do. It's poorly implemented and not portable (really, why require the user to edit the filename? ARGF exists for a reason).

This was also submitted by a new hn account mere hours after it was created (clearly by the author). I have no problem with showing off your own work, but at least let it cool down to see if it's a good idea; see that other people think it's interesting or useful in its own right.

I consider presenting an essentially 5-line program that is not generally useable or insightful as being basically spam.

I do recommend keeping on programming and, once you've got a project you're proud of that has seen some use besides yourself, seen at least one other happy user, and relates to HN's interests, post away!

2 comments

If he's a beginner your comment might be a bit harsh.

If it's not interesting to you don't upvote the post but saying it's "dumb" and "ARGF exists for a reason" is just being rude.

Out of curiosity (haven't done ruby for awhile): is your line-by-line implementation safe? Is it guaranteed that the lines are identical in the output file besides the character you're replacing? I'm thinking different CR+LR combinations. What if the final line is not terminated by newline? Doesn't print always add it?
You're thinking of 'puts' which appends a newline.

'print' does not

The code does handle/preserve all the cases you mentioned (\r\n, final or no final terminating newline, etc).