cloud9 node.js addon debugging - node.js

I'm working on a node.js module which uses native C++ addons. I plan to move my development from vim+nemiver+node-inspector to something more integrated. For that c9 seems to do the job.
Is it possible to debug both javascript (with v8) and C++ (with gdb) at the same time?
My old setup supports this by using nemiver and node-inspector side by side, but it isn't a very pleasent workflow.

Related

How to debug core library of node in WebStorm?

In WebStorm I could go into _stream_readable.js belonging to Node core library by using Force Step Into button. But I couldn't add any breakpoints there.
Meanwhile I can do this in Chrome Devtools where there is a limitation you need http server to connect Chrome Dev with Node Application. It is not convenient sometimes.
Is there any way to debug core code in WebStorm?
Chrome Dev Tools deal with runtime code loaded in VM, WebStorm - with source files available on your disk. You can't create breakpoints in files that don't exist in your project/libraries. But you can step into runtime code while debugging.
Node.js Core library created by Webstorm for Node.js code completion (Settings | Languages & Frameworks | Node.js and NPM, Node.js Core) includes fs.js, stream.js, etc. - all core modules provided by builtin-modules module, so some of the core files are available locally and included in project and thus accessible to the IDE. But undocumented and similar modules, like _stream_readable are not included.

Can expressjs be faster if I compile it?

There are tools that help us now to compile or node.js apps into executable such as "pkg". But I am interested If this can improve a web server written in expressjs?
No, web servers based on the Express framework will always require running on the V8 JavaScript engine of Node.js, which is also used by the Google Chrome browser.
You cannot compile a JavaScript program to machine code and run it standalone, like you can with programs written in C++.
If you create an executable program with JavaScript, for example using Electron, it's actually just a modified Chrome browser that runs the JavaScript, so the JavaScript is not actually compiled, it is still code interpreted by the modified Chrome's V8 engine at runtime.
Chrome and its V8 engine are written in C++ and compiled to machine code, so they can be run standalone.

JXcore vs Electron

question
I am wondering what the main differences are between Electron and JXcore.
background
I was thinking about how I could make a NodeJS server into an app and I came across both of these. They seem to do the same thing, except that JXcore supports mobile and Electron doesn't.
side question
If Electron doesn't support mobile then how was the slack mobile app created?
Thanks in advance!
From the JXCore site(http://jxcore.com/tech/):
JXcore is a fork on the open source Node.js project
It uses LLVM to compile javascript as opposed to V8 which NodeJS does.
In terms of what are the main differences- Electron is a framework for building native, cross platform desktop applications, where it appears JXCore is a javascript engine forked from NodeJS.
Electron is built with NodeJS, and Chromium. So to make it fair, the comparison would be better stated "How does Electron work with NodeJS vs JXcore". Since I don't have any experience with JXCore, I can't answer that question. I would venture to say the only way to know that is to fork electron and replace Node with JXCore.
Based on your background, I would assume you are thinking about making one application that works cross platform across mobile and desktop environments. To that, I would say it is possible, but you are going to have 2 different projects. There are things in Electron that you wouldn't want included in your mobile app, since they are working with completely different operating systems. You are right that electron does not support mobile (it wasn't built for that).
As far as your side question goes, there are any number of technologies that slack could have used to create their mobile app. They could have used Java , Swift, Objective-C, .NET, Ruby, or Javascript.
There are cross platform tools such as RubyMotion, NativeScript, React Native, and Xamarin that could also be used to create native mobile apps, that all compile down into the native language the mobile OS understands.
A final approach could be the use of tools such as Cordova/Phonegap which create mobile apps via a "web view". Essentially, this is like creating an app that launches a web browser to interact with your phone.
If you are looking for an example on how to build once and use everywhere, I would look at the github repo found here https://github.com/NathanWalker/angular-seed-advanced. This shows a common codebase that can be used in Electron, Web, and Mobile.

Node.js runtime wrapper

Are there any node.js runtime wrappers generators similar to gradle wrapper that allows to build node.js application without installing the node runtime globally?
Yes, there are many projects that aim to make bundling Node.js with your apps easy:
node-bundler
Nexe (doesn't support dynamic require statements)
EncloseJS (paid)
If you're starting a GUI project from scratch, then Electron or NW.js allow you to bundle up a browser with your app to allow using JS, HTML and CSS.
There are also some experimental JavaScript-to-uninterpreted compilers in the work:
ts2c converts TypeScript to C which can then be compiled with gcc or clang, and there's an unreleased project called Nectar that aims to compile JS to machine code directly.

How to debug node.js app typescript file in Visual Studio 2013

I have an Node.js app written by typescript. I have VisualStudio 2013 and Node.js tools for Visual Studio, so I can debug compiled .js files in node.js runtime.
I can debug typescript files for browser html application.
How can I debug typescript files for node.js environment?
It is trivial to debug nodejs javascript applications using webstorm : http://www.youtube.com/watch?v=6bKsDoFj83o I would suggest doing the same in typescript case i.e. debug your js.
I tried to do this a while ago and found it quite frustrating, I don't think it's possible to use the Visual Studio debugger for TypeScript with Node applications at the moment. You're also limited to using Internet Explorer for debugging and most developers seem to use Chrome these days.
That said Node and TypeScript debugging is possible, there's a link here. The process is a little funky but basarat is on the right track - WebStorm is probably a superior development environment for JavaScript applications and it has good support for the compile to languages (TypeScript, CoffeeScript, Dart). I haven't tried debugging TypeScript with Node apps using WebStorm but according to this thread it is possible.
UPDATE:
I've just had a quick look at the NTVS site (see here) and there are workarounds but they're not easy and this remains a work in progress
With the 1.0 beta release of NTVS it is now very simple to debug node.js applications in visual studio (version 2013), as this release contains the typescript compile templates which previous versions did not contain. The new functionality lets you debug directly in your typescript code.
If you are using previous versions you can get around the missing templates by having two projects in your solution, one for a web application (this does the typescript build) and one for the nodejs tools to debug the js code.

Resources