3 ms·
Python to Crystal??! But Crystal is a statically compiled version of Ruby, not Python.
by cutler 5y ago
Python to Crystal??! But Crystal is a statically compiled version of Ruby, not Python.
- viraptor 5y agoIt's not a version of Ruby. And Ruby and Python are roughly equivalent, so if you can convert one, you can likely convert the other. (see also https://github.com/whymirror/unholy https://github.com/whymirror/unholy)
- cutler 5y ago"roughly equivalent"? They're chalk and cheese to me. Python metaprogramming, anyone? Each? Blocks? Real lambdas? Don't get me started. I'm not saying you can't do it, just why would you want to when you end-up with something that doesn't resemble what you started with?
- viraptor 5y agoRoughly equivalent as in they have very similar object model and each construct is trivial to convert into the other. each is just a fancy for with new scope, blocks can be replaced with local functions, etc. They don't have anything that's not a trivial transform away (like for example: tail calls, callcc, macros, compile time transformations, ...). I mean, you may prefer one of these: foo.each { |i| ... } for i in foo: ... but after fixing up the scope issues, they're the same thing.
- nanobowers 5y agoThis project started with this request: https://github.com/crystal-community/crystal-libraries-needed/issues/116 https://github.com/crystal-community/crystal-libraries-neede... However, it is heavily based on the (abandoned?) py2rb work by Naitoh which I made enhancements to. IMO, Rubyists should have an easier time with Crystal syntax since it is more similar. Also, the likelihood of having type annotations in Python is much higher than Ruby because type annotations have been around longer in Python, iirc.
- cutler 5y agoBut the momentum behind gradual typing in Ruby is much greater due to the input from Stripe and Shopify.