7 ms·
With Ruby getting an AST, and potentially a type system in the future, I think that ruby 3 could lend itself to bring transpiled to crystal relatively easily, d
by qop 8y ago
With Ruby getting an AST, and potentially a type system in the future, I think that ruby 3 could lend itself to bring transpiled to crystal relatively easily, depending on exactly how much type information there is, how difficult / possible it is to correlate that with the AST.
Scala 3 is doing the typed AST thing, so hell, why not?
- vinceguidry 8y agoSyntax is only the first obstacle. You also have the object model and the standard library to deal with as well.
- Kalium 8y agoYou're absolutely right! Any Turing-complete language can be transpiled to any other. That said, you can't always expect sensible or human-brain-friendly results if you're moving between two languages that work very different.
- workinthehead 8y agoWhy must you keep telling people "You're absolutely right!" It seems insincere and condescending at best. If you really think you know better than the person you're responding to, use evidence and logic, not cheap conversational ploys.
- Kalium 8y agoI do need to mix up the verbiage more. In practical terms, people respond much better to having their egos stroked than they do to being told they're wrong. Evidence and logic work much better when someone doesn't feel like their ego is at stake. Telling someone they're right before pointing out that they could be more right is one way to do this. Telling people that they're wrong is more likely to provoke a defensive reaction and a closed mind than it is genuine thoughtfulness and consideration. We've all seen people refuse logic, reason, and evidence because they feel personally attacked, I suspect. This is a lesson I gleaned from the (in)famous "How To Make Friends And Influence People". It's not wrong, it's just cynical. So of course it's insincere. Human interaction is greased with little insincerities. It's how we deal with egos.
- vinceguidry 8y agoYou're not supposed to acknowledge insincerity. You're supposed to make up another reason that merges the sincere and the insincere viewpoint together.
- Kalium 8y agoYup. But the Dale Carnegie stuff is exhausting. I'm sincere in that I want people to listen to my points without getting their egos in the way.
- workinthehead 8y agoListen to my points. Me, me, me. What are you doing about _your_ ego (which seems quite large and is definitely getting in the way)?
- workinthehead 8y agoThe only place this works the way you think it does is in your mind. Any normal person is going to see that and register it as goofy and ingratiating. Like Spock or some alien that thinks it's cracked the human code when really it's nowhere even near the uncanny valley.
- Kalium 8y agoI understand why you think that. This may surprise you, but I really wish my experience agreed with you. I really wish most people saw immediately through insincerity and ego-stroking and empty complements. Indeed, some do. Most of the time, it's disturbingly effective. My data to date suggests that most people won't look too closely when you feed them kind words to hide the others.
- qop 8y agoYes definitely, however -> gets better response and cooperation than -> Well, actually Just my two cents, not parent btw
- chrisseaton 8y ago> I think that ruby 3 could lend itself to bring transpiled to crystal relatively easily I think for this to be tractable you'd basically have to implement a complete Ruby interpreter in Crystal and then transpire the Ruby program to bytecode to be run by the Crystal interpreter. So not really a meaningful or useful transpilation any more, and certainly not fast. Even basic things like method dispatch do not have the same semantics in Crystal as in Ruby, so almost nothing could be tarnspiled 1-to-1.
- qop 8y agoWe don't know very much about what ruby 3 types will look like or what other information we'll have. Even a small subset of ruby being transpiled would be a useful thing for some developers. You're much more aware of some of the constraints here than I am, as Oracle doesn't pay me to hack ruby for a living. With a typed AST, there'd be enough information there to build a foundation for a rb2cr tool. I didn't say the two languages are best friends and it'll be a breeze. Most of the ruby code I want to rescue isn't littered with string-based define_method nonsense. Most of ruby I think worth saving at all is outside of rails and exists in various tools or maybe some metasploit modules or stuff like that. The pieces of code that utilize the grossest dynamic elements of ruby, like define method or objectspace, that stuff doesn't need to survive. Even getting 50% of a codebase in ruby compiled to reasonable crystal is a much better foundation than previously purported successors (elixir, scala, swift) can do. If ruby gets a typed ast, I'll try and write a simple transform tool for the simplest ruby.
- chrisseaton 8y ago> Most of the ruby code I want to rescue isn't littered with string-based define_method nonsense. I see what you are saying - but this is where the issue is I think. You may not write code that does sophisticated metaprogramming, but the gems you use are probably fundamentally based on it. Even just requiring some of the standard library uses a surprising amount of of metaprogramming. For example you can't load something as basic as 'fileutils' without doing a lot of metaprogramming. The entire Ruby ecosystem is built on metaprogramming.
- vidarh 8y agoThe type system is the least of your problems. Ruby's type system is fairly simple and straight-forward. The problem is that the ruby execution model is fundamentally incompatible with ahead-of-time compilation without making a lot of decisions about what occurs before compilation and what is deferred until later. E.g. a lot of Ruby programs execute code to determine which files to "require" (e.g. iterating over all files in a directory is a common pattern). In some cases that is a convenience for developers. In others it's meant to e.g. provide "plugin" abilities at runtime. In both cases the included code can totally change the behaviour of large parts of your code base. Those decisions are possible to make, but you must make them and you probably can't make them satisfactorily without providing a mechanism for the developers to specify intended behaviour. If your decision is to defer everything until after compilation, you'll basically end up JIT-compiling most of the code at runtime, and all type information from before that point is suspect.