On 1/3/20 11:31 AM, Josef Reidinger wrote:
> V Fri, 3 Jan 2020 11:14:15 +0100
> Ancor Gonzalez Sosa <an...@suse.de> napsáno:
> 
>> Ok, and now that I got your attention, let's rephrase the subject into
>> something more realistic: "I'm starting to port to Crystal a very small
>> and limited subset of yast-storage-ng".
>>
>> See more details at https://github.com/ancorgs/y3storage
>>
>> Is something I wanted to do in the past Hack Week... and in the previous
>> one... and so on. So finally I used the downtimes of my recent trip to
>> Nuremberg and some vacation time to get it started.
>>
>> Since next Hack Week will take place soon, I hope to continue with that
>> and maybe experiment with automatic translation or bindings. Let's see.
>>
>> So far, you can get surprised about how similar both languages are by
>> displaying y2storage/disk_size.rb side by side with
>> y3storage/disk_size.cr, or also y2storage/disk_size_test.rb and
>> disk_size_spec.cr.
>>
>> Cheers.
>>
>> PS.- No, there is no evil plan to migrate YaST to Crystal. This is just
>> done in the Hack Week spirit of "what if".
> 
> Hi, this is quite interesting. Especially similarities in testing looks nice. 
> I have few questions:

I have to say that my feeling is that similarities in testing are not as
deep as they may look in the surface. Tests in Crystal use almost
exactly the same syntax that RSpec, but AFAIK there is nothing like
"let" and nothing like rspec-mocks.

In fact, DiskSize is an example of RSpec used as traditional unit tests
"masked" into RSpec syntax. That makes the conversion very easy. We will
need to experiment by migrating other tests with an advanced usage of
"let" and with mocking of other components.

> 1. do you compare speed? Is really crystal significantly faster then ruby? 
> And what about size?

I have only ported a very small part so far, so I can't run any
significant test. Maybe after porting the whole "ruby" directory we can
do some benchmarks.

In theory, the difference in both memory consumption and speed should be
huge (that's what people say).

> 2. how is crystal supported in SLE? Can we easily use it for speed critical 
> parts of yast?

Crystal is not present in SLE at all. I got it from the official page,
which provides RPMs for many, many distros:
https://crystal-lang.org/install/

The compiler is based on LLVM, so it should be possible to get it
working in all architectures supported by SLE. But in practice, I would
be very surprised if anyone has ever compiled Crystal for anything
beyond x86 and ARM.

IMHO, using Crystal for something really serious would imply some kind
of investment in the project. It's not like Ruby or Python, a language
you can take just for granted everywhere.

On the other hand, it's already supported in Travis and that kind of
services, since many companies are migrating some parts of their Ruby
infrastructure to Crystal (for performance and concurrency reasons).

> 3. how works bindings to C++? I expect FFI should work fine, but C++ is not 
> much FFI friendly.

As most LLVM languages out there, binding to C libraries is trivial.
But, as always, C++ is another story. It always needs extra tools (like
SWIG) to generate proper bindings.

SWIG does not support Crystal. AFAIK, the only almost-working bindings
generator is Bindgen. But again, only tested in x86.
https://github.com/Papierkorb/bindgen

Cheers.
-- 
Ancor González Sosa
YaST Team at SUSE Software Solutions
-- 
To unsubscribe, e-mail: yast-devel+unsubscr...@opensuse.org
To contact the owner, e-mail: yast-devel+ow...@opensuse.org

Reply via email to