Better HN
topnewbestaskshowjobs
Log inSign up

erik-kallen

168 karma · joined Sep 3, 2012 (14y ago) · 15 submissions

Submissions

comment 14y ago · link · parent

Reason to use Node.js on the server without liking Javascript: I like the framework. Framework != language (or at least it should be).

2.

Writing node.js applications in C#(erik-kallen.se ↗)

31 points · by erik-kallen · 14y ago · 33 comments

comment 14y ago · link · parent

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 :)

comment 14y ago · link · parent

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).

comment 14y ago · link · parent

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?

comment 14y ago · link · parent

Why would I want to use the proprietary Roslyn when I have a working solution with the open-source NRefactory and Cecil?

comment 14y ago · link · parent

for (;;), continue and switch.

comment 14y ago · link · parent

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).

comment 14y ago · link · parent

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).

comment 14y ago · link · parent

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.

comment 14y ago · link · parent

Saltarelle is way more complete, though.

comment 14y ago · link · parent

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.

comment 14y ago · link · parent

You can use the Chrome debugger just as if you had written the Javascript directly.

comment 14y ago · link · parent

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"?

15.

New C# to Javascript compiler released(erik-kallen.se ↗)

109 points · by erik-kallen · 14y ago · 79 comments