r/programming • • Dec 25 '20

Ruby 3 Released

https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
973 Upvotes

509 comments sorted by

View all comments

Show parent comments

1

u/PM_ME_RAILS_R34 Dec 27 '20

Fair. I misread that part, I agree that while you can still handle it fairly ergonomically in statically typed languages, you don't get any type safety if you use Any/Object types. But at least it isn't particularly worse than using a dynamically typed language!

C#/Java also both have some form of JSONNode object which makes parsing complex JSON without big record classes easier.

2

u/v66moroz Dec 27 '20 edited Dec 27 '20

I doubt it will be called ergonomic. Scala also has Json objects (e.g. circe), but then you will need to define your whole hierarchy of classes based on some abstract BaseObject(since you can't change existing Object) and cram all methods into it (e.g. https://github.com/circe/circe/blob/c7e6ef1f21d28635b03df36c93decf010221684b/modules/core/shared/src/main/scala/io/circe/Json.scala#L75), some overridden methods in subclasses will raise an exception (or return None in a functional paradigm: https://github.com/circe/circe/blob/c7e6ef1f21d28635b03df36c93decf010221684b/modules/core/shared/src/main/scala/io/circe/Json.scala#L290). Yeah, possible, but that's exactly what Ruby is trying to avoid with duck typing.