10 ms·
Show HN: Compile Ruby to C
- moonchild 6y agoFor practical use, how does this compare to crystal?
- d3nj4l 6y agoThose are probably not for the same use case. Crystal is a whole another language, and you'd have to migrate your whole codebase there. This (in my understanding) is more for compiling certain heavily used functions in your otherwise Ruby codebase to get a quick performance boost.
- ben-schaaf 6y agoDoesn't the new ruby JIT already do the same thing?
- d3nj4l 6y agoI haven't looked into the new ruby JIT too deeply, but as far as I remember it had several limitations that made it slow Rails apps down instead. This would make it easier to select and optimise for specific methods instead.
- sosodev 6y agoYeah, this is pretty much how the JIT works.
- sanxiyn 6y agoCurrent Ruby JIT doesn't take any type hint.
- agrafix 6y agoIt's certainly related -- not sure what kinds if specialisation the new ruby JIT does.
- d3nj4l 6y agoLooks great - but since you mention you're inspired by Sorbet, why not use their type annotations instead of rolling your own with Rubyspeed::T? (I don't know too much about C, so this might be obvious to some) Otherwise, I'm excited to try this out. I don't really have any performance-sensitive ruby personal projects, but with time and improvements pushing this to a production-ready state this could be a lifesaver in production for computationally heavy parts of a rails codebase.
- bfieidhbrjr 6y agoI'm sad Ruby has been, or is, left behind by python. There are lots of little reasons but no real big one. I just love ruby. I love little things like 'unless'. I know it's still with us, but still feels a little sad.
- satyanash 6y agoWhile I feel sad too, I think the primary reason why it imploded under its own weight was the "magic". I still love Ruby, for all its developer friendliness and the consistency of its idioms. But too much of that sugar leads to bloat, that requires a bunch of hair-pulling for newbies to grok. Now of course, there exist other simpler frameworks (a la sinatra), but when your posterchild is a thing like Rails, you can't expect people to not be burnt in the long term and still come back.
- cratermoon 6y agoRuby is a good little language, I used it quite a bit for time. Rails is a horror that I've run from whenever possible.
- eddietejeda 6y agoI recently started using Sinatra for side projects and it’s an absolute pleasure. It’s simple and reliable. I think it should get a lot more recognition.
- eddietejeda 6y agoRuby is changing. I doubt it will ever be as big as the Python world, but I can see it coming back into fashion. I’ve been paying attention to the community and it’s still very active.
- bdcravens 6y agoI think there's a lot of burnout in the JS ecosystem, and many are looking for the efficiency of Rails. However, I'm not certain if Ruby on its own is gaining more of a foothold. For a few years it looked like you'd seen more Ruby generalists with tools like Chef and Puppet, but I think Docker has taken a lot of wind out of those sails.
- blodkorv 6y agoReading this thread makes me feel like i have been transferred back to 2009-2010. Am enjoying the nostalgia quite a bit :)
- pjmlp 6y agoNice effort, but I think contributing to Crystal would be better spent.
- m12k 6y agoI maintain a 4 year old rails code base. I'm not going to be porting it to Crystal - but if I had an easy way to get ~5x speedup of the most performance critical parts of my code, I would jump at the opportunity. I'm glad someone is working on this
- vidarh 6y agoCrystal is not a Ruby. They're doing things that are intentionally different, and it's totally put me off considering it. In practice 99% of the time plain old MRI is fast enough for the things I do. The rest of the time, resorting to RubyInline or a C-module has usually been more than enough. E.g. the bulk of my code for my masters that involved heavy use of k-nearest neighbour implementations etc. for pre-processing image files for OCR was written in Ruby, with only ~2-3% then replaced with RubyInline C-code to get the speed needed. I'd take that over Crystal any day, as I don't like the places where Crystal diverges.
- 02020202 6y agoI wish there would C to GO compiler, that would make my day.
- tuananh 6y agoc to go transpiler exists https://github.com/elliotchance/c2go https://github.com/elliotchance/c2go
- 02020202 6y agoi have discovered it just today, lol. but it kind of works and mostly not, unfortunately. it would be AWESOME if Go core team would implement something like this into Go itself, since Go is just better C anyway, with GC. that would revolutionize the programming world, i think. i still dont understand why we dont have transpilation between the major languages being something one does not even have to think about, it just IS and WORKS.
- jonny383 6y agoImagine going all in on a Ruby project with this specialized library that literally changes the way you write Ruby and still thinking that's a good idea. Keep Ruby as it is - slow and expressive. If you need to speed up, get faster hardware.
- dastx 6y agoFaster hardware costs money. If this works well, and it stops being a PoC, why pay extra when you can simply add an annotation to a method, and your speed gain is free?
- wukerplank 6y agoThe thinking is that faster hardware is cheaper than developer time. E.g.: https://blog.codinghorror.com/hardware-is-cheap-programmers-are-expensive/ https://blog.codinghorror.com/hardware-is-cheap-programmers-...
- maccard 6y agoYou should really read that article. Just below the fold: > Everything is fast for small n. When n gets large, that's when things start to go sideways. The above graph of an ancient Trash-80 clobbering a semi-modern DEC Alpha is a sobering reminder that the fastest hardware in the world can't save you from bad code.
- chrisseaton 6y ago> Keep Ruby as it is - slow and expressive. Why not try to make Ruby faster without changing how expressive it is? I don't think this project does that by the way - it breaks Ruby semantics - but let's aspire to make Ruby faster. > If you need to speed up, get faster hardware. If your code is still too slow for your required per-request latency on a top-of-the-range Xeon and your individual requests have no useful parallelism and are not memory or IO bound... where do you go from there? Where are you getting faster hardware from? Sometimes there is no faster hardware.
- fareesh 6y agoThe obvious performance and bloat overhead with RoR aside, I have yet to see a framework and ecosystem that lets you have a programmable web application up and running with typical features in comparable time. For shipping new products or testing out ideas, I have not come across a more optimal framework in terms of going from idea to market. Most often I've tried Phoenix, Django and Laravel as alternatives, but all of them seem to fall short. I gave .NET MVC a shot too back in its early days, it was not pleasant. I run a dev shop and it seems to fit really well with our business model.
- pdimitar 6y agoThis is what brought me to RoR land... and this is what made me leave. I agree rapid prototyping is an excellent point for RoR but when you need to actually evolve the project for years, it gets really tedious and hard. So for a dev shop RoR is quite fine -- you make the project, do very little iteration on it, and ship. That works well and I've experienced it. For longer-lived projects however, Phoenix is miles ahead. Even Rust's Rocket, but only if you are willing to invent a lot of stuff yourself (auth for example).
- wukerplank 6y agoWhat makes you say it is hard to maintain longer lived projects? (I used to be a RoR developer for a few years, so I'm curious about other people's experiences.)
- pdimitar 6y agoIt's mostly the "magical" parts like before/after hooks. When you are tracing a bug and are trying to do step-by-step debugging, it has been hell. Quickly jumping to definitions? Even RubyMine can't do it. Furthermore, as the project grows, you need to introduce something more/bigger than MVC and people put these files everywhere. Sure it's a management problem but it doesn't help that people don't do the right thing by default. In general, there's a breaking poing that you will very soon hit when you try to just pile things on top.
- hasa 6y agoThe amount of new languages and "the absolute best framework" makes me think that big enterprises should never leave Java. Fancy project written on a newest tech is legacy before it is published. Scary from the business point of view. Disclaimer: I love Ruby.
- abhiyerra 6y agoOr use JRuby. :)