Does node.js replace tomcat? - javascript

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.

Related

Programming language of a website

If I program a website in a language, say JavaScript. Then I make this website public like an usual website. Will people who use my website be able to tell what language it is programmed in?
Code running in a browser is always discoverable by a visitor. Code running on a server may not be discoverable.
If you mean using JavaScript only on the server via NodeJS or similar solution, then no, there is not anything that will inherently expose the fact that you're using JavaScript on the server. Some languages whose filenames typically end in a known extension, (e.g. .php, .asp) may reveal the server-side language. But it's also easy for you (as the developer) spoof this if you wanted to for some reason.
However, any code running client-side can easily be explored by most browsers' developer tools. They even typically offer reformatting of minified HTML and JS.

How to make Python to be Client-Side?

I know that Python can be a server-side language but is there a way to make python act like a client side language (like javascript) i just want to try it out if its possible thank you
You can compile your python to javascript with Pyjs.
Note that if you use Skulpt, Skulpt will NOT let you create full websites or actual javascript code that can run inside browsers. For this, you must use Pyjs. Pyjs essentially transforms your Python code into actual Javascript, so you can run the resulting Javascript in any browser, or host it as a website.
Try http://www.skulpt.org/ it is an entirely in the browser implementation of Python.
Or you could try this: http://pypyjs.org/.
It uses the PyPy python interpreter, compiled for the web via emscripten, with a custom JIT backend that emits asm.js code at runtime.
I think you want online python compiler to test the code/snippet that run on browser, try repl.it
I am guessing you know python and want everything to be in python. Well dont do it. Seriously dont even use that skulpt solution that was posted. Not because it wouldnt work. Its more because browsers only understand Javascript as a front end program. No other language is understood. If you understand python, using javascript should be a piece of cake and you might as well start that. If you really want to use python, atleast transpile into javascript using http://pyjs.org/
Pyodide gives you a full, standard Python interpreter that runs
entirely in the browser, with full access to the browser’s Web APIs.
article
https://hacks.mozilla.org/2019/04/pyodide-bringing-the-scientific-python-stack-to-the-browser/
download
https://github.com/iodide-project/pyodide

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.

jQuery - run perl script (all standalone)

I have script Perl and for the moment this script is called with a simple batch file.
To make this interface more attractive, I'm looking for a language for create a GUI.
My first idea is to use jQuery/jQuery UI.
Before starting to learn, I want to know if is it possible to run a script perl with jQuery(UI).
fyi, I haven't Web server all code is standalone.
Of course, I'm interested if you have an idea for another language.
Thank's for your help.
jQuery is a JavaScript library for use in web pages. The primary way for JavaScript in a web page to interact with a Perl program is through HTTP (typically by using the XMLHttpRequest object to make an HTTP request). The HTTP server is responsible for running the Perl code (e.g. through PSGI, FastCGI, mod_perl, CGI or having a server written in Perl in the first place).
Without a web server, it isn't possible for a typical environment.
(There are exceptions, but they usually involve the browser being driven by Perl using something like Selenium).

Integrating ECMA Script into a C# program, what is the fastest technique?

I'm trying to execute JavaScript in a C# program, and I'm trying to determine:
Would it be better to create a state machine for JavaScript, or should it be compiled into MSIL before executing it?
I'm really looking for techniques rather than solutions. Some attempt to compile the JavaScript, there by treating it as a programming language, others use a state machine and treat it as it was meant to be : a scripting language.
Any documentation on the methods used for executing is welcome also.
The easiest way to run JS in a C# program is to use one of the existing .Net JS runtimes: IronJS, Jurassic, and Jint. If you're interested in adding another .Net-based interpreter to the mix, examining their code is where I'd start; If you're embedding JS in your program then using a preexisting one is probably the way to go.
You haven't explained your scenario - how much javascript, how often does it get executed, how often does it change, how closely integrated it needs to be with the C# logic, and so on.
If it rarely changes, then it may be smart to compile it into MSIL via one of the alternatives.
If it changes "constantly" then it might make sense to stand up a JS compiler and send it JS as necessary. It's something like a REPL for Javascript, that you'd use programmatically. Node.js offers a server that can do REPL operations; it could listen on a port, you send it JS to evaluate, and it sends back the result. There's a free w3sockets component that could be used from cscript.exe to do something similar: for example you could build a "host" Javascript shell that listens on a socket, executes the js it receives, then sends back the result.
If it needs to be closely integrated with the C# code, then you'll have to be smarter about this. One way to do it might be to host the JS in a Windows Script Component and have the C# code invoke the JS logic via COM. You can also do the converse - have the JS host invoke the C# layer via COM to gather input and deliver results.
EDIT
A better way is to use the IActiveScript stuff - this is the official way Microsoft makes it possible to host scripting within an application. There's a winforms example published here.
OR better, see parse and execute JS by C#
Using that code I put together a demonstration of how to parse and invoke Javascript from a .NET app, using IActiveScript.
You can download a VS2010 project for this app here.

Categories

Resources