5 ms·
I love Python and use it pretty much anywhere I can, especially as it's ubiquitous in scientific computing. Is there a good reason to switch to Ruby except to t
by mahathu 4y ago
I love Python and use it pretty much anywhere I can, especially as it's ubiquitous in scientific computing. Is there a good reason to switch to Ruby except to try something new?
- nixpulvis 4y agoI would claim that Ruby as a language is much nicer to use, however it has less support for data science and other things which Python is much more well known for. If you ported over some libraries, you might find you like Ruby more in the end.
- doix 4y agoMy biggest gripe with Ruby is how much syntax is optional and the "accepted" conventions by the community are to leave out a lot of optional syntax. The worst offender (in my opinion of course) is leaving out of empty parentheses on method calls. It makes it impossible to know if something is a property or a function. The argument is that it doesn't matter if it's a property or a function, but I feel like it makes it very difficult to reason about performance. If I know something is a function, I'll look at the function and see what the performance implications are. Where as if something is a property, I assume it's "free" to access. This doesn't hold when reading Ruby code, and I basically have to look up everything all the time. Just my opinion as someone that had to switch between python/ruby/perl to maintain tools written during different decades.
- nixpulvis 4y agoAlways use parens. That's my rule.
- floodedchip 4y agoWhat do you mean by “property or function”, though? There are no properties or functions in my view—only messages. object.message sends message to object, which object may or may respond to.
- dehrmann 4y agoIt's the same in Python. Methods just happen to be callable properties.
- ByteJockey 4y ago> but I feel like it makes it very difficult to reason about performance This seems like a form of premature optimization. I mean, you're not wrong technically, but if you were exceptionally performance concerned, you probably wouldn't be using ruby. If you're just regular performance concerned (i.e. you want to stop pathological behavior in the hot loop), you're really only concerned about 1-2% of your code. You wait until it's an issue, run a profiler over your code and optimize the couple of parts that are causing the issue.
- hvis 4y agoAll "properties" are functions too (methods, to be exact). There is no difference. `attr_accessor` is a macro which defines two methods.
- linuxftw 4y agoAs a non-ruby user, from my POV ruby is primarily related to webapps. While it's possible to use it for other types of software, nobody really does, except possibly people that already maintain large codebases of ruby webapps.