1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Writing a website in C++?

Discussion in 'C, C++, C#' started by seeplusplus, Feb 25, 2017.

  1. seeplusplus

    seeplusplus Power Member

    Joined:
    Aug 18, 2008
    Messages:
    517
    Likes Received:
    165
    Hi,

    I've spent the last couple of weeks developing a rather blackhat type site in PHP/MySQL and I'm pleased with how it's turned out, infact I think there will be quite a few people who might like to buy a copy, so there are two reasons for my rather unortadox question.

    A) The site is pretty simple on the back end, just a handful of SELECT statements, no AJAX or anything, BUT it'll be getting huge spikes in traffic, from around 30 hits a day six days a week to all of a sudden getting 100k hits in the space of an hour, so perhaps I could make a much more efficient C++ version?

    B) As I might indeed sell the script, why is it more developers don't use C++ (as one example) when they want to protect source code? It's not hard to null PHP code is it.

    Welcome any random thoughts :).
     
  2. Jomasdf

    Jomasdf Jr. VIP Jr. VIP

    Joined:
    Jul 7, 2012
    Messages:
    445
    Likes Received:
    156
    Occupation:
    C# dev
    Location:
    Sweden
    Home Page:
    Well, mostly because C# exists I guess. Easypeasy web developement.
     
  3. dmass43

    dmass43 Newbie

    Joined:
    Mar 7, 2012
    Messages:
    29
    Likes Received:
    5
    Most developers dont use c++ for projects like this because you would have to recompile after change. Python, php, ruby or even node js would all be a better choice.
     
    • Thanks Thanks x 1
  4. thedorf

    thedorf Supreme Member

    Joined:
    Oct 1, 2008
    Messages:
    1,223
    Likes Received:
    728
    Occupation:
    what? I gotta have a job?
    Location:
    BHW - Where else?
    Dumb, dumb, dumb.

    PHP owns the internet for tons of reasons.

    The fact that there is such a small, tiny, minute number of people doing this with any other programming laungage - like C++, C# and others (.net sucks) - should tell you something in itself - read and translate this to - almost nobody recommends this for a production system - there must be reasons why.
     
  5. Jomasdf

    Jomasdf Jr. VIP Jr. VIP

    Joined:
    Jul 7, 2012
    Messages:
    445
    Likes Received:
    156
    Occupation:
    C# dev
    Location:
    Sweden
    Home Page:
    Um.. basis for that? Sure PHP is what's going on right now, but .net is demanded more every day. Just look at what people that are hireing. Also, feel free to elaborate on why .net sucks.
     
  6. WebzSuite

    WebzSuite Jr. VIP Jr. VIP

    Joined:
    Oct 22, 2016
    Messages:
    160
    Likes Received:
    30
    Gender:
    Male
    Location:
    UK
    Home Page:
    That is not right. ASP.NET MVC C# is a king of professional big projects that requires proper best industry standards for updating, etc.

    PHP in this aspect is light years away, fairly old and doesn't change with requirements of companies, that requires full integration with their Windows systems.

    PHP has big % of market due to the costs. Most of PHP guys wouldn't be able to create anything of quality in ASP.NET MVC, cost of development is much higher and only bigger companies can justify paying extra for quality, security and performance.
     
  7. thedorf

    thedorf Supreme Member

    Joined:
    Oct 1, 2008
    Messages:
    1,223
    Likes Received:
    728
    Occupation:
    what? I gotta have a job?
    Location:
    BHW - Where else?
    Wrong. Wrong. Wrong. Total bullshit in fact.

    1) ASP.NET has a small market share - it is not half that of PHP.

    2) MVC is not a programming laungage, it is a framework description. PHP also implements the MVC model in numerous huge projects - way more than ASP.NET. Besides that fact "MVC" in NOT laungaue dependant. It stands for "Model View Controller" and represents a way to develop websites from any laungage that is mostly used in conjunction with Object Oriented Programming.

    3) Yes PHP is getting old. But the latest release, PHP7, is completely rebuilt off the latest ZEND engine and is 4 x faster than PHP5 (there is no PHP6). Beyond that you can do rapid application development using your choice of PHP frameworks and the latest and greatest, imho, is Pharaoh. Special compile required but 3 times faster than the 10 largest PHP frameworks in use today. I am now 7X faster than I was 2 years ago on PHP. This means I can run 7 times as much traffic on a given day per server than I could 2 years ago.

    4) Community. Existing open-source code. Dirt cheap complete website systems custom ordered. Plugins (well, functional code units) available. Tutorials, sample code, GitHub.

    5) Name three of your "bigger companies" that built their website with C++ or C#. I want to see this.
     
    • Thanks Thanks x 2
  8. Jomasdf

    Jomasdf Jr. VIP Jr. VIP

    Joined:
    Jul 7, 2012
    Messages:
    445
    Likes Received:
    156
    Occupation:
    C# dev
    Location:
    Sweden
    Home Page:
    Why would it be bullshit, c'mon now.. There is no absolute right or wrong here (topic was c++ after all, we are going a bit OT here).

    1, Yes, no one disagree with this.

    2, I personally was studying both PHP and .net + MVC. .net just feels more flexible and modern with the access to .net and the third party integration that comes with it. It's up to taste.

    3, Not much to argue, both are fast.

    4, These are things that will eventually catch up obviously. I think Microsofts got this under control.
     
  9. cooper1210

    cooper1210 Regular Member

    Joined:
    Aug 7, 2016
    Messages:
    225
    Likes Received:
    60
    Gender:
    Male
    Good luck programming something in C++ one of the hardest languages I've found, other than C99... Nevertheless, you mentioned that it only handles a few db connections so it could be straight forward.

    I presume that since database calls are being made, that it's a dynamic site. How dynamic is it? I.e. Does it react differently to different users and store / process user information? The reason why I ask is that you could write a program that say every ten minutes updates a set of static public html files which be so easy for the server to deliver. If your site requires more user specific info, then some form of binary module would probably be the best option;

    Just my $0.02
     
  10. hyperkernel

    hyperkernel Newbie

    Joined:
    Feb 14, 2017
    Messages:
    5
    Likes Received:
    1
    C++ is stupid to use for webpages for a few reasons:
    • Managing concurrency needs to be built by hand
    • Security is very easy to fuck up (e.g. doing string interpolation without proper bounds checking is enough to get you into trouble)
    • ORMs exist, but they are not idiomatic
    • By the time you dress up C++ to be "nice to use", you are likely looping in Boost and 20 other things with a really complex toolchain
    • ...and no PaaS supports C++ web frameworks.
    PHP is OK if you're using Laravel, but otherwise, it is an AWFUL programming language. Rails and Django win at doing this job. Look at the industry. Every startup is using one of these two frameworks.
     
  11. rootjazz

    rootjazz Jr. VIP Jr. VIP

    Joined:
    Dec 21, 2012
    Messages:
    684
    Likes Received:
    326
    Occupation:
    Developer
    Location:
    UK
    Home Page:
    Ignoring everyone in there little language flame wars and getting to the OP.

    Don't code the app in C++. First get your 100k traffic, then worry about it. If things are as simple as you say, PHP and a proper cache will handle it no problem.
     
  12. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    12,478
    Likes Received:
    11,182
    Occupation:
    CHEAP
    Location:
    DATASETS
    Home Page:
    Most of Facebook is written in C++

    They compile all their PHP to C++ and that's what runs behind the scenes.

    The main search and crawler components in Google are C++ too. Python for all the frontend stuff.
     
  13. yellowcat

    yellowcat Regular Member

    Joined:
    Aug 27, 2015
    Messages:
    304
    Likes Received:
    174
    Location:
    internet 24/7
    Home Page:
    I'ma just sit back and eat glue while the better programmers flame eachother
     
  14. whyseacreature

    whyseacreature Newbie

    Joined:
    Mar 5, 2017
    Messages:
    5
    Likes Received:
    0
    Gender:
    Male
    As far as language runtime goes, it's 27 req / per second, and most runtimes and frameworks handle it with relative ease.
    Your first bottleneck might not even be in your app's code but in database. Make sure you profile everything well first before optimizing.

    In either case, there is nothing that stops you from emulating this type of load by running another script, or using something like wrk and seeing how it performs.

    I'm 99% sure you will not need to rewrite it in C++. You will waste a lot of time fighting with things that are not relevant to your business logic, like memory management and safety. Even if you think you need a faster than php language runtime, it would worth it checking out google's Go-lang. You will get best of both worlds: close to C++ speed-wise and close to php productivity-wise. And Go is easier to distribute since your program is just a binary file.

    If you're worrying about people pirating / reselling your product, try selling it via subscription instead of giving away script or binary.
     
  15. SMM_shop

    SMM_shop Jr. VIP Jr. VIP

    Joined:
    Mar 6, 2016
    Messages:
    107
    Likes Received:
    25
    Home Page:
    I agree with it.
    But I think you can use c++ for develop some part back end, but no more.
     
  16. Renfield-Files

    Renfield-Files Junior Member

    Joined:
    Feb 13, 2017
    Messages:
    120
    Likes Received:
    57
    Gender:
    Male
    Occupation:
    IT Manager
    Location:
    Sao Paulo
    Why would somebody choose C++ over PHP?