Want to have quick a C# program that writes to screen and is compiled with Ruby syntax? This mini-compiler could help you.
A code like this one does what you would expeect: writes 10 times "Hello from Calcium" then it counts the time in milliseconds that was required to do so:
def run
print "Hello from Calcium"
end
start = Environment.TickCount
i = 0
while i < 10
run
i += 1
end
endTime = (Environment.TickCount - start) / 1000.0
print "Time: "
puts endTime
The generated C# is the following:
using System;
using System.Collections.Generic;
using Cal.Runtime;
public class _Global {
static public void Main ()
{
Int32 start;
Int32 i;
Double endTime;
start = Environment . TickCount;
i = 0;
while(i<10)
{
run();
i += 1;
}
endTime = (Environment . TickCount-start)/1000.0;
Console.Write("Time: ");;
Console.WriteLine(endTime);;
}
static public void run ()
{
Console.Write("Hello from Calcium");;
}
}
As you can see it could be a time saver, and if it will be extended enough, it can replace in future some cases where you used IronRuby and you quit because it felt to slow. I plan to fix and extend this transpiler to make it functional enough to support very common cases.
If you are interested, please take a look and try to extend or report as minimal bug reports as possible.
If you are interested, please take a look and try to extend or report as minimal bug reports as possible.
No comments:
Post a Comment