Closed zaxebo1 closed 9 years ago
@zaxebo1 Can cython detect type errors at compile time?
@zaxebo1 I'm a Python programmer, and that isn't even close. Cython just speeds up Python, with optional type annotations for more speed and the ability to generate Python bindings. Crystal is a completely different language from Ruby that happens to share syntax and some design concepts but is still very different. I'm not a Ruby fan, yet I really like Crystal.
It's more like Crystal is to Ruby as the late Wirbel is (was?) to Python.
The first two statements in http://docs.cython.org/src/quickstart/overview.html do not match crystal
Cython is a programming language that makes writing C extensions for the Python language as easy as Python itself.
Crystal is based on Ruby syntax, but does not aim to be a tool. There are some experiments to expose native extensions to ruby programmed in crystal, but that is as match as it's get right now.
It aims to become a superset of the Python
Noup. Crystal does not aim to be a superset of Ruby.
Thanks for replying. I am gladly surprised at such a fast response, this positively means that community of this is very active.
1) @asterite : cython can detect type errors
2) @bcardiff : it is superset of python, only in the sense that although pure python scripts can be compiled by cython easily, but if you mark types with cython specific annotations, then the types will be taken from those programmer-specified additional annotations and keywords. Only this superset thing for typing - is there. BUT still this superset keywords is just for sugar syntaxing, i can put the same extra superset keywords also in perfectly valid python annoations, and it will become perfectly valid python program also.
import cython b1=10 print(10) print(type(b1))
import cython cdef int b1 b1=10 print(10) print(type(b1))
import cython b1=cython.declare(cython.int) b1=10 print(10) print(type(b1))
SIDE NOTE: that now just few weeks back released version 3.5 of python itself contains core language contructs for specifying type constructs of function parameters etc
or, may be its not 100% analogous, but now my modified proposed FAQ statement(for python programmers) can be : "in some use cases, crystal and cython are analogous. "
Not even that. Cython is still mostly Python. Crystal isn't exactly even trying...
@kirbyfan64:
1) so are you saying that ?? - "not every ruby syntax is supported by crystal", .? OR, 2) so are you saying that ?? - we can not call ruby third party libraries into crystal directly.? (this is very important for me, to know) OR, 3) so are you saying that ?? - crystal standard library and ruby standard library have incompatibilities?
@zaxebo1 Crystal is a new language with Ruby-inspired syntax. It's not Ruby, it's not a Ruby implementation, it won't run Ruby programs, etc.
ohh.. okk
@zaxebo1
Best Regards, Alexey Fedorov, Sr Ruby, Clojure, Crystal, Golang Developer, Microservices Backend Engineer, +49 15757 486 476
2015-10-10 2:03 GMT+02:00 zaxebo1 notifications@github.com:
ohh.. okk
— Reply to this email directly or view it on GitHub https://github.com/manastech/crystal/issues/1717#issuecomment-147014070.
@zaxebo1 Yes, yes, yes. In my mind, this is a good thing, since Crystal also tries to avoid aliases, which is also what Python does.
ok permit me ask a one final question in other dimension:
1) Do ruby and crystal share "enough common things", that I can write a non-trivial sufficiently complex program from scratch in "that COMMON SUBSET of crystal and ruby", so that the program can run both on ruby and crystal. 1.a) non-trivial program (written in some common subset) to perform scientific manipulation 1.a) non-trivial program (written in some common subset) to perform RDBMS access and take input and display on web
Is it possible?
2) In this common subset(of crystal and ruby), can there be some kind of if-else kind of statement(preprocessor statement or part of language construct etc), so that the incompatible libraries call between ruby and crystal can be put it in conditional block, like:
if lang() == "crystal" CrystalStdlib_FunctionCall() else RubyStdlib_FunctionCall() end
It's about as possible as trying to write C++ and C# together...
Crystal requires type annotations in a few places that Ruby would consider syntactically invalid (e.g. [] of Int
). I would consider it possible, but jt would be kind of suicidal. :O
Trust me: just use Crystal. It's a good 200x better than Ruby.
Has anyone considered pushing to allow crystal type annotations in ruby? The stdlib is semi compatible but could be made more compatible by providing additional libraries.
@technorama :
your suggestion is really good/
just alternative wild suggestion from my side.
in cython , the types can be written using "cdef" as "import cython cdef int b1"
But types can also be written in python compatible syntax using "cython.declare()" such as: ""import cython b1=cython.declare(cython.int)""
in the same way, we can put ruby compatible syntax alternative for putting crystal type annotations in crystal programs. This minimal compatibility will make it attractive for large number of ruby developers
@zaxebo1 Crystal team made a decision not to be Ruby compatible to cast off all the bad baggage that Ruby has. I would say, if you want to write the same programs for ruby and crystal - it will never happen.
Best Regards, Alexey Fedorov, Sr Ruby, Clojure, Crystal, Golang Developer, Microservices Backend Engineer, +49 15757 486 476
2015-10-10 8:30 GMT+02:00 zaxebo1 notifications@github.com:
@technorama https://github.com/technorama :
just a wild suggestion.
in cython , the types can be written using "cdef" as "import cython cdef int b1" But they can also be written in python compatible syntax using "cython.declare()" such as: ""import cython b1=cython.declare(cython.int)""
in the same way, we can put ruby compatible syntax alternative for putting crystal type annotations in source. This will make it attractive for large number of ruby developers
— Reply to this email directly or view it on GitHub https://github.com/manastech/crystal/issues/1717#issuecomment-147045595.
I think the question is sufficiently answered with no, closing.
I'd say "Crystal
is for ruby
" is the same as "Nim
is for python
".
Totally different beasts. The Nim/Python comparison is much closer. cython is primarily aimed at speeding up python by letting you compile modules and classes t no C which is then transnogrified into ruby, which can be quite dramatic if you use the optional type annotations. However the super duper dynamic nature of python (And ruby) means that without the type annotations you end up with C that has to do a lot of faffing around with its introspection to run so while faster than cpython, its still not as fast as we'd want it. Crystal , while having more than a passing resemblance isn't ruby, nor is it ruby+types. Its a completely different language That relates to ruby in the way that, say , modula-2 relates to pascal. Close, but not quite. I'd say its closest analogue is actuall Go, but with safer types aaaand a slightly more immature ecosystem.
However if you know python or ruby, crystal is an afternoon at most to grok.
From the first looks on the website, can i say that "crystal is to ruby, what cython is for python" ? If it is right statement then probably it can be put into FAQ, so that programmers coming from python can easily understand the analogous