Hacker News new | ask | show | jobs
by ativzzz 1195 days ago
So ruby has a JS transpiler - opal - https://opalrb.com/

I tried using it a little bit but the reality is if you need JS to make your app more interactable it's really worth it to just learn some JS. As soon as you need something complex the extra layer of abstraction just gets in the way and becomes more of a headache, and if you don't need anything complex then you don't need a fancy JS solution in the first place.

JS only becomes complex when you are trying to create an enterprise version of your app along with a build platform. You can always just sprinkle in <script> tags in your HTML for simple one liners without getting into the weeds.

3 comments

You are assuming people use Opal because they don't want to learn JS. In reality it's that JS is a very messy language compared to ruby.

You can be a lot more productive if you avoid JS entirely.

Absolutely agreed, hence the many Python to JS transpilers out there.

https://transcrypt.org https://yourlabs.io/oss/ryzom#javascript https://github.com/am230/py2js

We get so much satisfaction out of writing JS in Python, it's worth all the IDEs in the world for us!

JS is a totally fine language. The entire browser ecosystem makes JS an incredible productive language for working on the web. You can disagree if you don't like the language personally but that doesn't change the fact JS gets the job done
"incredible productive language for working on the web"

You can disagree if you want but that doesn't change the fact that JS is a huge pain in the neck to get the job done with.

I'm working on https://github.com/mayu-live/framework which is 100% server side Ruby. It's kinda like React/Preact, but server side, and Ruby. No JavaScript required (it's not even supported).
That's pretty neat. In general I think stuff like this is cool and works pretty well as a starter kit for simple CRUD apps if you don't already know Rails + JS, but like I said in my OP, once your app gets more complex, you hire some UX designers and you try to make your app more interactive, not having easy JS access makes it hard to do interesting things.

So could be useful for small projects but I wouldn't pick a solution like this for projects I would want to grow larger

JS is complicated because the browser environment is complicated.

If it's going to be rendered by and live in a web browser it will either be complicated or limited in some way (like low code/no code tools).

That's not really true. It's complicated because the language is one of the worst to manage.
It's not really any worse than Python or Ruby, but you also get TypeScript which helps
I posit that it is both.

Dealing with interactivity in the browser is subtle, complex and full of edge cases. JavaScript is also a horrible, broken language that’s not really fit for purpose. We’ve collectively invested a lot of time and resources trying to improve the experience of working with it, but the point still stands.