SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 28

Thread: I apologize for this question, but i cant figure it out atm

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I apologize for this question, but i cant figure it out atm

    Hello,
    I have two simple questions, for the ones that know the situation.

    1) Wich hosts are able to run .exe (or linux executables compiled with gcc/g++ or wtvr)? GoDaddy does? (You'll hit me hard for saying this but...) I like GoDaddy so far, its true they have ads and garbage, but they're cheap and simple to use.

    2) How can i convert to C, this PHP so that it outputs the exact same thing?

    PHP Code:
    <?php

    $html 
    '<b>hello world</b>';

    echo 
    $html;

    ?>
    My guess is:

    PHP Code:
    #include blablabla

    int main() {
        
    char html[] = "<b>hello world</b>";
        
    printf("%s",html);
        return /
    care;

    Will this output the same way as php?

    C++ would be cool too.

    Thanks!

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2006
    Location
    Gold Coast, Australia
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) You will need root access, so I would suggest VPS or Dedicated server.

    2) (Sitepoint has no tag for C) I think thats it? I have never touched C. So, good luck.
    Code Cpp:
    #include<stdio.h>
     
    main()
    {
        printf("<b>hello world</b>");
     
    }

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wackyjoe View Post
    1) You will need root access, so I would suggest VPS or Dedicated server.

    2) (Sitepoint has no tag for C) I think thats it? I have never touched C. So, good luck.
    Code Cpp:
    #include<stdio.h>
     
    main()
    {
        printf("<b>hello world</b>");
     
    }
    Hmmmm, and VPS aren't cheap, are they?

    C is very similar to PHP (or the opposite).
    I always thought that by running an executable file on any host (like GoDaddy) it would run that file and output the result, just like php does.

    So only VPSs can run EXEs?
    Is the output stream of C/C++ the same has PHP? I mean, what's the output stream of PHP?
    And the imput stream of PHP?

    when we do /phpfile.php?var1=abc
    we can access that var by $_GET['var1'];
    but are there other ways in PHP to get var1? So i can understand better how PHP handles them?

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2006
    Location
    Gold Coast, Australia
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP is a C based language. The syntax is similar. When I said I have not touched C, I meant I have not literally touched it, not I have not heard of it =p

    If you are proficient at C++, why not write a PHP plugin? Might be alot quicker.

    Is the output stream of C/C++ the same has PHP?
    PHP input/output streams c++'s std(in|out|err) are FILE *s, i.e. you use fprintf to write to them, c(in|out|err) are streams where you use <<; php's streams are almost never used, only for cli, and i think you use fprintf, but with php://std(in|out|err) as a string (i.e. quoted), not a var


    but are there other ways in PHP to get var1? So i can understand better how PHP handles them?
    Not that I'm aware of no.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know some nice VPSs? Not very expensive, but good quality? (same cheap/quality old history)

  6. #6
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,109
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Try Linode.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  7. #7
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,133
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I am not sure what you are trying to do, but why do you want to run a C script? You might also be able to make the same code through a php cli script.

    Quote Originally Posted by MakoReactor View Post
    So only VPSs can run EXEs?
    Is the output stream of C/C++ the same has PHP? I mean, what's the output stream of PHP?
    And the imput stream of PHP?
    PHP has good/ok stream support, you should read up on the manual. http://php.net/manual/en/wrappers.php.php

    The only thing I personally is missing is the ability to access files being uploaded by the stream. I.e. if we had this we could have native php upload progress bars.

    Quote Originally Posted by MakoReactor View Post
    when we do /phpfile.php?var1=abc
    we can access that var by $_GET['var1'];
    but are there other ways in PHP to get var1? So i can understand better how PHP handles them?
    Depending on how your PHP is setup $HTTP_RAW_POST_DATA might be available, if not you can use the php://input stream.

    Quote Originally Posted by MakoReactor View Post
    Do you know some nice VPSs? Not very expensive, but good quality? (same cheap/quality old history)
    All depending on what your planning to use the VPS for, you might want to shell out a little more money. The problem with cheaper offers is usually the support, reliability and speed.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRedDevil View Post
    I am not sure what you are trying to do, but why do you want to run a C script? You might also be able to make the same code through a php cli script.


    PHP has good/ok stream support, you should read up on the manual. http://php.net/manual/en/wrappers.php.php

    The only thing I personally is missing is the ability to access files being uploaded by the stream. I.e. if we had this we could have native php upload progress bars.


    Depending on how your PHP is setup $HTTP_RAW_POST_DATA might be available, if not you can use the php://input stream.


    All depending on what your planning to use the VPS for, you might want to shell out a little more money. The problem with cheaper offers is usually the support, reliability and speed.
    I want to convert almost all my php to C/C++ so that i can compile it and run it normaly, as php would. Making the requests faster.

    PHP is always parsing and stuff (scripts disadvantage), and i need to spare the processing effort on my site, so compilation would solve that.

    unfortunatly, i dont know how to simulate php at 100&#37; with C/C++. I know there are some compilers from PHP to C out there, but nothing's better that having full control of the conversion.

    Being PHP, C based, can turn this conversion easier, i hope.

    VPS by other hand, are very, very expensive, i wish there was another way to make this run in normal hosting servers. Ill test in GoDaddy normal hosting to check if it does run exe's, as soon as i can.
    Because they make alot of effort making me choose from a hosting service using Linux CentOS ou Windows, and i thought that the operating system was only useful if they were talking about VPS, but no, they make us choose the OS of a normal, pre-configurated, web hosting service, why? If it doesnt run exe's, we cant configure php.ini and .htaccess and so on, i dont see why would they make such effort to make us choose.


    Ps. Maybe i could use python for this, i dont know, but i dont have much time to learn the python ways...
    Ps2. actually no, python is a script like PHP, no slowlyness problem solved by it.

  9. #9
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you actually having performance issues? Have you done any profiling? Would pimping your server be cheaper/easier than porting your code? PHP might be slower than compiled code, but does it actually make any real difference for your app?, ie if a request takes half a second to get to and from the server, and php takes 5ms vs c taking 0.5ms, then there is no significant difference.

    If you really want to use compiled code, you could move to C#.net, or Facebook has released hiphop, which converts PHP to compiled C++.

  10. #10
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,133
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I am sorry, but I dont really see any reasons for why you need the speed of a C application vs PHP application.

    You want to use shared hosting accounts, which means that what the application will be used for does not have a lot of traffic.

    If your having performance issues, have you as "hash" mentioned profiled where in the code the bottleneck is? Usually the bottleneck is not the PHP code, but instead a database query etc.

    To increase the performance of PHP there is also bytecode cache loaders like APC etc.

  11. #11
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRedDevil View Post
    I am sorry, but I dont really see any reasons for why you need the speed of a C application vs PHP application.

    You want to use shared hosting accounts, which means that what the application will be used for does not have a lot of traffic.

    If your having performance issues, have you as "hash" mentioned profiled where in the code the bottleneck is? Usually the bottleneck is not the PHP code, but instead a database query etc.

    To increase the performance of PHP there is also bytecode cache loaders like APC etc.
    The database is local. And yes, php runs very slowly, just because there will be a huge amount of users acessing the site at the same time, i've made stress tests, and php is slow, by other hand, C is very very fast.

    My only problem now is, how to make exe's requests, for example, being mainfile an executable, certainly i cant do this:

    www.mysite.com/mainfile?var=1

    right?

  12. #12
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,535
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If your site/application is so popular that you're concerned about the speed of PHP then shared hosting is inappropriate.
    Ian Anderson
    www.siteguru.co.uk

  13. #13
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't need C. I don't care what your use case is, you don't need C (especially if you're running on a shared host). Facebook recently went to completely compiled code, and their unique monthly user base is a non-trivial percentage of the entire world's population.

    Your application won't be Facebook. Don't mean to be harsh, but it sounds like someone needs to talk some sense to you (and I'm not the first in this thread to do it) before you go off chasing something that's completely irrational.

  14. #14
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SituationSoap View Post
    You don't need C. I don't care what your use case is, you don't need C (especially if you're running on a shared host). Facebook recently went to completely compiled code, and their unique monthly user base is a non-trivial percentage of the entire world's population.

    Your application won't be Facebook. Don't mean to be harsh, but it sounds like someone needs to talk some sense to you (and I'm not the first in this thread to do it) before you go off chasing something that's completely irrational.
    Is not that simple.
    I like to learn new things. That's why i didn't use a pre-made compiler.
    I wanna know everything about speeding up websites. I want to know it all, my site is not online right now, but the code is very complex and slowo operate, and yes, im using logaritmic performance order in almost every algorithm i have there.

    My site is about a game, like Ogame, or Tribalwars, etc... And as you see, they require alot of resources to keep it cool. So will i.

  15. #15
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MakoReactor View Post
    Is not that simple.
    I like to learn new things. That's why i didn't use a pre-made compiler.
    I wanna know everything about speeding up websites. I want to know it all, my site is not online right now, but the code is very complex and slowo operate, and yes, im using logaritmic performance order in almost every algorithm i have there.

    My site is about a game, like Ogame, or Tribalwars, etc... And as you see, they require alot of resources to keep it cool. So will i.
    There is no change you could make in C to speed up your site sufficiently so that you would make up (over the entire life of your website) the amount of time you've spent posting in this thread, much less the amount of time spent recoding the application in C.

    If you *really* need a compiled language, something like C#.NET running on a windows IIS server would be a good choice, or something running Java.

    The reason you don't see people writing webpages in C is because C isn't a web design language. Stop trying to use the wrong tool for the job.

    Edit: You'd be much more likely to get good responses if you posted a new thread asking us to help you optimize your code. I have a feeling that if it's so slow it's unusable, you've got a problem in your design somewhere that you're just not seeing.

  16. #16
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SituationSoap View Post
    There is no change you could make in C to speed up your site sufficiently so that you would make up (over the entire life of your website) the amount of time you've spent posting in this thread, much less the amount of time spent recoding the application in C.

    If you *really* need a compiled language, something like C#.NET running on a windows IIS server would be a good choice, or something running Java.

    The reason you don't see people writing webpages in C is because C isn't a web design language. Stop trying to use the wrong tool for the job.

    Edit: You'd be much more likely to get good responses if you posted a new thread asking us to help you optimize your code. I have a feeling that if it's so slow it's unusable, you've got a problem in your design somewhere that you're just not seeing.
    No, the page isnt slow, its very fast indeed. I tried to reduce the number of requests (one imagem for all, only one CSS file, some recursive code generated by Javascript (client-side job to spare the server and speeding up html transference), super efficient algorithms, etc...) but i think more can be done.

  17. #17
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But still, using remote servers to do the job, i still get 0.003ms of time generating the page. That's awful for a website that may have a huge number of requests per second.

    If i have 1000 people using it at the same time, it will take 3 seconds to load!!!

  18. #18
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MakoReactor View Post
    But still, using remote servers to do the job, i still get 0.003ms of time generating the page. That's awful for a website that may have a huge number of requests per second.

    If i have 1000 people using it at the same time, it will take 3 seconds to load!!!
    I don't think you understand how web servers work. Is it .003 seconds or milliseconds? If it's milliseconds, then your math should be that it will take 3 milliseconds to load with a thousand users (which isn't true).

    In reality, those requests are handled in parallel, and because of the incredibly short PHP processing time (3 milliseconds is plenty fast), you'll see minimal degradation due to simultaneous requests.

    At a .003 second processing time, you're seeing more overhead from the network than the server: it takes almost 50 times as long as that for the average web server to even make a TCP connection.

    At this point, I'm starting to wonder whether or not you're just trolling.

  19. #19
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by MakoReactor View Post
    If i have 1000 people using it at the same time, it will take 3 seconds to load!!!
    If you have 1000 people doing simultaneous requests, you have millions of visitors a day. Which means you should be earning enough cash to throw a couple of extra servers and a load balancer at your site.


  20. #20
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SituationSoap View Post
    I don't think you understand how web servers work. Is it .003 seconds or milliseconds? If it's milliseconds, then your math should be that it will take 3 milliseconds to load with a thousand users (which isn't true).

    In reality, those requests are handled in parallel, and because of the incredibly short PHP processing time (3 milliseconds is plenty fast), you'll see minimal degradation due to simultaneous requests.

    At a .003 second processing time, you're seeing more overhead from the network than the server: it takes almost 50 times as long as that for the average web server to even make a TCP connection.

    At this point, I'm starting to wonder whether or not you're just trolling.
    No im not trolling.

    Yes you're right, 0.003 milliseconds.
    Another pro of compiling my PHP, is that it will prevent any kind of code stealing.

    Anyway, if i go for shared hosting, and dont compile my php code, can i, if needed later, compile everything, and migrate to a VPS easily? Or if im thinking about that possibility, i should do it at the very start of the project?

    Is any shared hosting compatible with sqlite3?

  21. #21
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Immerse View Post
    If you have 1000 people doing simultaneous requests, you have millions of visitors a day. Which means you should be earning enough cash to throw a couple of extra servers and a load balancer at your site.

    thinking that way, if i earn 1000$ of salary each month, i could pay 999$ for someone to do my job. :P

  22. #22
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,133
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MakoReactor View Post
    thinking that way, if i earn 1000$ of salary each month, i could pay 999$ for someone to do my job. :P
    You will not even be able to have thousand users doing a request at the same time on a shared host.

    Even on a dedicated server you might get problems there, all depending on your pool of workers. The web server can serve X users at the same time before it will reject requests due to being overloaded.

    As mentioned, if you reach a point that you will have thousand real users at the site at any time you have a successful website and should have no problems to pay for a few dedicated web servers and use load balancing.

    Do yourself a favor, finish your application in PHP first, then if its as successful as you hope/believe then expand and do the required updates.

    As SituationSoap mentioned, I am starting to believe your just doing some trolling, at best its pure ignorance on how things work together.

  23. #23
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRedDevil View Post
    You will not even be able to have thousand users doing a request at the same time on a shared host.

    Even on a dedicated server you might get problems there, all depending on your pool of workers. The web server can serve X users at the same time before it will reject requests due to being overloaded.

    As mentioned, if you reach a point that you will have thousand real users at the site at any time you have a successful website and should have no problems to pay for a few dedicated web servers and use load balancing.

    Do yourself a favor, finish your application in PHP first, then if its as successful as you hope/believe then expand and do the required updates.

    As SituationSoap mentioned, I am starting to believe your just doing some trolling, at best its pure ignorance on how things work together.
    Whatever you like most.

    pay for a few dedicated web servers and use load balancing
    If i reach that situation, how can i do that load balancing? My only experience with servers is wamp and shared hosting...

  24. #24
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,133
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MakoReactor View Post
    If i reach that situation, how can i do that load balancing? My only experience with servers is wamp and shared hosting...
    Countless books has been written on that subject and on how to administrate servers in general. You will either need to buy a bunch of those or take a few courses to learn how to properly do it. Or you can do as most successful businesses would, they "outsource" the work to a company that specialize on server management.

    You can also base your application in the "cloud", but in the long run that will be more expensive than running your own servers. It will be a lot more flexible since you can add/remove servers instantly, but that flexibility cost.

  25. #25
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRedDevil View Post
    Countless books has been written on that subject and on how to administrate servers in general. You will either need to buy a bunch of those or take a few courses to learn how to properly do it. Or you can do as most successful businesses would, they "outsource" the work to a company that specialize on server management.

    You can also base your application in the "cloud", but in the long run that will be more expensive than running your own servers. It will be a lot more flexible since you can add/remove servers instantly, but that flexibility cost.
    Hmmm, what books would you recomend for managing N servers, and their respective requests load?
    Im a computer science and engeneering student, i should be able to handle some of those things, but im still fresh in my server experience, but please dont give me a book from the scratch, i would like some that would go straight to the point, i can learn the basics while i learn what i need. Just need an advice

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •