Link to home
Start Free TrialLog in
Avatar of duncanb7
duncanb7

asked on

Node.js Vs C or Node.js Vs C++

Dear Experts,

I have done my created huge math function such as order 20 of polynomial/regression function with 10,000 data input in PHP program.
After math calculation is done , I will echo out the output
to the client browser. Since the function is huge almost
costing it  15 seconds to finish, I want to replace the math
function by other languages.

Recently, I heard javascript on server-side, Node.js,  so  
I know javascript is much easy to use as PHP coding , and I check
its speed is much faster than PHP as C

So now I try to make desicion on switch programming Lanauge on Javascript
or C or C++

But C or C++ is really time consuming to get to know everything such as
its complicated pointer structure or its sytnax

How do you think about using Javascript to do huge math function instead of
using C or C++ ?

And what is major different between C and C++ in doing huge math function ?

Or other lanaguage could handle huge math function code with good code and speed, please point it out ?

Please advise

Duncan
SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of duncanb7
duncanb7

ASKER

Yes, I check the speed in Node.js and C that is similar doing
1e10  times of addition/subtraction  math,

And yes javascript is interpreted language not complied language
but Node.js is running much faster than PHP that is also interpreted language.

Also  it can be running as background process with http request which is
the task will fire on request once it is running on system set up in advance

And Node.js emphasis on concurrent process that  is much faster  than
other language.


Anyway, I prefer to take back C or C++ because I don't want to take a risk
to try new

Shoud I use C or C++ ? which is better just for huge  math function ?

executed or Complied code should run faster than interpreted code
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am planning write a C running in PHP with exec() command

for example,

<?php

php code
....
....
test=exec("../../C/mymath order data test.csv");
file_get_content("test.csv")   //which is done by C language and save the result into a file


php code for web handling


?>
It will be faster but if you are interacting with a browser you are going to have to write it so that it can interact with the web server (using CGI or as an extension).

What you mean CGI ? php is CGI script  langauge already , right ?
I meant if you wanted to interact directly with the C program.

Given you are going to be exec'ing the prog that does the intensive math calcs - the host environment (PHP / Java) is irrelevant and should give you no performance benefit either way.

If you are going to use PHP you should have a look at the set_timelimit function (http://php.net/manual/en/function.set-time-limit.php) to ensure your script does not timeout before the math app completes.
So what you mean, please advise


Given you are going to be exec'ing the prog that does the intensive math calcs - the host environment (PHP / Java) is irrelevant and should give you no performance benefit either way.


Even max_execution_time or set_timeout is no issue at al,
you mean I don't have any benefit to run C using exec() in php, RIght ? WHy ?

Or

I need to rewrite all PHP code into C instead rather than just some math cals code
that might speed it up  by not using PHP environment or PHP slow engine, RIght ?


Please advise it in detail

DUncan
you mean I don't have any benefit to run C using exec() in php, RIght
No - definitely not. If you can write the app in C then it is the best solution for performance.

What I meant was  - if you are going to write your math intensive code in C and then launch that from a server side scripting environment - then the scripting language you use is irrelevant because it is not really doing anything. The performance is going to be dictacted by the speed of the C app.

In other words PHP launches C app vs Java launches C app vs .Net launches C App is much of a muchness.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is HipHOP similar to Zend framework or Zend php or Zend server

http://en.wikipedia.org/wiki/Zend_Framework

that also is process to get better php code optimization  from converting some part php
code in php file into C/C+= coding ?




I run command "zf  show version " that is checking version of zend framework and it showed
zend is not installed.

How I can know whether my server is already installed HIPHOP or not ?

Please advise

Duncan
Dear Ambience and JulianH


Could you reply my last post and read this new thread

https://www.experts-exchange.com/questions/28287892/HHVM-optimization-on-Linux-CentOS-to-speed-up-php-script.html

Please advise

Duncan
I have no personal experience with HipHop.
Thanks for all of reply , your attached link is helpful a lot to the issue.