108 points · by schiller-silvio · 9y ago · 34 comments
[0] http://www.mikeperham.com/2016/05/25/sidekiq-for-crystal/
Just to nitpick, capturing STDOUT is not that hard in Ruby at all. Definitely not as easy as Stdio.capture, but Ruby gives you a variable called $stdout, which you can assign to local variable and treat it like a file. If you would rather not print messages out during the test, then you can just temporarily assign $stdout to nil.
Personally I think the wide adoption of JVM, CLR, Python, Ruby,..., alongside the demise of languages like Delphi, helped fortify C and C++ place at begining of this century.
For many people, they became the only two languages they knew that were capable of producing binaries, unaware of other options.
Thankfully the tide is turning.
As for Ruby, I always felt the community could have learned from Dylan and implemented a proper AOT compiler, for a while RubyMotion seemed to be that one.
Now we have to bet on Crystal it seems.
Ruby is fundamentally hard to AOT compile efficiently (that's part of the fun I have of trying to compile it...). Part of the challenge is that the moment you allow eval() you have to include a JIT anyway.
Even without it, something as basic as "require" (to load modules/include files) in the typical Ruby install has been overridden by bundler and/or Rubygems to dynamically alter what will get loaded, and e.g. a variety of patterns involve dynamically altering the load path based on directory content.
Something as "simple" as generating a staticaly linked binary out of a Ruby program involves solving the halting problem (e.g. your program could wait for user input to decide which file to load) or making decisions that makes your compiled binary act different to how the interpreter would.
Basically, to statically link Ruby you have pretty much two choices: Make a new language, like Crystal, or determine the minimum set of limitations / changes to Ruby semantics to make it viable to compile with the lowest amount of breakage. I'm trying for the latter, but who knows, something like Crystal might turn out to be the better option. It's certainly a simpler option.
A large part of the problem is that Ruby grew organically based on an interpreter rather than being designed with compilation in mind.
I was telling him that from my point of view, given the work done in languages as dynamic, meaning Lisp, Dylan, Smalltalk, that from my naive of view (I know Ruby only superficially) that could be applied to Ruby as well.
He also answered me along those lines, that idiomatic Ruby abuses more the dynamism than those languages.
Someone mentioned on reddit me about a CLI testing framework that perhaps does a more holistic job of testing STDOUT.
it's written in python but it's not for python projects per se.
I've been playing around with it for a a while, and really enjoy it.
That said, if you hate Ruby, keep walking...
For example Crystal vs. Elixir.
Does Crystal have A framework like Phoenix or Rails?
I'm sure large, opinionated frameworks will appear for Crystal but in the meanwhile Crystal and its community are just finding their feet and experimenting with what feels natural in Crystal and what doesn't. Once that's done, I'm sure that knowledge can be crystallized (heh) into a framework like Rails.
Crystal seems quite nice though.
Wat? Rails?