Live data from Hacker News

Ruby 2.7

ruby-lang.org

31–40 of 68 posts

Re: Ruby 2.7

#31
post #26

One of the interesting news is that they are now going to start requiring a C99 compiler, instead of only C90. I've been considering to do the same on my own projects. What does HN have to say about this? Is anyone here still working in a context where C99 is not an option? Did anyone else also recently switch to C99? How did it go?

The only modern problem with switching to C99 is Visual Studio on Windows. You have 2 sensible choices:

1) Use clang to build on Windows.

2) Use the subset of C99 which is implemented in Visual Studio (which also requires compiling as C++, which isn't that difficult to handle).

Re: Ruby 2.7

#32
post #28

Pattern matching is awesome in Elixir, it's great to see functional language traits stain the Ruby language more. It's all the better for it.

Basically this is Elixir's case, so a very narrow instance of what Elixir's pattern matching is. I'd love to see more pattern matching added to Ruby year after year. However adding everything Elixir has probably would require a total rework of the language. Example: multiple method definitions, one per pattern. I wonder what's going to be the idiomatic way to handle a failed match. Elixir ends the process but there i…

There seem to be plans to extend this to destructuring assignment/bind, that would be a ton more useful and interesting imo.

Re: Ruby 2.7

#33
The compaction GC was the most important change. I haven't measured Ruby's performance specifically but in general the difference and improvements over a non-compacting GC is so huge. Specially for long running processes.

Re: Ruby 2.7

#34
post #9

Earlier quoted context omitted.

>The idea is that you use it sort of like a collection in most cases Sort of like a monad, even! Honestly if you're running into problems like that though you should probably be using Either instead of Maybe like GP suggested. In my opinion, most of the benefit is still derived from strong static type checking, because otherwise you basically have to trust that callers respect your contract with these types. Perhaps…

> Sort of like a monad, even! Yes that's it - they're monads! Either is also a monad, and you can store error information in the other side if you want, but a good thing about Maybe is it could transparently store the error information, and produce it when debugging, rather than baking it into the normal runtime semantics. > you basically have to trust that callers respect your contract with these types This is table…

Yes I’m aware they’re monads, my primary languages are OCaml and Haskell. I don’t understand what you’re suggesting with Maybe, that sounds like maybe adding some layer of magic onto it?

> Yes people can do anything, but usually they follow the rules they're given.

Sure, but the primary advantage remains in not having to trust that, not having to write tests for it, and communicating the contract itself inside the code it restricts. I’m just honestly not sure what purpose they serve here, and why you’d bother to call them monads when what you really seem to want is the stored debugging information.

Re: Ruby 2.7

#35
post #26

One of the interesting news is that they are now going to start requiring a C99 compiler, instead of only C90. I've been considering to do the same on my own projects. What does HN have to say about this? Is anyone here still working in a context where C99 is not an option? Did anyone else also recently switch to C99? How did it go?

Why? Not being facetious. Wondering about the weights of benefits versus costs for users.

Mostly portable implementations of extensions for me; __thread, bool, inttypes.h, variadic macros, flexible array members etc. But declaring variables closer to the point of use is nice, as is struct initializers, compound literals and single line comments.

Compared to the rest, C99 contains a lot of useful improvements.

Re: Ruby 2.7

#36
post #25

Pattern matching is awesome in Elixir, it's great to see functional language traits stain the Ruby language more. It's all the better for it.

I was introduced to it in Scala. I like how all "classic" languages are cherry-picking features from functional programming. It will make people less shell-shocked in the future, when they try it for real.

Yup, Scala, F#/OCaml and Rust have the best pattern matching implementations I've seen. I'm happy to see other languages slowly coming around. Java has a JEP for it (although nowhere near as nice as Scala's). Even JavaScript has a TC-39 proposal, although its champion has gone on to focus more on Rust. I'm excited for the future.

Re: Ruby 2.7

#37
post #34

Earlier quoted context omitted.

> Sort of like a monad, even! Yes that's it - they're monads! Either is also a monad, and you can store error information in the other side if you want, but a good thing about Maybe is it could transparently store the error information, and produce it when debugging, rather than baking it into the normal runtime semantics. > you basically have to trust that callers respect your contract with these types This is table…

Yes I’m aware they’re monads, my primary languages are OCaml and Haskell. I don’t understand what you’re suggesting with Maybe, that sounds like maybe adding some layer of magic onto it? > Yes people can do anything, but usually they follow the rules they're given. Sure, but the primary advantage remains in not having to trust that, not having to write tests for it, and communicating the contract itself inside the co…

> I don’t understand what you’re suggesting with Maybe

I’m suggesting adding a trace of where a None value is created and propagated, for debugging purposes.

> the primary advantage remains in not having to trust that, not having to write tests for it

Is that the primary advantage? I’m not as sure as you seem to be.

And of course there’s one huge part of monads that you have to take on trust even in Haskell isn’t there? The monad laws! No type system is enforcing those. If you’re comfortable trusting someone else is following that rule why is trusting they follow another so alien?

But if you don’t like the idea don’t worry I’m not going to come round to your house and force you!

Re: Ruby 2.7

#38
post #26

One of the interesting news is that they are now going to start requiring a C99 compiler, instead of only C90. I've been considering to do the same on my own projects. What does HN have to say about this? Is anyone here still working in a context where C99 is not an option? Did anyone else also recently switch to C99? How did it go?

Why? Not being facetious. Wondering about the weights of benefits versus costs for users.

The only real cost is that Windows users will have a slightly less convenient time, which doesn't matter for most projects.

Re: Ruby 2.7

#39

Earlier quoted context omitted.

Pop an item from an array. What do you return when the array is empty? Solution: nil. Problem: How do you tell the difference between "the array was empty" and "the item you popped was nil"? Solution: have pop return a Maybe instead.

or allow returning multiple values. for example in CL searching for a thing returns two values the is-found and the value

...which, btw, is equivalent to Maybe/Either – they're tagged unions, i.e. pairs (tag, content). Maybe is isomorphic* to

  { has_value: bool,
    val: T|nil }
* well, this representation is a bit too permissive, since you could do

  {has_value: true, val: nil} 
if you wanted to get the types water-tight, you'd need dependent types, typing it as dependent pair:

  Maybe =
    sigma (has_value: bool)
      if has_value
        then T
        else ()
which can then only have values

  (false, ())
or

  (true, )

Re: Ruby 2.7

#40
post #33

The compaction GC was the most important change. I haven't measured Ruby's performance specifically but in general the difference and improvements over a non-compacting GC is so huge. Specially for long running processes.

>over a non-compacting GC is so huge

Yes in other languages, but as far as I am aware that is not the case in Ruby ( Specific to Rails ) . At least I wouldn't use so huge to describe the improvement.

Post reply on HN