4 ms·
Writing node.js applications in C#
- impostervt 14y agoWhen I read about Node.js, the first selling point people mention is how you can reuse code on the client and server sides. For me, the main selling point is that it's Javascript. When I see new variants of js, developed to "fix" js, it makes me want to cry.
- GameDev 14y agoCry me a river
- davidlumley 14y agoI think there's a difference between languages designed to compile down to JS (e.g. CoffeeScript) and wanting to convert a completely different language (e.g. Ruby or C#) into JS. JavaScript has a lot of good and bad parts, and given we don't really have an option of choosing to use something else in its place I strongly believe that (some) languages that compile to JS have their place. While I don't believe all of them are useful (i.e. dart, typescript) they're specifically targetted as an alternative to JavaScript. If you're trying to convert a different programming language, that isn't based around the way JavaScript does things then I firmly believe you're doing something wrong. JavaScript isn't just remembering that the semi-colon is optional and that JSON is wonderful. While other languages support event driven behaviour, JavaScripts implementation is (probably) different meaning there's still a learning curve. The documentation for Node.js is, unsurprisingly in JS. The libraries are JS. The whole ecosystem is JS. At least with CoffeeScript quite a few libraries have their source as .coffee, and the style of programming is identical to the compiled JS.
- Jare 14y agoCurrently, reusing code on client and server is far from the first selling point. Companies like Meteor and Groupon are pushing in that direction quite heavily, but for mere mortals it's still limited to reusing a few core libraries like underscore, async or templating. Reusing experience and knowledge, and reducing the cost of context switching, those are very clear and positive advantages. On the topic of sharing code, these should be interesting: the 'pipe dream' ( http://keithnorm.com/spainjs-pipedream/ http://keithnorm.com/spainjs-pipedream/ ) and the 'holy grail' ( http://thatconf.chrisjpowers.com/ http://thatconf.chrisjpowers.com/ ).
- alphadogg 14y agoAs an aside, http://thatconf.chrisjpowers.com/ http://thatconf.chrisjpowers.com/ features what I will give my "Annoying Hipster Presentation Style Of The Month" award. Can't we just have information without all the JS supa-awesumness, just because we can?!?!
- rdrey 14y agoThanks for the "pipe dream" link, I found the conference talk on youtube and enjoyed it a lot. The reusable code 'function' of node is still too non-obvious to achieve without the right mix of tools and this talk gave a nice intro for a solution.
- vladsanchez 14y agoUse TypeScript!
- tomkludy 14y agoWhat exactly is the point here? If you want to write C#, just use ASP.NET and MVC 4. You will certainly save yourself a lot of headaches, and you can still do everything async, etc. From what I can tell, the purpose of Node.js is to reduce the number of technologies that a web dev has to use and understand. You already need to use JavaScript on the client side, so using the same thing on the server side allows code reuse, knowledge sharing, etc. It seems like what the author really wants is ASP.NET on the server, and Script# on the client side. Then the whole stack is C#. Or perhaps he would find TypeScript an acceptable middle-ground on the client. But I don't understand why you would choose Node.js on the server if you hate JavaScript, does not compute.
- erik-kallen 14y agoReason to use Node.js on the server without liking Javascript: I like the framework. Framework != language (or at least it should be).
- davidlumley 14y agoSidenote: Node.js isn't a framework, it's a platform.
- tomkludy 14y agoI'm genuinely curious which feature(s) of node you like better than ASP.NET. I have used both and find them quite similar as far as "raw" capability. ASP.NET however has all of the things you were asking for: great Intellisense, great tooling (for instance integration with Entity Framework), great libraries available (such as SignalR), code in C# or any .NET language (including F#), rich async support... I like node too, but to me, the reason to choose it is either if you want to remain platform-neutral, or if you really like Javascript.
- axefrog 14y agoI would imagine he's referring to the non-blocking IO and evented model. ASP.Net and friends use threads for everything, which allows for heavier processing, but also is more restrictive in terms of concurrency.
- cincinnatus 14y agoThere is already a node.js analogue that runs on .net and hosts .net https://github.com/jacksonh/manos https://github.com/jacksonh/manos Hasn't been updated in a long time. Not sure why it isn't getting any love, maybe something better came along. Seems to me it should be more performant on equal hardware.
- gizzlon 14y agoI can't believe Javascrip is really that awful that anyone would rather go through all this trouble, rather than just write JS.. Maybe it has more to do with people being to reliant on IDE's, which he, kind of, admits to anyway.. I can't believe that any IDE is that great that anyone would rather go through all this trouble, rather than just use something else..
- yawgmoth 14y agoI think in this case, it isn't about being dependent on Visual Studio, but C#.
- hkarthik 14y agoThe two go hand in hand. Aside from a very small cross section of Mono users, most C# users are very dependent on Visual Studio.
- georgemcbay 14y agoIMO JavaScript is that awful, but I still don't understand why you wouldn't just use Go or C# or whatever natively on the backend. There are lightweight frameworks similar in concept to node for virtually every language out there. I understand why people write JavaScript translators for the browser -- there you're (unfortunately) stuck with JavaScript there is no other option. I also understand why people who do like JavaScript use node. Even though I'm not a fan of JavaScript, there is certainly some benefit to keeping a project all in one language. But if you're the type of person that wants to avoid JavaScript in the first place, why start off in a situation where you already have an overly complicated language-to-language transpiler situation on the backend?
- louthy 14y agoIt strikes me that there's a much simpler solution, and that is to use TypeScript. It has all the VS intellisense that's required and none of the boilerplate in the OP's solution. http://www.typescriptlang.org http://www.typescriptlang.org
- cdl 14y agoMay want to take a look at ServiceStack, nice lightweight alternative to MVC with an extensive architecture providing for super easy and high performance ORM, JSON/JSV serialization/de-serialization, POCO DTO's with no-effort endpoints! http://www.servicestack.net/ http://www.servicestack.net/
- fpp 14y agoOne of the key benefits of node.js is that people who are great with JS can write server code and you have one language stack less to worry about. You can with that (watch for security issues) also share code & objects between the server and browser. Can't see how this fits into that.
- politician 14y ago"JavaScript is the only language people feel like they don't need to learn to use." -- Crockford
- kantl 14y agoNot more than month ago when this project was announced people were praising it. (No wonder, it features a fairly complete subset of C# - it's free and open source, it works and it's great - mad props to the creator keep up the good work!) Now when the author presents a use case people are throwing rocks. (At least this is my impression by reading some of the comments). I don't know about you, but I feel bad about it. It's the same story everytime a topic of compiling to JS is brought up. The JS "crowd" steps in with their "wisdom" of why it's a bad idea to do "X" and all they do is criticize...