Hacker News new | past | comments | ask | show | jobs | submit login

Which standard function in Ruby is a single letter?



b, to_s, to_i, to_a, to_c, to_h, to_r, etc.

Should have said methods but you get what I mean. And I've encountered ambiguous and pointless abbreviations all over the place.


It's weird, when I was I younger I used to love shortform syntax like that as well as removing unnecessary punctuation

But now that I'm older, I appreciate things being more descriptive and orderly, including strict use of semicolons, functions that say what they are doing (e.g. to_string), or being explicit about converting (e.g. static_cast<type>)

I think it's because I find trying to make everything as succinct as possible ends up trying to be too clever.


When I was younger I tended to write more code than I read. As I got older I transitioned to reading more code than I wrote. This correlated with a desire toward a preference for code that self documents as I progressed.


I type fast enough that somewhat longer names don't hurt. Also tab completion has existed both in IDEs and in shells for many years now. But just like very nearly everyone else I fall into the "7 ± 2 items in working memory at once" capability range. Having to remember what a command/function/syntax element does instead of reading a word that says what it does takes away from that working memory.

Long-term memory is similar, while it's not bounded in the same way it takes time and effort to develop. I'd rather type `git new-branch` than have to remember `git checkout -b` and I certainly don't alias it to `git nb` or something: I can type `git n<TAB>` and let that complete it.


Well said. "Clean Code" goes into this a lot and it helped me realize why I was starting to become more and more bothered by looking back at the short variable names I wrote years ago on my projects.


When I was first learning java I loathed the verbosity, but I was coding everything in vi. Now days with good ides, I don't mind java's verbosity or even the boiler plate.

I find myself more annoyed by dynamic languages, because the tooling just isn't at the same level. All sorts of 'hints' that I rely on in java simply aren't there in other languages, and the ide throws up it's hands and is like '...? I guess this is right? Godspeed sir', and I wind up having to go lookup documentation rather than ctrl clicking into underlying functions and code. It's really annoying, and it's made me be more appreciative of staticly typed languages.


Interesting, I’d never seen or used .b or .p that someone else mentioned. I agree those definitely should not be a part of the standard library. Not sure about to_i etc. we use those pretty often and it’s never really been an issue.


p




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: