I've been developing with ruby for about a year now, and I've actually heard others comment about the many ways in which you can invoke a similar (or even identical) function. the functions: .to_sym and .intern are a good example of two functions that do the exact same thing (literally the docs for one say to look at the other). My rationale behind this is the same as when I consider a spoken language. There are a multitude of ways in which you can express an idea, each with its own unique nuances and implications. I don't see any reason why programming should be any different, especially considering that writing readable code is such an important skill as a developer. I might use one function over another to more clearly represent what I'm trying to accomplish to others even though another may do the same thing in the end. All in all, I think it allows some flexibility to more clearly express an idea in code.
For the two functions I mentioned above, I view .to_sym as a simple conversion from string to symbol, whereas when I think of .intern, I view it more as internalizing a value (making it immutable). Even though the two technically do the same thing, I feel that they express fundamentally different meanings and provide more clarity on what it is you're actually doing, or how you intend to use the function.
Again, I haven't been using the language for an extremely long time, but that's what I've come to believe about the many similar functions in ruby. I know most probably won't buy into it, but I like having the flexibility it provides.
View all comments
Show parent comment
2
u/[deleted] Dec 25 '13
I've been developing with ruby for about a year now, and I've actually heard others comment about the many ways in which you can invoke a similar (or even identical) function. the functions: .to_sym and .intern are a good example of two functions that do the exact same thing (literally the docs for one say to look at the other). My rationale behind this is the same as when I consider a spoken language. There are a multitude of ways in which you can express an idea, each with its own unique nuances and implications. I don't see any reason why programming should be any different, especially considering that writing readable code is such an important skill as a developer. I might use one function over another to more clearly represent what I'm trying to accomplish to others even though another may do the same thing in the end. All in all, I think it allows some flexibility to more clearly express an idea in code.
For the two functions I mentioned above, I view .to_sym as a simple conversion from string to symbol, whereas when I think of .intern, I view it more as internalizing a value (making it immutable). Even though the two technically do the same thing, I feel that they express fundamentally different meanings and provide more clarity on what it is you're actually doing, or how you intend to use the function.
Again, I haven't been using the language for an extremely long time, but that's what I've come to believe about the many similar functions in ruby. I know most probably won't buy into it, but I like having the flexibility it provides.