admin管理员组

文章数量:1352828

Can I write my web-site only in JavaScript being sure that my code is concealed from anyone? In this respect, is Node.js, like Apache, can be given access to through an Internet-provider?

Can I write my web-site only in JavaScript being sure that my code is concealed from anyone? In this respect, is Node.js, like Apache, can be given access to through an Internet-provider?

Share Improve this question asked Oct 15, 2017 at 20:36 Maksym DudykMaksym Dudyk 1,1731 gold badge16 silver badges18 bronze badges 3
  • Have you read up on how NodeJS works? – Sterling Archer Commented Oct 15, 2017 at 20:39
  • I read some here and there. Alas. You see, they say JS can be used as a server-side language. As well as PHP is. With PHP, though, I need not bother installing Apache on my puter. All I need is to upload my code on the web host. And note, doing so I do need to be an expert in Apacher. – Maksym Dudyk Commented Oct 15, 2017 at 21:15
  • Now I understand that the code written in JavaScript can actually be concealed form viewing (this is what I had asked) if it is writting in Node.js on backend. This is why I find the answer of Obsidian Age below incorrect. – Maksym Dudyk Commented Jul 2, 2021 at 14:00
Add a ment  | 

3 Answers 3

Reset to default 4

The answer to both of your questions is yes.

Node.js can pletely replace Apache (assuming you are willing to re-write all of your PHP as JavaScript). If you have your Apache running in reverse-proxy mode between your server and client, you can even handle some requests in Node.JS while handing others in PHP. This will allow you to maintain original functionality while changing the code out, and also allow PHP to handle more mundane tasks.

While you cannot prevent raw JavaScript from being read through any means of obfuscation, you can prevent people from reading your code by note making use of standard JavaScript at all. You can use a NativeExtension for Node to add an extension handler for encrypted JavaScript files:

require.extensions[".jse"] = function (m) {
 m.exports = MyNativeExtension.decrypt(fs.readFileSync(m.filename));
};

require("YourCode.jse");

This will convert your JavaScript code to a .jse, which you would then package for production. Considering the encryption is done inside the native extension, the encryption key wouldn't be revealed.

Hope this helps! :)

Yes, you definitely can. It may, however, take a while to transition existing code, and if this is for a corporate institution, you'll have to ask your coworkers and your boss/supervisor. Good luck, and remember, always document your code in JavaScript (no types) all languages.

  1. NodeJS is much faster: http://www.hostingadvice./blog/paring-node-js-vs-php-performance/
  2. Many more libraries: http://npmjs
  3. Only need one language for everything

Comparing PHP with another technology like Node.js which is meant for an entirely different type of task, parer must mention the difference of use-case/context in which one is suitable over others. Let's talk about in terms of a different area of execution because we can not Disgrace any of them and both have its own priority. If you talk about in terms of Application Domain.

PHP :

CMS (Content Management Systems) like WordPress, Drupal also use PHP which makes it possible to be used in creating blogs, websites, e-merce sites, etc. Used in developing CPU-intensive applications like meteorology applications and scientific applications.

should be used in applications in which the client does not have to interact with the server again and again

PHP 7 is based on the PHPNG engine that speeds up PHP applications more than the previous PHP interpreter (Zend Engine 2.0). Thanks to PHPNG, your apps see up to the 2x faster performance and 50% better memory consumption than PHP 5.6.

NodeJs:

Nodejs is ideal for developing highly scalable server-side solutions because of its non-blocking I/O, and event-driven model.

Used massively in Real-time applications like chat applications, blogs, video streaming applications.

Used in developing single-page applications like resume portfolios, individual websites.

Node.js should be used for the applications which require a lot of interaction between client and server.

For some tasks, Node.js may be faster than the “standard” web server with PHP because it runs as a single thread with non-blocking IO for each connection, hence there is no memory overrun. Due to this, Node.js is useful when there is a need to process data in real-time (chats, games, video, big data streams without logic) PHP is Still alive and he has learned its lessons from Node.JS

ReactPHP enables developers to write PHP-based socket server to process requests constantly as well as Node.js does it (yes, Node.js is faster, but the fact is that PHP can also do it). The same thing with Workers (the classes responsible for running asynchronous jobs and synchronizing their results) or Amp (libraries that are used for writing non-blocking asynchronous code). Hence, it is easy to create long-running processes using PHP. Additionally, there are a lot of tools for supporting and managing these processes (such as supervisord).

So, the same tasks may be performed either with PHP or with Node.js. The question “what tool to use” is a question of personal preferences. you can use Node.js for tasks involving big data flows and PHP for tasks involving plex logic, high-load tasks, for dealing with external utilities, applications, and OS. From the scalability perspective, there are no big differences between PHP and Node.js, it is more important to consider the project’s architecture.

Dayle Rees (a Laravel Framework contributor and developer): For a long time PHP was the butt of many language jokes, but I honestly feel that it’s being not only a popular language but a powerful one. PHP7 is great. The speed boost is one thing, but having optional support for full type hinting is a game changer. We’ve also got modern tools like Laravel and Composer, breathing new life into the language and its supporting munity. With this in mind, I think it’s unlikely that Laravel will move from PHP. I think it’s more likely to gain further integration with front-end tools to provide a plete application building platform. That’s where I see it heading in terms of future expansion. I’m sure the Node will continue to excel when dealing with microservices and threaded applications.

The most important and most awaited News from PHP is, PHP is scheduled to receive a Just In Time (JIT) piler in its next major version PHP-8 (most probably in sep-2021).This is going to boom the php and it breaks all his limitation due to JIT.

Wrap up

To wrap up Both have some pros, both have some cons but the amazing thing is both are created by intellects to make the web development better. While selecting the technology the question shouldn’t be which one is better but which one can serve your project needs in a better way. Understanding your project and business logic can give you a clear idea about selecting the right technology for your project.Moreover, one more important thing to consider is the skills and proficiency of the developers using the technology, how they use them and apply to the project.

本文标签: server sideCan I use JavaScript instead of PHPreplacing Apache with NodejsStack Overflow