5 ms·
Haven't used ruby in years for the typical reasons people move away from it (performance, strong types, GVL, etc.) but syntax is #1 reason I like programming in
by rudolph9 6y ago
Haven't used ruby in years for the typical reasons people move away from it (performance, strong types, GVL, etc.) but syntax is #1 reason I like programming in Ruby. I did mostly ruby for about 5 years and really grew to love it! It may seem bonkers at first but quite enjoyable once you understand it. Now nearly 4 years later of mostly javascript, golang, python, haskell I still regularly stop and think to my self how much I miss ruby!
- regularfry 6y agoAs an end user, it's amazing. I do have sympathy for the implementers, though.
- hrktb 6y agoI read parent’s “bonkers” in a positive way. Then for instance most languages get away with inline optional typing by using “:” , for instance “ping_user(name: String)“. In ruby it’s of course already taken, in no small part because there are 3 or 4 different ways to declare hash parameters. I’d imagine most decent syntax candidates had similar issues, due to ruby’s syntax versatility.
- Polylactic_acid 6y agoThe worst part of ruby imo is the fact that a hash can have both string and symbol keys. Countless times I have encountered issues where a function takes an options hash and the callers use both string and symbols for the same key depending on which caller it is. I end up calling the function to convert to symbols all the time.
- rudolph9 6y agoActually, if my memory serves me, a ruby hash can use any object a key! And considering everything in ruby is an object (even the class `Object`) it’s really quite elegant
- vlunkr 6y agoThis seems to be getting downvotes? I don't know why, it's accurate. Anything can be a key in Ruby.
- tdeck 6y agoThis is why ActiveSupport (Rails) has Hash#with_indifferent_access and people use it all over the place.
- Glyptodon 6y agoI'm trying to think of any typical chars that don't already mean something and I think at best you'd have to use a pair and even then it would potentially break older code. Very badly offhand something like: `attr_accessor ~:String :name` and `def sing(~:Song song):` seems pretty ugly but borderline feasible on the premise that while ~ and : have meaning in Ruby, it's not super likely that bitwise inverting symbols is common. (I'm sure there more reasons that wouldn't work or isn't great.) I don't like the separate file thing, but it does seem more challenging than I'd have thought to avoid. I guess on a tangent Ruby code historically cares a lot more for duck typing so strong typing will be a headache for a lot of stuff.
- regularfry 6y agoI genuinely think that adding `:` as a hash separator was a mistake. Apart from anything else, you get this weird effect where the type of the key in `{"foo": bar}` isn't what you think it is.
- chillfox 6y agoCrystal [1] is a pretty nice ruby like language with types and it is up there with Go/Rust for runtime performance. [1] https://crystal-lang.org/ https://crystal-lang.org/
- nurettin 6y agoCrystal is nice since they added a decent concurrency model, but it doesn't support one of the major platforms (windows)
- pjmlp 6y agoSame applies to Swift (even worse than Linux) and Go (e.g. plugins package). So while I agree with you, I still look forward to see support for Windows eventually landing.
- Can_Not 6y agoDidn't ruby historically have poor support for windows? Everything great has to start small either eay.
- nurettin 6y agoYeah no, you can say this against literally every criticism and be right unless someone comes up with time spans and user experiences of other great things to disprove it. Ruby was great on windows since 1.8, don't know how it was before that. I recently scripted AIX with it, so not really a contender on the same lane.