Live data from Hacker News

Ruby 2.6

anamaria.martinezgomez.name

91–100 of 164 posts

Re: Ruby 2.6

#91

> Constant names can now start with non-ASCII capital letters. I am not sure how useful this is Very? If you want to code in non-Latin languages. Also, π = 3.14159

Looks like an ‘n’ at first glance. Just as easy to type “pi”.

Re: Ruby 2.6

#92

Earlier quoted context omitted.

How do you check your code? Presumably, you’re not able to exercise the full range of inputs, so at some point you will have to look at the code and figure out what it is doing…

Which means you'd notice the value of a constant being exfiltrated, since a maliciously named constant doesn't magically expose secrets outside of the application.

I suggest you take a look at some of the submissions in e.g. the Underhanded C Contest. Where it can be excruciatingly hard to figure out where the backdoor is even though you know that the code has one.

Re: Ruby 2.6

#93
post #21

> Constant names can now start with non-ASCII capital letters. I am not sure how useful this is Very? If you want to code in non-Latin languages. Also, π = 3.14159

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 makes constants consistent with other identifiers in terms of non-ascii support, while preserving the “initial capital means constant" rule.

And, as sibling comments note, reassigning a constant produces a warning, so devs making a mistake and using constants for variables (regardless of ascii-ness) will quickly be informed of their error.

Re: Ruby 2.6

#94
post #33
post #26

Really like the idea of using lazy ranges instead of magic negative indices! I.e `xs[6..]` instead of `xs[6..-1]`.

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

#95

Earlier quoted context omitted.

As good as any time. You will loose a lot of performance when compared to v8 but the ruby paradigm is subjectively much more pleasant to work with.

Enumerable methods are almos always what make me want to ditch Javascript for Ruby.

ES6 has map, filter, reduce, etc... and anonymous functions which can be used in lieu of Ruby blocks.

Re: Ruby 2.6

#96

Earlier quoted context omitted.

head, *tail = *list Has worked since 1.8. Don't ask me how I know that :-P

Damn, I should have remembered that. Especially considering I had a project where I had to trawl through the ruby parser including multiple assignment rules.

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.

Re: Ruby 2.6

#97
post #81
post #42

This 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?

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.

Re: Ruby 2.6

#98

Earlier quoted context omitted.

Damn, I should have remembered that. Especially considering I had a project where I had to trawl through the ruby parser including multiple assignment rules.

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.

Re: Ruby 2.6

#99

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…

The only collection I wish Ruby improved upon is a simple Lisp style linked list. Kind of amazed JS has an easier way to do cdr than Ruby: const list = [ 1, 3, 4, 2, 8, 5]; const [fst, ...snd] = list; But I suppose that's just a result of JS implementing pseudo-pattern matching.

There's always Elixir :)

Re: Ruby 2.6

#100

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…

Try Kotlin and its collections.

I used to love Ruby too but the dynamic typing quickly became a deal breaker. So I set out to find a language that's as pleasant to use on a daily basis, with well designed libraries and collections, but also statically typed.

Kotlin met all these requirements for me.

Post reply on HN