O
O
Offenso2013-11-01 06:34:08
PHP
Offenso, 2013-11-01 06:34:08

Does C++14 have enough features to make you forget about PHP?

I have long been warming the idea of ​​creating sites in C ++, in my native language. But before it was not rational.
The other day I got acquainted with the draft C ++ 14, and I would like to know from those who have read in more detail, and have already mastered C ++ 11, there are enough opportunities to rivet shit sites just as quickly, only on a normal language, with adequate memory allocation?

(For the pissed off php people, I'll add, I'm not satisfied with this. The whole language is covered with this.)
$a = "2d9"; $a++; $a++; echo $a; → 3
$a = "2d9"; $a+=2; echo $a; → 4
$a = "2d9"; $a++; echo $a; → 2e0

Answer the question

In order to leave comments, you need to log in

11 answer(s)
G
galaxy, 2013-11-01
@galaxy

C++14 has enough features to make you forget about C++

A
AxisPod, 2013-11-01
@AxisPod

Well, if you want a lot of hemorrhoids for your seat, then good luck.
Profit from C++ is possible only if very complex calculations and multithreading are required. And for every little thing that basically works with databases and files, absolutely any interpreted language will do. If you want to get away from PHP, look at Python for example. But pitfalls are absolutely everywhere.

S
Sergey Lerg, 2013-11-01
@Lerg

Have you looked in the direction of Go ? I forgot about PHP when Go came into my life. True, I do not make websites, but services, but one is not much different from the other. Go is like C compiled (speed, low memory consumption), but it is very comfortable to write in it, almost like in PHP or Python.
You can make friends with nginx.
Here is a selection of web frameworks in this language
robfig.github.io/revel/
www.gorillatoolkit.org/
webgo.io/
code.google.com/p/gorest/
I use this one - github.com/stretchr/goweb
Simple and lightweight.
Go book - www.golang-book.com/

9
96467840, 2013-11-01
@96467840

I was very surprised by C#. I myself program mainly in php, and at work I started a new project on Sharpe. I was very surprised how everything is pretty simple and pretty convenient.

G
gro, 2013-11-02
@gro

No, first you need to write some kind of garbage, hint that php-g.but also php's talpiops, and then tell that "I didn't want to offend anyone", "I'm not talking about php here at all" ...

B
bak, 2013-11-03
@bak

On the pluses, there is everything to cut sites. Take batteries (boost), a web server (my choice is mongoose with a self-made wrapper ), a template engine (for example, cpptemplate ), a database (in simple cases, store everything in memory and dump to disk. In medium ones, use any of the heap of databases , both external and easily embedded directly inside the program.In complex ones, keep part of the data in memory, part on disk, load it when necessary, and do not forget to log). Then you take bootstrap & jquery (or any other framework you like) and file the json exchange. You can also tie websockets.
In terms of development speed - when you get used to it - you will not drain the interpreters too much. For convenient development, you need to have a configured build system with libraries, an ide that can work with data on a remote machine (for example, QtCreator) and the machine itself, which will not take long to rebuild all this.
You will merge anyway, because: - compilation (faster than 5-10
seconds for a project with a set of libraries, you can’t accelerate, though ..)
for languages ​​popular on the web)
- bicycles (I don’t know about the pros of normally implemented web components, i.e. cms, web frameworks, etc). As a result, you will have your own framework withblackjack and whores memory leaks and bugs, fixing which you will have to spend time exceeding the time of product development
- the speed of the brain. There is infa that if the brain part of the time thinks about which object owns who and who kills whom when, another part, how to wrap the first part in conveniently usable abstractions and apply some pattern here, another part about what a strange error message in some third-party library that has entered into a strange connection with a freshly written shit code, not forgetting about static typing, as well as a perverted interface for developers of typical solutions ( yes, the same split ) - its performance is somewhat lower than that of a brain that thinks mostly about product logic.
- compilation errors, linking errors, segfaults, multithreading errors, memory leaks - in general, a complete set of pleasures for true connoisseurs :)

N
Nikolai Turnaviotov, 2013-11-01
@foxmuldercp

Honestly, for myself, I personally appreciated the simplicity of web development in C # + Asp.Net MVC + jquery / twitter bootstrap.

A
Alexey Akulovich, 2013-11-04
@AterCattus

About the objectivity of using C ++, this has already been written for you. Let's explain about the PHP logic that does not suit you. The truth is in a different order.

<?php $a = "2d9"; $a++; echo $a; → 2e0

a is a string. Incrementing a string (which is not a 10-digit midrange entry) follows the Perl principle : "A"++ = "B", "Z"++ = "AA", "AA"++ = "AB". So we get "2e0".
<?php $a = "2d9"; $a++; $a++; echo $a; → 3

If the string contains something similar to a 10-digit midrange, then we bring it to an integer and increment it. The second increment gives "2e0" = 2*10^0 = 2. 2++ = 3.
<?php $a = "2d9"; $a+=2; echo $a; → 4

Arithmetic without increment immediately converts the string to a number, and we just count 2+2.
Normal logic considering how PHP is being used. It's like wondering why the increment short* increments the pointer value by 2, and not "as it should be" by 1 :)

V
Vitold S, 2013-11-08
@vit1251

I don't understand your problem at all? If you're writing in C++, it's not hard to just make your own PHP branch cut out string addition and get an interpreted language with the behavior you want.
And I am sure you will find followers and fans to write long-pool applications. And if you add PHP and equip it with Threading and finish the OOP-shny Runtime to a good level, then you will not have a price ...

S
SBKarr, 2013-11-13
@SBKarr

If you are very interested, you can write websites in both C and C ++

My projects use Apache HTTPD + modules of interest + content module written in C++ (however, from ++ there are only objects with inheritance, no templates, and even more so stl and boost, just object semantics is more convenient than structures from C)

Apache HTTPD already has a solid set of useful things on board (google Apache Portable Runtime), the shortcomings are corrected by tons of good and accessible libraries (curl, imagemagick, openssl, anything from the world of C / C ++, at least V8 + toc ++ for generating bindings and you have own javascript-scripted server)

In addition, you can get a memory management system from APR (memory pools), which saves you from the severe headaches of leaks, resource lifetime control, and other joys.

For all this joy, we have written a framework that gives C ++ code readability and development speed at the level of interpreted languages, which the team has been dreaming of finishing up to a full-fledged OpenSource project for a year (here, only there will be free time ... but it looks like it will be in the next life ).

The assembly is built on a makefile, which is perfectly understood by any IDE that is on Linux. The assembly is incremental, as expected, compilation during active work on a feature is less than a second. Debugging via GDB (also great for IDE). Compilation + deployment + launch from one keyboard shortcut takes less than a second.

Working versions are rolled out through a primitive CI (gitolite + hooks), the server itself collects, installs itself. Rolling out also takes from 5 to 10 seconds (everything is completely rebuilt on the server, and the quality of the connection is not the last role assigned).

Web muzzles are assembled on bootstrap (although layout designers have recently tried SemanticUI and rejoiced), the heart of the web muzzle is AngularJS.

But what about indexing, people familiar with SEO will ask? PhantomJS + the simplest script solves this problem. When the robot comes for the full index, the servers are of course not very happy, but they are quite worthy and work without noticeable brakes (0.1 ms versus 1.5 ms, with an average user ping of 150ms)

In general, if you want to write sites in C, this is more than realistic, and sometimes more than effective. Strong typing and the lack of runtime-interpretable code solve a whole host of stability and security problems. And the point here is not the level of the standard, but the approach.

P
polifill, 2016-11-07
@polifill

1% of the time the power of C++ is used.
99% of the time you struggle with C++ Says a
person who has been designing languages ​​and environments and compilers for almost 40 years.
https://habrahabr.ru/post/314616/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question