Earlier quoted context omitted.
Can you comment on why a good type system became so important to you? I can understand the value in interfaces but not really in any other context.
Languages without ADTs and Optionals just feel impoverished.
Ruby 2.6
111–120 of 164 posts
Re: Ruby 2.6
#112Earlier quoted context omitted.
Can you recommend a post/article explaining some of what makes Ruby's collections especially pleasant? Studying Ruby's stdlib design has been on my 'someday' list, but there's so much else there...
It's mostly how complete the API is and how consistent. For example: * Hash#merge takes a block for conflict resolution. I use this all the time for aggregating counts. * #sample * #unique * Everything has a change in place option by appending "!"
Re: Ruby 2.6
#113I am always happy to unwrap my Christmas present from the Ruby team! Some questions about this release: - Are there any benchmarks for the new JIT? - Why was `(Date.today..(Date.today + 1)) === DateTime.now #=> true` false in Ruby 2.5? It seems correct that right now is between today and tomorrow. Is it because one is a Date and the other a DateTime?
> (Date.today..(Date.today + 1)) === DateTime.now #=> true It took me a minute to parse this. (I have never had this problem with Python or JS.)
case DateTime.now
when Date.today..(Date.today + 1)
.. do something
else
.. or not
endRe: Ruby 2.6
#114Earlier quoted context omitted.
In most real world applications, the cost of doing an in-memory data manipulation like this is negligible compared to I/O, waiting for the database etc. It's already the wrong language for someone who wants to squeeze out every CPU cycle, and imo it's a Good Thing for a language upgrade to embrace its strengths ie syntax sugar in the case of Ruby, as long as the perf hit isn't out of control. I'd agree developers sho…
I might be more receptive to this if this was added to all collections, then, rather than just arrays. (Maybe it was? I don’t write Ruby, so I don’t know for sure. Maybe Ruby doesn’t have a generic “collection” protocol?)
Re: Ruby 2.6
#115What is the complexity of set operations on arrays? This seems a bit too much sugar to me, to the point where people will end up writing inefficient code because they will thing these methods are more performant than they really are. Usually, I like to see explicit conversions to sets to make the performance characteristics explicit.
Re: Ruby 2.6
#116This will be fun. I’m glad we now have some performance improvements to some common methods. For those considering playing with Ruby, you should! One thing I’m surprised not many has mentioned what makes ruby unique and awesome, BLOCKS!
Aren't they like arrow functions in JavaScript?
Similarly, Ruby has nice blocks, and many other languages have similar closure support. But Ruby's support is so built-in from day 1 and heavily used in the standard library and the general culture of Ruby gems. Many of the methods in Enumerable take blocks, making it easy to chain a bunch of functional stuff together, even without any support gems and from the earliest days of Ruby.
Re: Ruby 2.6
#117Ruby used to be my most beloved language. I've since developed a strong appreciation for good type system. However, working with collections of any kind in Ruby is just such a joy. The methods around it are so well thought throug and make writing code a joy that in most other languages just would be tedious. On top of that the Ruby team is constantly working on making that aspect even better. I truly don't understand…
Re: Ruby 2.6
#118Earlier quoted context omitted.
Clojure's stdlib is unintuitive, and `into` is the poster child. It's easy to find what's available in Ruby: https://ruby-doc.org/core-2.5.3/Enumerable.html Good luck with Clojure: https://clojure.github.io/clojure/clojure.core-api.html
https://re-find.it ?
Re: Ruby 2.6
#119Earlier quoted context omitted.
Negative indices aren't magic. They follow the obvious wraparound (modular) pattern: Negative `i` indexes the element in array `a` located at `i % len(a)`. If they worked any other way it'd be madness.
I don't think you got that index calculation right. -1 in array of 5 elements is located at 5-1 == 4, not at 1%5 == 1.
Re: Ruby 2.6
#120Earlier quoted context omitted.
To be fair, I find the destructuring syntax strange in Ruby. For example, why do I need the splat on the list? It doesn't make sense to me. I'm sure there is a good reason buried in the implementation, but if I were to design the syntax, I don't think I would do it that way.
> For example, why do I need the splat on the list? You don't on the RHS, or rather, it's redundant in the given example. On the LHS you need it to prevent single element capture.. and within the ruby language, it's a fairly consistent sigil.