Hacker News new | ask | show | jobs
by shaky-carrousel 1433 days ago
The ruby oneliner looks way cleaner and more natural than the python one.
1 comments

Would you ever use either in a real codebase though?
Well, yes. In fact it's the recommended style for simple conditions.
As opposed to a fake codebase? This sounds a bit like https://en.wikipedia.org/wiki/No_true_Scotsman.
As opposed to either a snippet in a REPL or a comment on hacker news.
The code is part of a standard, used-almost-everywhere library, `date`. Code in these libraries, from what I undersand, have a ton of thought behind them. It might follow that there were good real-life use-cases ready to use the code that influenced its presence in that library?

Also: https://github.com/search?l=Ruby&q=Date.today.saturday%3F&ty...

So the answer to the original question was simply “yes”.
No, not as opposed to a fake codebase. I think it's clear what they meant.

One incredibly common alternative to a codebase is a script.

Ok, I'll bite. I don't, I think it was a knee-jerk reaction post that didn't think things through for more than a couple seconds. I'm guilty of many of these, it's not the end of the world.

I know many "scripts" that have far more curation, history, and accumulated effort than any "codebase" sensu your post, I don't think this has any relevance to his question. Use is use. "Real" or "Fake" in terms of a standard library like "date" (see my other post) just isn't a useful dichotomy IMO.

I'm not a fan of gatekeeping either, but on HN the proper etiquette is to give the poster the best possible reading of their post.

I just interpreted their post as talking about bigger, organized projects, instead of small scripts.

I personally draw a distinction between "codebases" and most everything else. One of the key differences is "would I start a new git repo?"

"Real projects" get a repo for sure.

It's not too diminish smaller projects. Almost all of the most useful things I've ever built were very small. But when you can grok the whole script, and you're likely to be the only user..."codebase" isn't the word I'd bust out.

I'm sure you can think of many exceptions to this. Thinking of exceptions is a good quality for programmers.

I don't think the word "real" (codebase) was a very important modifier.