Difference betweeb Wamp, node JS and express? - javascript

I come ask my question here not because i did't found the answer but rather because i don't understand them...
Currently I try to do a website with HTML / CSS and basic JS but I need a database
And when I see different tutos in YouTube or other I always see Express, node...
Yes, I already use NodeJs but not Express, I only know him by name
And i'm lost, and i didn't know what to do to use mySQL with JS
I know Javascript is a front-end language and with NodeJS we can use it in back-end but...
In this case, with mySQL, what's difference between Node, Express and Wamp ?
All answer that i have is : *"Some of them are servers but not really a server, but more or less a server"
Yes, i didn't understand !
So can you please explain me what's three of them ?
Wamp simulate a locale server
But express too... ?
And node JS don't need to use a server... ?
If i use expressJS with Wamp will it be the same on a VPS ?
Please I need an explanation

WAMP is an abbreviation for Windows+Apache+MySQL+PHP environment. It is also the name of a package that lets you easily install Apache, MySQL and PHP on a Windows machine. Apache is a powerful web server software, which you can still use in front of Node, but don't have to (as a beginner, ignoring Apache is fine). PHP is a serverside programming language, but you are already decided on using JavaScript/Node.js, so you don't need it. For your purposes, simply installing MySQL instead of WAMP makes more sense.
Node.js is a serverside runtime for JavaScript language. It is what lets you run your JavaScript code on a server computer, along with some essential libraries that extend JavaScript with functions that it does not have built-in, such as the ability to read files, or to accept incoming connections (like HTTP requests).
You could make a web server purely in Node.js, but it would be a lot of hard work. Express.js is a framework (basically, a big library) you can install that already does a lot of that hard work for you, letting you focus on writing your web application's logic and not have to write low-level code that would make up the guts of your web application.
In the same way, you could theoretically write your own code to communicate with MySQL, but the mysql library exists so you wouldn't have to.
So if you are making a serverside JavaScript web application, you would typically start with installing MySQL and Node.js, then use npm (Node.js package management tool) to install Express.js and mysql packages. Apache is optional, so don't worry about it now; PHP is entirely superfluous.

Related

To what extent does Node.js replace Apache2?

I'm in the process of updating an old piece of software (running Apache2, PHP, MariaDB, HTML, CSS) to use a React frontend. I'm completely new to React and I'm between beginner and intermediate with vanilla JavaScript so I've been researching this the last few days.
My confusion is about backend with a React web app. If I want to keep the existing architecture in place aside from frontend, will I be able to painlessly have my apache2/php integrate with my React app? And I'm also confused about the role of Node.js. Some places describe it as just extra libraries, and some places describe it as an Apache2 replacement. I think the source of my confusion is that so far in learning React and Node it always requires me to run npm start. Which feels very much like running a server like apache.
I guess in a nutshell my question is - what will my project structure look like when using a React frontend? Will I have just javascript files and host that on Apache? Or will this need to be run on Node? And where does my PHP fit in, will this need re-written in JS?
EDIT : For further clarification. I'm asking about the differences between a Node.js server and Apache2 server. That's the focus of my issue. Additional points of discussion to help me understand the problem are how PHP and React fit into all this, and whether my understanding of Node as an Apache-like tool is correct. Hopefully that makes this question less broad
For the purposes of building a React app against an existing set of web services: Node.js is used only at build time. It is used to execute the build tools which generate static files which are deployed on your Apache HTTP server.
Node.js is also used to run the development server for the React application that hot reloads it as you save changes to the source code.
Node.js can be used to run an HTTP server which hosts web services written in JavaScript (which which case it either replaces Apache or sits behind Apache (which is configured to act as a reverse proxy) … but that isn't your use case.

Does node.js replace tomcat?

If I can build a server with node.js do I need tomcat?
Excuse me, I'm a pretty new to it and I'd like to understand this base concepts. Thank you so much!
No, you do not need Tomcat if you are using Node. You could run one or the other, or both at the same time as long as they are not trying to listen on the same port. Here's why.
Tomcat is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies.
Basically, this means that Tomcat is designed specifically to be a web server.
Node is a JavaScript runtime built on Chrome's V8 JavaScript engine.
Basically, this means that Node can take JavaScript code, optimize it, and give the code access to things that aren't normally exposed to JavaScript code that is run in a web browser, like direct access to the file system. JavaScript is similar to Python, lacking strict data typing, but unlike Python which is an interpreted language, Node reads JavaScript and turns it into machine code which does not require it to be interpreted before it is executed (so it can be much faster).
Node happens to be good for developing servers especially when using frameworks like Express, sort of like Rails for Ruby, or Flask for Python, but you can write anything you want, it doesn't have to be a server.

Whether to Use Tomcat or express for Angular project

I am working on one application which has rest services and these rest services are running on tomcat server.
I have one more tomcat running which has only UI part.I have built this UI in Angular. I am creating a war out of these Angular related files and deploying in this tomcat, which is accessing other tomcat's rest services.
I have two options of running my UI code, I can either use tomcat or use express js, but I am not sure which to use.
As I am comfortable with tomcat, so I am using tomcat only but if using express on node platform is more beneficial then I should be using that.
Could anybody please explain the pros and cons of using express js over tomcat for my UI project.
Overall it doesn't really matter. Both tomcat and NodeJS/express can do the job.
The benefit of NodeJS is that you are using the same language (javascript) on the front-end and on the back-end.
The benefit of Java/tomcat is its maturity. There's a lot more tools, IDEs, etc for Java than for NodeJS code.
There's also the difference between a scripted language and a compiled language:
Scripting Languages vs. Compiled Languages for web development
If you are trying to get things done, I would stick with Java/Tomcat since that is what you already know. You don't want to waste time figuring things out.
On the other hand, if you you have plenty of time to complete your project and have time to learn, I would recommend going with Express. It's a framework with growing popularity and it's always nice to be able to write the whole app in one language (aside from CSS/HTML).
Express is overkill to serve static files and slower than a native http server. Even Tomcat is overkill imho (it's not a simple web server). If you're looking for a light and fast way to serves static files, there is nginx: benchmark here. Or you could stay with Tomcat, it's already setup and faster than Express.

How to run JavaScript as a server side script language on SourceForge.NET?

As I known, JavaScript is a client-side scripting language. But, some days ago, I have heared that JavaScript is a server-side script language.
I don't understand about it... To know it, I have search Google, and I known that Node.JS can be used as a server-side script language. I have run some script with Node.JS (on Windows XP) successfully.
So, I tried to run it with a real server... I have posted all script (which are written in Node.JS) into SourceForge.NET. But, I don't know how do run it?
Can you help me to answer: "Does SourceForge.NET supports Node.JS? If can, please show me how to run with this server?".
I tried to run it with SourceForge.NET for only fun.
Node.js is a means of running JavaScript programs. It is commonly used to write HTTP servers.
If you have written code to use Node.js then you need to run it with Node.js for it to work.
If you want to involve some other kind of server then you would have to proxy requests made to it onto Node.js (e.g. with Apache's ProxyPass directive)… but that typically eliminates the reasons that people choose to use Node.js in the first place.
If you want to use Node.js in production then you will usually need to be hosting your site on a VM or a dedicated server. Shared hosting won't usually give you enough access to run Node.js.

Running a js code on the server

I have a third-party javascript code which communicates with their web server and which I want to run periodically on the server. I'm not that familiar with NodeJS so that's why I don't know exactly wether it'll help me or not, although I've read some articles about that topic. The task is run that script on the server exactly as it were in a browser on the client. Is it possible to do with NodeJS?
The task is run that script on the server exactly as it were in a browser on the client. Is it possible to do with NodeJS?
Very nearly, yes. What you're looking for is a "headless browser" with a JavaScript API and/or NodeJS module. Specific recommendations are not what SO is for, but that's the term to search for, and I'll note that both jQuery and Sizzle projects (closely related) use PhantomJS. (I haven't used it directly, just as a byproduct of contributing to projects that do.) It's not a NodeJS module (it has to run in its own process), but you can launch it from Node as a project and then interact with it.
Then you load whatever assets you need into the headless browser, including the JavaScript you need to run.
Needless to say, you need to really trust the source of any code you receive and run on your server. :-)

Categories

Resources