You highlight the daunting prospect of moving to C++. You need to pick half a dozen separate libraries and glue them together. Sure, once you've done that a few times it's pretty quick, but it's a scary prospect for a Django dev who can program in C.
What I mean by physical design is, if a particular function is prone to be edited constantly, keep that function definition in it's own .cpp file.
of course I'll agree that in this day and age, we shouldn't worry about those sorts of things.
This has been a problem on every C++ project I've worked on over the past 15 years, and it only seems to be getting worse. And scaled up by increasing team size, that makes it even more of a serious problem.
I hope your parting shot was intended to be that we shouldn't have to worry about this today, i.e., that we should be able to expect more from our tools, and that the current tools are shit. Because we absolutely should worry about it! This is people's time we're talking about. That isn't any less valuable than it used to be.
I have seen optimized builds run faster than debug builds simply because many symbols where being removed during optimization speeding up the link step.
Modern C++ style generally requires making a whole bunch of little functions and classes and counting on them to be inlined and SROA'd away. This works remarkably well for runtime, but it exacts a big compilation performance hit simply because you're optimizing so much code.
The actual ray-tracing code wasn't that long at all, but if you turned max_max_bounces up (say, 100+) "code-gen" time in visual studio blew up to over one minute. That was the moment when I appreciated what everyone was saying about C++ compile times being quite slow if you (mis)use templates.
I'm sort of surprised it doesn't come up more in this environment, but modern C++, Lua, and LuaJIT .. these things appear, to me, far more valuable than given by the hoipolloi ..
The point is, an investment in C++ does not mean you can't 'have all the fun toys too', because .. you can. And boy do they kick ass.
The Definitive C++ Book Guide and List : http://stackoverflow.com/questions/388242/the-definitive-c-b...
I like the breakdown of books by their goals in this FAQ : https://isocpp.org/wiki/faq/how-to-learn-cpp
I would say 'C++ Primer 5th Edition' and 'The C++ Programming Language 4th Edition' are good.
And of course, Effective Modern C++, although the other Effective series books from Meyers are a must read.
http://www.informit.com/store/c-plus-plus-primer-97803217141...
http://shop.oreilly.com/product/0636920033707.do
http://www.informit.com/store/c-plus-plus-programming-langua...
http://www.informit.com/store/effective-c-plus-plus-55-speci...
After sitting down and getting everything actually working between 2000-2010, C++ now seems to be on a steady path of improvement with major releases every three years with no plans to stop.
So, it's not a matter of waiting for things to finalize. It just deciding to go ahead and climb on board the moving train.
These books discuss performant (and sometimes complex) C++ code - in the domain of computer graphics.
http://www.amazon.com/Physically-Based-Rendering-Second-Edit...
http://www.amazon.com/Real-Time-Collision-Detection-Interact...
About how to use the new threading standard: https://www.manning.com/books/c-plus-plus-concurrency-in-act...
Also, the rest of the book is well written and worth reading for completeness, if not rather lengthy.
!! I've always heard that Asio is great, but never bothered to look because I don't like introducing Boost's 450 megs of compiler-test-suite-worthy C++ to my >45kb programs. But, as a stand-alone library. That's interesting!
https://www.manning.com/books/c-plus-plus-concurrency-in-act...
Promises are already there.
This will also only be fixed in C++17. Boost future already implements more of this, but afaik it's still flagged as experimental, so it could change again. And afaik there were also some pending discussions about how futures should interact with schedulers/executors.
Briefly: "Seastar is event-driven and supports writing non-blocking, asynchronous server code in a straightforward manner that facilitates debugging and reasoning about performance." -- http://www.scylladb.com/2015/02/20/seastar/
Concurrency model: "Seastar futures/promises/continuations (f-p-c) are a subset of reactive programming.
Seastar performance derives from the sharded, cooperative, non-blocking, micro-task scheduled design, and f-p-c are a friendlier way of feeding tasks to the scheduler.
Seastar’s f-p-c do have some optimizations relative to other f-p-c designs. They trade off thread safety, which is unneeded due to the sharded design, for scheduling efficiency, and have a very low memory footprint." -- http://www.seastar-project.org/faq/
If you'd like to find out more, here are a few links with more information (including examples and tutorials):
- https://github.com/scylladb/seastar/wiki
- https://github.com/scylladb/seastar/blob/master/doc/tutorial...
- http://www.seastar-project.org/futures-promises/
- http://blog.cloudius-systems.com/2015/04/29/seastar-tutorial...
- http://www.slideshare.net/TzachLivyatan/seastar-sayeret-lamb...
In terms of practical applications, ScyllaDB (fully compatible--and significantly faster--drop-in replacement of Apache Cassandra) relies on Seastar: http://www.scylladb.com/
ScyllaDB has been discussed here before: https://news.ycombinator.com/item?id=10262719
That said I've found nodejs slightly nicer for distr
If you can bundle all your dependencies into a static file you're right, C/C++ is actually better as you have no install requirements.
However in terms of maintaining your dependencies, nodejs can be pretty great with package management coming with the npm tool. When you want to share your code with the world, and for someone else to actually use it, nodejs is easier.
In C/C++ you can use CMake to have external dependencies on git projects which is the best I've seen that you can do. If you know of any other tools that help with these problems please tell!
<?php
$data = json_decode(file_get_contents('data.json'));
foreach ($data as $obj) {
echo $obj->x . ',' . $obj->y . "\n";
}
That's the entire script.Perhaps this example (benchmark, actually) is close enough: https://github.com/nlohmann/json/blob/master/benchmarks/benc...
Note that the above also performs mini-benchmark with multiple iterations, dumping parsed data to another file, and finishes with a clean-up of the aforementioned dump target file.
The core (read, parse, write) can be simplified to:
std::ifstream input_file("data.json");
nlohmann::json data;
data << input_file;
std::cout << data; #include <fstream>
#include <json.hpp>
int main()
{
std::ifstream input_file("data.json");
nlohmann::json data;
data << input_file;
for (auto obj : data)
std::cout << obj["x"] << ',' << obj["y"] << '\n';
}If we were talking about language constructs/semantics or flow-control abilities, I'd have a very different opinion - but not having a json decoder builtin, is no reason to use or not use a language.