HNHacker News
TopNewBestAskShowJobs

erik-kallen

168 karma · joined September 3, 2012

submissionscomments
erik-kallen··on Writing node.js applications in C#
Reason to use Node.js on the server without liking Javascript: I like the framework. Framework != language (or at least it should be).
erik-kallen··on New C# to Javascript compiler released
I think the tools fill different purposes, so integration with JSIL is absolutely a possibility in the future. I did not do any speed comparisons, I just translate what you write in C# to the equivalent script, so if you write a fast script it will be fast, if you write a slow script, it will be slow :)
erik-kallen··on New C# to Javascript compiler released
SharpKit is only free as long as you want to use it for projects that don't need it (the limit is like 2k lines or something). When I last tried it I was not very happy with the code it generated. Additionally, it uses the standard mscorlib so it is not unlikely that you will end up calling methods that are not implemented (which is the very problem the tool is designed to avoid). If it were open source, I would have contributed to SharpKit instead of rolling my own, but it is not.

When it comes to the language support, I think Saltarelle is slightly ahead, as it supports goto and yield (I don't count SharpKit's implementation of yield which translate 'yield return "x"' to '$yield.push("x")' and then returns the $yield array).

erik-kallen··on New C# to Javascript compiler released
Java has been said to be a DSL to convert XML configuration into stack traces. But what does this have to do with compiling C# to Javascript?
erik-kallen··on New C# to Javascript compiler released
Why would I want to use the proprietary Roslyn when I have a working solution with the open-source NRefactory and Cecil?
erik-kallen··on New C# to Javascript compiler released
for (;;), continue and switch.
erik-kallen··on New C# to Javascript compiler released
That's right, it doesn't get horrific until you use goto or yield (which don't exist in Javascript so they have to be emulated).
erik-kallen··on New C# to Javascript compiler released
But all those commits are, unfortunately, tiny. Also the compiler is not open-source only the runtime library (which Saltarelle uses a modified copy of).
erik-kallen··on New C# to Javascript compiler released
JSIL is also great, but its philosophy is that yo write .net code and run it in the browser, whereas Saltarelle's (and Script#'s) is that you write Javascript but with better tools. Also, the script that JSIL generates is very far from what you would write by hand, whereas that generated by Saltarelle/Script# can be distinguished from hand-written script primarily because the indentation is always correct and there is never an accidental loose comparison operator.
erik-kallen··on New C# to Javascript compiler released
Saltarelle is way more complete, though.
erik-kallen··on New C# to Javascript compiler released
It comes with metadata for jQuery and jQueryUI, so obviously those libs can be used. I know of people using Node as well (and I hope to include that import lib in the distribution at some point).

As for porting an existing C# application, it will probably not be trivial, but the back-end stuff is most likely possible (as long as it doesn't have external references). Personally, for my own stuff I tend to compile stuff like DTOs and helpers to both Javascript (running on the client) and regular MSIL (running on the server), but that code has been written with this intent from the beginning.

I prefer to regard working with this to be writing Javascript but with tooling from 2012 instead of 1995.

erik-kallen··on New C# to Javascript compiler released
You can use the Chrome debugger just as if you had written the Javascript directly.
erik-kallen··on New C# to Javascript compiler released
Actually, debugging is quite simple. The generated script (unless minified) is very similar to the input code. Are you also against other options such as CoffeeScript? And do you think it is very hard to debug higher-level languages such as C, C# or Java because "if you are writing code to run on a processor, it is assembly you should be writing"?