As php is server-side - for a website, the visitors of which would form a network of distributed computers that would solve problems collectively - could php not be used to off-load processing power for the problem onto the browsers of the clients?
-
I've heard about the differences between php and javascript, and although they are not directly comparable (one being more of a server-side language and the other client-side), it seems that php generally wins out in that it apparently can do anything that javascript can do (although occationally it might take longer to program) and more. Two disadvantages (at least as they appear to me) of javascript seem to be that you need to encrypt the script to make it difficult to steal, and also that javascript may already be turned off in some browsers. However with javascript being run inside the browser of the clients visiting the website, it sounds an effective way of offloading processing power for performing certain tasks that may otherwise have to be done by the server. Is php capable of performing in the same way? If not this seems to be a huge benefit to using javascript, releaving pressure from the server. Is this right?
-
Answer:
The short answer is "yes." The less short answer is "yes, technically that would work, though I would not recommend it" The long answer is that if you're looking to create a distributed computing platform, any problem that requires that sort of engineering could probably be solved in a better manner. For non-complicated problems, it's better to just let the server process it. For just about anything you're doing in PHP, your scalability isn't going to be bounded by the complexity of the code so much as it will be bounded by number of users or database access or some other contributing factor that will only get worse if you try to offload processing to the client. But let's say that you're trying to do something complex in your code and offloading to the client makes sense. At that point, you might as well use real processing power, which you're not going to get in the browser. Any current javascript engine implementation you're going to find is inappropriate for large scale processing. They're all relatively slow. They work just fine for their intended use, so I don't want you take this as a slight on Javascript, but if you were to try to do anything exciting, you'll find that you'll want better tools. This is why God invented C/C++. Take a look at BOINC: http://boinc.berkeley.edu The BOINC client is written in C++ and was developed by scientists to handle parallel problems. Poorly written C++ will run considerably faster than well written Javascript in about 99% of all possible scenarios. And not like 20% faster or something, but orders of magnitude faster. This is just a function of how/when each are compiled and the level of abstraction away from the hardware. In many cases, C++ is somewhat abstracted away from the processor, but not to the point that it runs in a virtual machine running in a web browser like javascript is. You get additional benefits to building your client side software to run in the background of client machines as standalone programs, such as you don't have to worry about the user closing the browser or the browser crashing, you don't have to worry about different results stemming from different javascript implementations, and did I mention it's going to be fast? It's going to be fast. Now I've sort of migrated away from the original question about whether this could be fed by PHP on the server side, and the answer is "probably yes". I'm not entirely sure what sort of processing you're trying to do or what sorts of problems you're looking to solve. Given that all you really need is an API, it doesn't really matter what language the backend is written in so long as the server can handle the traffic and keep up with the responses. If the server is feeding the clients chunks of work that require processing to define/build/package, then you might want to choose your backend architecture appropriately, at which point you would have, say, a C/C++ daemon building work packages and a PHP driven server assigning them and handling communication with the clients.
Christopher MacTaggart at Quora Visit the source
Related Q & A:
- What risks do I have to consider when encrypting server side as opposed to client-side?Best solution by Information Security
- Why do I get the error "A network error occured while connecting to the server?Best solution by Yahoo! Answers
- How do plugins identify what type of server a website is running on?Best solution by Stack Overflow
- What are tips on attracting visitors to a website?Best solution by 99u.com
- Can a website use .org if it is not a non-profit?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.