Question

Would it be possible to design a statically typed JIT'ed language to build a web framework like Ruby on Rails, an attempt to gain the speed of a statically typed language?

Embedded Ruby (eRuby) in html is a feature of Ruby on Rails that I don't see an obvious way to implement in a statically typed JIT'ed or compiled language.

I am not familiar with the internals of the implementation of Ruby on Rails, but more generally are there other features of Ruby on Rails that would be very difficult to implement in a statically typed JIT'ed or compiled language?

Was it helpful?

Solution

Sure. It wouldn't necessarily achieve what you want (dynamic typing is just one of many things which make optimizations harder, the "fast" languages you know make many tradeoffs beside static typing to achieve that performance), but it's perfectly possible. In fact, it's being done. ASP.NET MVC has had the Razor view engine for quite a while now, which features a statically typed template language. The few restrictions compared to C#/VB.NET (e.g. I don't think you can declare classes) are design decisions, not technical issues. Basically, all you need to do it parse the template, separate (e.g.) HTML from code, and generate code which outputs the strings that should be output according to the template.

Now, Ruby on Rails specifically is heavily using the dynamic features of Ruby. While many "statically typed" languages do feature reflection which may achieve something similar (though much more verbose), and other metaprogramming constructs can be typed just fine, I doubt you could simply port RoR to a run of the mill statically typed language, especially if you want the end result to be anywhere as convenient. It's probably better to create a new framework, inspired by existing ones. And that has already been done. A thousand times. Per language.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top