Live data from Hacker News

Rewriting the Ruby parser

railsatscale.com

31–40 of 182 posts

Re: Rewriting the Ruby parser

#31
post #14

I love how pragmatic the approach is here. We still don't have parser generators which generate human understandable/readable recursive descent parser with good error recovery baked in. But i am guessing the ruby syntax is too complicated/irregular anyway. On a macro side, i am always surprised with the length and effort company will go to keep working with solution design and selected at their young age, and try to…

Where is the “more bang for the engineering buck”?

JRuby. TruffleRuby.

Re: Rewriting the Ruby parser

#32

It feels to me like Shopify is single-handedly keeping Ruby alive. A little bit like Jane Street and O'Caml.

This is wholly irrelevant, but I love the spelling of O'Caml like an Irish last name. I'd definitely frequent a pub called O'Caml's.

Given the early logo for the language was Joe Camel, it would need a smoking room ...

Re: Rewriting the Ruby parser

#33
I think Ruby is a pretty good language and I spent many years using it professionally but I can't imagine having enough motivation to work on the language implementation when it's so difficult to even parse the code. The amount of engineering time spent on this topic is bonkers!

Re: Rewriting the Ruby parser

#34
Nice article! In this sentence

... open parenthesis character is ambiguous in this context. To get around it they made their grammar more ambiguous and then enforced that the actual grammar was enforced in their tree builder.

I'd change the second "more ambiguous" to "more lenient"

i.e. lenient meaning "grammar accepts more strings", ambiguous meaning "grammar is invalid"

I have seen this issue in Python's grammar as well, and it's mitigated by the new PEG parser

Re: Rewriting the Ruby parser

#35
post #34

Nice article! In this sentence ... open parenthesis character is ambiguous in this context. To get around it they made their grammar more ambiguous and then enforced that the actual grammar was enforced in their tree builder. I'd change the second "more ambiguous" to "more lenient" i.e. lenient meaning "grammar accepts more strings", ambiguous meaning "grammar is invalid" I have seen this issue in Python's grammar as…

Ambigious does not mean invalid

Re: Rewriting the Ruby parser

#36

Earlier quoted context omitted.

I don't know why, there are tons of smaller companies using it. I have a lot of languages and experience on my resume and the one that consistently gets me the most inquiries at the highest pay grades is still Ruby. Anecdotal I know, but from the moment that it appeared on my resume in 2012 it's been non-stop. Probably 80% of everything I hear about. Ruby and it's ecosystem brings the closest thing to natural Aspect…

i think if rails continues to push hotwire (turbo + stimulus, and perhaps strada?) and get a coherent story on view components, it will continue to take mindshare from the js hype of the last decade. mobile dev is in decline, and browser makers just released web notifications, web app support, webtransport, page transitions, etc., so the backend has largely reached parity for cross-platform development. no longer is…

I've been building a webapp with Rails on and off over weekends. Several times over this process, I thought through some of the architectural decisions and naturally realized that the "Rails way" was the best option to pursue. It's not just because I'm using Rails - my most recent webdev experience was with a SPA driven by a Java backend. I'm sure there are tradeoffs involved (what doesn't?) but with every passing day I use Rails the more I appreciate the decisions it makes for you.

Re: Rewriting the Ruby parser

#38
post #34

Nice article! In this sentence ... open parenthesis character is ambiguous in this context. To get around it they made their grammar more ambiguous and then enforced that the actual grammar was enforced in their tree builder. I'd change the second "more ambiguous" to "more lenient" i.e. lenient meaning "grammar accepts more strings", ambiguous meaning "grammar is invalid" I have seen this issue in Python's grammar as…

Ambigious does not mean invalid

Yes, technically it means "there's more than one derivation"

But Python's pgen rejects such grammars as invalid ... The other strategy is just to pick an arbitrary interpretation

Re: Rewriting the Ruby parser

#39
With the mention of the parser's performance, I am reminded of Rich Kilmer's 2004 RubyConf presentation. Rich used Ruby to test reliability of a distributed system with hundreds of Java VMs. Some of the serialized data was stored as XML (over 1M lines!), which was slow to parse and load. Rich modified the program to serialize the data as Ruby code, which loaded much faster (https://www.infoq.com/news/2007/06/infoq-interview-rich-kilm...):

> Chad Fowler and I over basically 2 weeks, took the Java Debug Wire Protocol specification [...] turned it into a DSL in Ruby, and used that DSL to generate the packets for sending and receiving data. So we used the DSL in Ruby as a generator to generate Ruby code, as the whole protocol and then I used that at Darpa. They were trying to say “we could freeze the agent society from within the agent society will send messages, and it took about 7-8 minutes for all the messages to propagate and everything to freeze and then go quiet. I had a Ruby process that was running all 300 VM’s were underneath it, and I could freeze it in about a half of second. All 300 of them! And you actually could watch the CPU use because we had a monitor and the CPU use has dropped to zero. And it freaked them out. And what was great was you could turn it back on, and all the agents came back on. But time had been lost. And it was like alien abduction lost time, ten minutes went away, “what happened to us?” It was a bizarre thing because they were agents and they were planning on things and all of sudden 10 minutes just went away. But it was interesting to show how Ruby could actually be used as this kind of harnesses to wrap around things like systems.

Re: Rewriting the Ruby parser

#40

It feels to me like Shopify is single-handedly keeping Ruby alive. A little bit like Jane Street and O'Caml.

I think ‘is Ruby dying?’ is little more than a meme that has stuck around for longer than it deserves.

The continuing work on the language and its performance is impressive, but Ruby (and Rails) themselves have the honour of being stable, tried-and-tested solutions for rapid application development. Is it as exciting as the latest and greatest serverless lambda framework in Typescript? Not really. Is it a dependable workhorse? Absolutely.

At some point you might be successful enough to justify a rewrite into something else, but a simple Rails app will take you a long way with little effort.

Post reply on HN