If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

Redefining Website Creation: C++23 vs. PHP

Started by EQDavid, Dec 26, 2023, 01:08 AM

Previous topic - Next topic

EQDavidTopic starter

I've been considering the idea of using C++ to build websites in my native language. However, until recently, this seemed impractical. After reviewing the draft of C++23, I wonder if it now offers enough features for efficient and effective website development, especially when compared to PHP.

For those who are familiar with C++20 and have studied the new features of C++23 in detail, do you think the language now provides sufficient capabilities for rapidly developing high-quality websites with proper memory allocation? Moreover, is the transition from PHP to C++23 a viable option for creating websites? As an additional note, I'm particularly interested in whether the new features of C++23 can outperform PHP in terms of speed and performance.
Finally, I'm curious to hear from passionate PHP developers if they believe that C++23 has the potential to surpass PHP in website development.
  •  


Prefade

The release of the C++23 standard brings several new features that can significantly enhance the language's capabilities for web development. The addition of modules, concepts, and other language enhancements in C++23 provide a more structured and efficient way of organizing code, which can be particularly beneficial for large-scale website projects. Additionally, advancements in tools and libraries for C++ web development, such as Boost and ASIO, further contribute to the language's suitability for creating high-quality and performant websites.

In terms of memory allocation, C++ provides fine-grained control over memory management, which can be advantageous for developing web applications that require strict memory optimization. Proper memory allocation and efficient resource management are crucial for ensuring the responsiveness and reliability of web services, and C++ empowers developers to address these concerns directly.

Transitioning from PHP to C++23 for website development is indeed a viable option, especially for projects where speed, performance, and the ability to handle heavy workloads are top priorities. However, it's important to acknowledge that while C++ offers significant advantages in terms of performance and memory allocation, it also comes with a steeper learning curve and requires a more rigorous approach to coding practices.
As for the comparison between C++23 and PHP in terms of speed and performance, C++ has the potential to outperform PHP, particularly in computationally intensive tasks and applications that demand low-level system interactions. For websites with complex backend processing or those serving a large volume of concurrent requests, C++ can deliver superior performance when properly optimized.

It's worth noting that PHP remains a popular choice for web development, especially for rapid prototyping and server-side scripting. PHP's simplicity and ease of use have made it a go-to language for many web developers, and its extensive ecosystem of frameworks and libraries continues to support a vast array of web applications.
The decision to transition from PHP to C++23 should be carefully evaluated based on the specific requirements of the project. While C++23 brings compelling capabilities for website development, it necessitates a deeper understanding of systems programming and may be better suited for projects that demand the utmost in performance and scalability.
  •  

nHeficeseer

C++ provides all the necessary tools to develop websites. First, you can use batteries (boost), a web server (such as mongoose with a custom wrapper), a template engine (like cpptemplate), and a database. In simple cases, you can store everything in memory and then dump it to disk. For more complex cases, you can use a variety of external or embedded databases. Additionally, you can use bootstrap & jquery (or any preferred frameworks) to facilitate the exchange of json files, and you can also implement websockets.

In terms of development speed, once you get used to the process, you won't lose too much time due to interpreters. It's important to have a customized build system with libraries, an IDE that can work with remote data (e.g., QtCreator), and a machine that can efficiently handle the workload without taking too long to rebuild everything.

Despite the benefits, you may encounter challenges such as compilation times, library integration, and the need to create your own framework, which may result in memory leaks and bugs requiring additional development time. There are also cognitive considerations, as part of your brainpower will be devoted to thinking about complex programming concepts, error messages, and debugging. Furthermore, you will need to address compilation errors, linking issues, segfaults, multithreading errors, and memory leaks, which can be challenging but ultimately rewarding for those who appreciate the intricacies of software development.
  •  

dasiydan88

I can tell you that writing websites in both C and C++ is a fascinating endeavor. My projects involve using Apache HTTPD with modules of interest, along with a content module written in C++. Although C++ currently lacks templates, stl, and boost, the object semantics make it more convenient than C structures.
Apache HTTPD comes with a solid set of onboard utilities, and any flaws can be addressed by numerous accessible libraries such as curl, imagemagick, openssl, and even V8 + toc++ for generating bindings, creating your own JavaScript server.

Additionally, the Apache Portable Runtime provides a memory management system with memory pools that effectively eliminate memory leaks and control resource lifetime.

To make C++ code more readable and speed up development, my team has developed a framework. We have been contemplating turning this into a full-fledged OpenSource project for quite some time, but the constraints of free time have delayed this ambition.

The build process is based on makefiles, easily understood by any Linux IDE. Incremental builds ensure fast compilation when actively working on features. Debugging through GDB is seamless, and compilation, deployment, and launch from a single keyboard shortcut take less than a second.

For continuous integration, we use gitolite + hooks for automatic server builds and installation. Rolling out new versions also takes only 5 to 10 seconds, with reassembly on the server and high-quality communication playing significant roles.

Web interfaces are built on bootstrap, though our team has recently experimented with Semantic UI and found it quite satisfactory. The core of the web interface is powered by AngularJS.

Regarding indexing and SEO, we address this with PhantomJS and a simple script. When search engine robots come for a full index, our servers handle the load well with barely noticeable delays (0.1 ms versus 1.5 ms, with an average user ping of 150ms).
Writing websites in C is not only realistic but sometimes more effective than other languages. The strict typing and absence of runtime-interpreted code contribute to stability and security, making C a compelling choice for web development. It's not just about the standard level, but about the approach.
  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...