As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm a web apps developer, I use for most apps PHP/MySQL with APC enabled, caching technologies: Memcached is my favorite one. Sometimes I use Percona MySQL version.
I'm new to NodeJS and I want to build my own web app using it. It's a SaaS working with Facebook, Twitter and Instagram APIs. I read a lot of good things about it.
What I need to know about Asynchronous JS Programming before starting the app?
Is there any performance advantages for Asynchronous Programming?
Is there any live examples, graphs with the difference between Async/Sync?
It doesn't block.
Let's compare with PHP:
<?
readfile('some/large/file.bin');
?>
This might take a while. And while PHP reads the file, it won't be able to do other stuff (like answering other requests).
The same thing asynchonously (using node.js):
fs.readFile('/some/large/file.bin', function callback);
Node does the reading without blocking the current process.
So in conclusion: while the synchronous way blocks the process until the result is available, the asynchronous method has the advantage of doing other stuff, even before the readFile callback got fired.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
i have a few questions about real time applications.
Comet vs Websockets, what is better? For example checking the online users, chat etc.
How does running any of these processes (comet server, websockets) affect normal server functions performance (Page load, php, operating with databases)?
How can i actually install websockets / comet to my hosted server and not just having it on localhost.
Im sorry if some of these questions are stupid, but im quite new to this, so i have to start somewhere :)
Once again, this is a question that is only answered by "it depends on what you're doing". Also, a simple SO and/or Google search will give you several results that I suggest you should read for a better in-depth view.
Both techniques will deliver data "real time", and both can be used to check online users, check etc. Also, Comet is an umbrella term and there are many "Comet Servers" that use WebSockets as the transport mechanism when possible. Comet servers don't just use AJAX, XHR Long-Polling, Forever-Frame etc. They now use WebSockets and fallback to other transport mechanisms where required.
Depending on what kind of back-end technique you're using, ASP.NET SignalR is pretty awesome too.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I was wondering if it is possible to use the WebSharper compiler to write Node.js applications in F#. Are there any resources available that could show me how to do this? Are there any good reasons not to try to do this?
[I would post this as a comment, but it got a bit too long...]
Here is another good reason not to do it - F# agents and asynchronous workflows provide a concurrent programming model that is in many aspects much better than what Node.js provides. For example:
it gives you both concurrency and also true parallelism so you can write code that does not block the system when it needs to do some work using the CPU
asynchronous workflows provide easy way to handle exceptions and handle resources
(you can use try .. with in asynchronous (or event-based) code)
the agent-based programming model gives you a great way to store state
If you can use F# to write your server-side application, then you can as well us the powerful abstractions it providers. See Server-Side Functional Programming for a brief introduction. I also did a talk F# on the server-side which has been recorded and discusses the same topic.
This is not necessarily a reason why not to try this. Trying this might be fun and if you like F# language, but want to use in Node.js environment, then it would be very useful to have this.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I hope this question is not too general, but i haven't found any good tutorial on how to do the transition from standard javascript / jQuery code to modular / tested code.
Mmy new task is the complete refactoring of the javascript of our wordpress plugin.
Our current code is standard jQuery code, thrown all into a file, with checks on the existance of dom elements to understand on what page we are in and attach the correct event handlers.
My goal is simply to write more manteinable and clear code, and introduce tests in the process.
My approach would be:
Try to modularize code in separate files (one file for each page) and use require.js to load only the required code.
write some tests with jasmine/sinon and try to adapt the esisting code so that the tests pass
Have you got any other suggestions/best practice?
Can you share some example on how you approached similar tasks?
I was thinking about bringing in an mvc framework but if i can stick to standard jQuery code i think it's easier for the development team because it doesn't add complexity
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I just recently got interested in how search engines work, and I found out that they use "bots" or "webcrawlers". I immediately started wondering about how do these things work and I wanted to create one! So, first of: how do you make a program that requests a page from a server? It would be awesome if you gave me a simple example in JavaScript (I'm running it as a normal scripting language using Node). Next, is there a Node module that let's me interpret HTML? Create a DOM for me so I can cycle trough all the links and so on? Correct me if I'm wrong but I guess it's done like that... Any examples in C++, C or Python are warmly welcomed as well, although I'd prefer JS or Python because I'm more familiar with high-level scripting languages.
Getting HTTP pages: node http.get (example is there)
DOM documents: jsdom (also includes examples)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
If I'm developing a client side application with heavy load, what is the most appropriate choice of Ajax framework?
I'd recommend you the JQuery. It is not just an ajax framework, it is more than that.
Client side? jQuery. Server side? Depends on your environment. Also, AJAX is not a framework per definition, but there are various libraries like jQuery which will ease the pain when using AJAX.
AJAX exists just to send some data and recieve some data from your server or some other site without forcing you to do a whole page reload. That's all about it in the nutshell.
If you're looking for a technology that will automatically place widgets on your site that use AJAX, that's a whole different story...