Ruby 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…
Groovy. Probably because Groovy borrowed quite a lot from Ruby.
Ruby 2.6
121–130 of 164 posts
Re: Ruby 2.6
#122Earlier quoted context omitted.
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.
I don't follow your point. We're concerned with the value of -1 % 5, not 1 % 5. There's no definition of the modulus operator on which -1 % 5 = 1.
Re: Ruby 2.6
#123Ruby 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…
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.
It's a lot easier for me to reason about and avoid edge cases when I can (more or less) verify at compile time that invalid states are impossible.
This is about more than just catching null values, and also encompasses things like mutually exclusive fields, and access control.
If you're interested, I gave a talk once that dives into these ideas more effectively than I can express in this comment: https://github.com/ShaneWilton/programming-with-types-talk/b...
Re: Ruby 2.6
#124Earlier quoted context omitted.
> CPU intensive ones Truffle Ruby ? https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
From the Truffle readme: > TruffleRuby is progressing fast but is currently probably not ready for you to try running your full Ruby application on. However it is ready for experimentation and curious end-users to try on their gems and smaller applications. > TruffleRuby runs Rails, and passes the majority of the Rails test suite. But it is missing support for Nokogiri and ActiveRecord database drivers which makes it…
Do we think that's what `jb3689` meant by CPU intensive.
Re: Ruby 2.6
#125This 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?
Re: Ruby 2.6
#126This 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!
Re: Ruby 2.6
#127Earlier quoted context omitted.
Aren't they like arrow functions in JavaScript?
Just parameters that are functions, except that you can only have one per function. I still fail to see the advantage of blocks over being able to pass functions as arguments like in other languages.
def find(x, l)
l.each do |y|
return y if y == x
end
end
Where in Lisp you'd use (return-from find x) and in other languages you might pass in a continuation or use a special return value protocol. It's a nice solution for higher order functions that are supposed to feel more language-level.Also, you can pass functions as arguments like in other languages; lambdas behave like you would expect them to.
Re: Ruby 2.6
#128Earlier quoted context omitted.
https://re-find.it ?
I'm talking about the flat namespace.
Re: Ruby 2.6
#129Earlier quoted context omitted.
Try Crystal and you get the joy of Ruby enumerables together with a static type system.
Crystal is definitely not production ready, I mean a language without thread support...
Re: Ruby 2.6
#130Earlier quoted context omitted.
I'm not sure about this being good for coding in non-latin. It might actually encourage behavior to mistreat ruby constants as regular variables. IIRC constants are not really constant, but only visual help for reading code and ruby just issues a warning on reassignment and these warnings are not shown by default. I can totally imagine new devs just trying out non-ascii variables, see it not crashing and then actuall…
> I can totally imagine new devs just trying out non-ascii variables, see it not crashing and then actually writing all their code using constants. Ruby already supported non-ascii identifiers for variables; 2.6 added support for non-ascii first characters of constants, which must still be capital letters, as had always distinguished constants from variables. It doesn't make anything non-ascii a constant, it just mak…