It's been a long time dream for me since about 2013 when I started getting deep into Ruby and Rails, to be able to write Ruby code for the frontend instead of JavaScript. I was a lover and adopter of CoffeeScript (which had it's flaws and imperfections), but that mostly got killed by ES6, and in truth ES7 and beyond made javascript a whole lot more tolerable so less need/motivation to use Ruby on frontend.
I wrote some PoCs with Opal[1] that felt pretty good to write, but the overhead was rough (this was many years ago so things might be different now) and I never really felt like I didn't have to know about or care about the underlying javascript. I tend to discard leaky abstractions as I feel they often add more complexity than they were meant to cover in the first place.
Has anybody used this or Opal or anything else? What is the state of "write your frontend in Ruby" nowadays?
Ruby.wasm is here now, so you can run ruby in the browser. It still a bit big, but it even supports many regular gems. I met up today with a friend who is working on much smaller mruby version. He'll be giving a talk at rubykaigi next month.
I use Ruby.wasm with my own patch. [1][2]
You can use the Javascript API and the syntax is a joy. I used it to make an electron app with videoplayer.[3]
I also ported the rubykoans[4]
I'm working on a framework inspired by React/Next.js which turns Haml into Ruby. It's 100% server side, but it runs pretty fast. I'm currently working on a rewrite, I just wish I had more time to work on it.
Both! I needed something like JSX, and I found Rux [1] but I had some issues with it, and then I found syntax_tree-haml [2] which gave me an AST that I could transform into Ruby. This is what the transformation looks like: https://gist.github.com/aalin/c0e4b0360a1f84d0283149fe4b2ce6...
I have always liked Haml because it's compact and easy to read.
I wrote some PoCs with Opal[1] that felt pretty good to write, but the overhead was rough (this was many years ago so things might be different now) and I never really felt like I didn't have to know about or care about the underlying javascript. I tend to discard leaky abstractions as I feel they often add more complexity than they were meant to cover in the first place.
Has anybody used this or Opal or anything else? What is the state of "write your frontend in Ruby" nowadays?
[1]: https://github.com/opal/opal