Mike Cantelon

Author
+ Follow
since Mar 04, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
5
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mike Cantelon

Thad Humphries wrote:I have a requirement for a web client to work with a large, legacy server system. This system has an API of approximately 200 functions and is documented in C. The system also provides C libraries for Windows and Macintosh development, and we have rolled our own Java interface.

I have a good deal of Java experience and a lesser amount of JavaScript experience, though none with Node.js. I am looking at Node.js for client-server development (as well as Python for server only). I see there is a Node.js module sunrpc_server (https://nodejsmodules.org/pkg/sunrpc_server) but there's no information that tells me how I might use it or if it could even do what I need, which is make an RPC connection to this remote legacy system, send properly packed RPC parameters, and unpack the response to each call.

When I've investigated the RPC claims of languages outside of C, what I find are examples of an application talking to another app in the same language and no mention of legacy systems. As I said, for Java we had to roll our own--writing our own RPC hand-shaking and packing and unpacking parameters for each call. This was no small effort. What might Node.js offer that would get me moving quickly?



Hi Thad,

I'd suspect that you'd have to roll your own with Node as well. I know of RPC systems, but they're more geared towards new development rather than interfacing with existing, non-Node systems. Rolling your own with Node, however, may be easier than in Java. Node is a pretty good framework for rapidly developing TCP/IP functionality. Maybe what you should do is try out Node's net module to get a feel for whether it would be doable.

Cheers,
Mike

Kent O. Johnson wrote:Hello Mike, Mark, T.J., and Nathan! Welcome to the ranch.
My question to you is how do you address security with node.js? After looking at your ToC for the book I see you address security with HTTPS in chapter 4 and Connect in chapter 7.
I see that the Node Firm claims to provide node.js with enterprise-level security. Do you address that topic or point in your book anywhere?



Hi Kent,

We don't go into security in the book, no. Node applications, like applications created using other platforms, tend to employ a lot of add-on modules. Each add-on module presents its own potential security risk.

There's an initiative, contributed to by a number of Node organizations, to track vulnerabilities in Node and Node add-ons that you might want to check out: https://nodesecurity.io/advisories

Cheers,
Mike

Muhammad Saifuddin wrote:Hi Authors,

Firstly, Congratulations and best wishes for this book.

My Question is more to share-out your part of interest like How you become enthusiast of this product and what attract you most in your first experience?

Thanks,



Hi Muhammad,

Thank you!

Before using Node I'd worked with a number of different dynamic languages (mostly PHP) and had started getting more serious about JavaScript. When Node started to attract interest I check it and was excited. What I really liked about Node was how easy it was to do things that were previously difficult (writing TCP/IP applications, for example). I also like the module system and the Node Package Manager (npm). I kept playing with it and started showing it to others so they could see what it could do

T.J., from what I remember, was originally into doing graphic design then got interested in programming. He originally worked with PHP, then Ruby, and then got into Node. T.J.'s written a ton of amazing modules.

I'm not sure about Nathan or Marc's stories about how they got into Node. I should ask them... it's always interesting how people end up doing what they're doing.

Cheers,
Mike

David Sachdev wrote:

Barry Raczkowski wrote:Okay now I understand where Node.js fits in to the chain. Can it connect to database back end were does it sit in the server software chain. Does it work with python or is it self conatined? Does it have JDBC drivers? Can it perform ajax calls?



When it comes to it's connection pooling and transaction capabilities, can Node.js handle XA transactions across multiple databases? Can it rollback transactions against various "data sources"

Thanks
David Sachdev



Hi Dave,

Node interfaces with database through add-on modules, so it all depends on the add-on module's capabilities. If a database supports transactions then it's likely that Node add-modules to interface with that database will support transactions too.

As far as where Node sits in the server software chain, it sits in the same place as a language like Python, Perl, or Ruby normally would. Those languages also use modules to talk to the database.

Node is self-contained: you can think of it as a server-side JavaScript implementation with a core library of add-ons that can be used to deal with the filesystem, deal with networking, etc.

Node normally doesn't use JDBC, but there's a a module available that allows you to interface with JDBC: https://github.com/CraZySacX/node-jdbc. I'm not sure how well-used it is, however.

You can definitely perform HTTP requests with Node, yes.

Cheers,
Mike

Sagar Rohankar wrote:I am asking this question because I really want to know what he is doing after stepping down as node lead? Any idea authors?



Hi Sagar,

The last I heard, Ryan was going to focus on doing research for Joyent. I haven't heard anything since then. Before getting into programming, and eventually starting the Node project, I think Dahl was focussed on non-technical academic pursuits, so maybe he's stepped away from tech? Interesting question.

Cheers,
Mike

Rebecca Peltz wrote:Is there any benefit to using JavaScript for all layers in your application? In o her words, is it worth it to use node.js over Apache/Tomcat for your server if you are migrating to an application using angular? If not absolute answer, any pros and cons?



Hi Rebecca,

There are some benefits to using JavaScript for all layers in your application. One is that you can use the same code on the client-side as on the server-side. Form validation code is one example of where this can be useful.

I'd say if your application is running as needed, then it may not be worth the work to convert it to Node.js (unless your application is small).

Cheers,
Mike

Runrioter Wung wrote:Node is very, very hot, and I just coded in javascript for the front-end before.I wonder when I should choose JS for backend not .NET or JavaEE(I am a J2ee programmer). Which type of application is the one that Node is designed for?Asyncronous and evented nature of Node is very cool,but sometimes sequential programming is a must.How can I implement it by JS.I don't know that if all I ask is in the book named NODE.JS IN ACTION.



Hi Runrioter,

Node.js is great for applications that require high concurrency and minimal CPU/memory usage. So things that should feel "real-time" like online games, chat, and web applications. For a balanced look at what use-cases Node.js is most suitable for, I recommend Chris Richardson's talk "Node.JS: The Good Parts? A Skeptic's View" (https://www.youtube.com/watch?v=CN0jTnSROsk).

If you need part of your application to be sequential, you can a technique called "flow control". Flow control makes asynchronous logic behave in a synchronous fashion. You can either implement flow control yourself in your application or, much easier, simply use flow control modules. One such flow control module is async (https://github.com/caolan/async).

Cheers,
Mike

Priyadarsan Khabiya wrote:Which unit testing framework is being used in node.js in action and why ?



Hi Priyadarsan,

There are a number of unit testing frameworks available for Node. Most of them also work in the browser, so you can use them to test your client-side JavaScript as well. Mocha (http://visionmedia.github.io/mocha/) is a popular one (created by T.J., one of the co-authors of "Node.js in Action"), and the one I prefer to use. Vows (http://vowsjs.org/) and Nodeunit (https://github.com/caolan/nodeunit) are also widely used.

Cheers,
Mike

Chip Furstenau wrote:This is a similar question to one that was already posted, but here goes. Whenever I read articles about Node.js, it seems to have a reputation as a "neat trick" for web developers to easily create a little backend for their application. Are there benefits to Node.js that could motivate someone who is already familiar with Java backend to learn a new framework? That is, could an existing application be made better by implementing Node.js?



Hi Chip,

Whether or not it's worth learning probably depends on what kind of applications you're looking to create or improve. Node.js is great for applications requiring high concurrency and a minimal amount of CPU/memory usage. JavaScript, however, isn't strongly typed and debugging asynchronous applications can be difficult.

Probably the best thing I've encountered in terms of weighing the pros and cons of the use of Node.js is a presentation by Chris Richardson, a Java developer who uses Node.js for smaller projects. He points out potential flaws of Node.js and JavaScript, yet concludes that Node.js is well worth using for many use-cases. His presentation is here if you'd like to check it out: https://www.youtube.com/watch?v=CN0jTnSROsk

Cheers,
Mike

Scott J Johnson wrote:Hi!

So I've noticed that a number of projects use grunt to 'build' a node.js project. I'm wondering what projects that use node.js need to do to "build", and what advantages/disadvantages are of different tool sets.



Hi Scott,

Most Node.js projects using Grunt are doing so to build client-side, rather than server-side, resources. So they're doing things like taking JavaScript and minifying it to reduce the filesize so when it's served to a client browser it takes less time to send. Another common use for Grunt is compiling CSS from CSS pre-processors like LESS (http://lesscss.org/).

In terms of advantages and disadvantages, Grunt has a great deal of community add-ons and is in wide usage so it's easy to get help with. Gulp.js is an interesting alternative that uses a Node.js technology called "streams" to make it easy to write build files and lessen build times.

Cheers,
Mike

Alec Swan wrote:Hello,

What are the pros and cons of node.js when compared to a Java backend, such as Jetty? I am looking for something very high-level, e.g. "Use Java for data-intensive processing" or "Learning curve of asynchronous programming for Java developers is very steep". It would be valuable if the answer touched on performance, productivity, adoption and tooling of these two backend technologies.

Thanks,

Alec



Hi Alec,

My knowledge of Java isn't too in-depth, but I'll give this question a shot. A lot of Java frameworks rely, as far as I know, on threading for concurrency. This can be more expensive, in terms of CPU and memory usage, than using an event loop, like Node.js does. So if high concurrency is something you need, then you might want to avoid traditional Java web frameworks. However if you know Java, continuing to use Java may be the right thing to do. There's a project called Vert.x which employs the same event-driven strategy as Node.js to get high concurrency, but it can be programmed in Java (or JavaScript, Ruby, Groovy, and Python). Vert.x isn't Node.js compatible, though, so you won't be able to use Node.js modules. There's a new project, however, called Nodedyn (http://nodyn.io/) that aims for compatibility with Node.js, but runs using the JVM. This could end up being useful for folks with a lot of experience tuning the JVM.

Cheers,
Mike

Qunfeng Wang wrote:Developing with a dynamic language is a little painful. It happens a small typo will cause some time to debug. I'm wondering how comfortable developing server side with Node. It's different with client side. We have no choice on client side. But there are lots of good languages for the server side.



Hi Qunfeng,

That's a good point... dynamic languages aren't to everyone's taste. One way to get strong typing when creating Node.js application is to use something like MicroSoft's TypeScript (http://www.typescriptlang.org/) which is a superset of JavaScript that supports strong typing (and classes, modules, and interfaces) and compiles to JavaScript.

Cheers,
Mike
Thanks everyone! Good to be here! Hopefully we can be of help!

Cheers,
Mike

robyne vaughn wrote:Hello,
I tried to look at the sample chapters, but the links push you to an opening page, and on a quick glance, I didn't see any sample chapters to download.
I am new to mobile and web app development. I'm still trying to determine the best tools to use and best practices. There are so many options. For the moment, my team has started with Eclipse. We're using some jquery mobile and trying to figure out phone gap. We have developed a couple of Android apps which use a restful web service and pull json data from our DB2/LUW database. We expect to build an Apache Tomcat web server after we reach a certain point. For now, we're serving from Eclipse/tomcat.

In our googling around about how to do what, we cross trails that point to Node.js, but since we have started down a path, we hate to add still one more thing to learn, especially since we're still in the "feeling our way through" stage.

Can you tell me what is Node.Js's primary purpose, what need it fills and why we should consider using it?

Then, is your book good for the novice?

Thanks,



Hi Robyne,

There are two sample chapters available: chapter 4 (http://www.manning-source.com/books/cantelon/Node.jsSample04.pdf) and chapter 8 (http://www.manning-source.com/books/cantelon/Node.jsSample08.pdf). Let me know if you have any trouble downloading them.

Someone who's new to web application development might find our book frustrating. I'd say our book is a good fit for anyone with a good working knowledge of JavaScript ("Secret of the JavaScript Ninja" is a great book on this topic) and experience developing web applications (in any language).

As for Node's primary purpose, Node was designed to handle DIRTy (data-intensive, real-time) applications: so applications that need to move data round quickly like web applications, online games, chat applications, voice-over-ip, etc. Node is good at handling a lot of simultaneous connections in a way that minimizes memory and CPU use. If you're building something where that's the challenge, then it could make sense to consider Node.

Cheers,
Mike

Federico Kereki wrote:Hi! What's the current (better?) way of hot patching some JS code in use at a node.js server? With Apache, I can just change a PHP file, and from then on, it will be used, but with node.js, it doesn't work that way. I've read about several possible methods, but no one seemed to be as simple as Apache's. What would you recommend?



Hi Federico,

With Node it's a bit tricker than with PHP/Apache. The way it's mostly done is having a file watcher running in the background that checks for flle changes and, when a file has been found to have been changed, restarts the server. There are a number of watcher utilities out there... "forever" (https://www.npmjs.org/package/forever), created by the folks at Nodejitsu, is one that's been around for awhile and will also restart your server if it crashes.

Cheers,
Mike