> Manual memory management is the most popular misconception of C++. Since C++11, it is now recommended to use std::shared_ptr or std::unique_ptr for automatic memory management. There is a small computational cost to maintaining referenced pointers but it’s minuscule and the safety outweighs this cost. I think another misconception is that you need pointers at all. Smart pointers are still pointers. Its better to us…
You mean C++ programmers allocate n object on the heap even when its lifetime is the same as the scope of the containing block ? Unless its such a large huge object that stackoverflow is a possibility I cant imagine why would one do that.
Starting a tech startup with C++
81–90 of 107 posts
Re: Starting a tech startup with C++
#82Earlier quoted context omitted.
You mean C++ programmers allocate n object on the heap even when its lifetime is the same as the scope of the containing block ? Unless its such a large huge object that stackoverflow is a possibility I cant imagine why would one do that.
I don't think C++ supports variable length arrays? So, if you want to allocate N objects, where N is not known at compile time, (I think) you have to use heap allocation anyway. Normally I just use vector , and call reserve() if I feel like extra performance-y. Sure, it's much slower than C99-style variable length arrays, but 99% of the time it's still fast enough. More importantly, it plays nice with other C++ funct…
Re: Starting a tech startup with C++
#83Earlier quoted context omitted.
Because copying the entire in-memory database you're using on every function call is kind of expensive?
Most often you can pass stack values to and from functions without copying. This is because of move constructors, and named return value optimization. Often its slower to use pointers (the indirection). For instance this does not do any expensive copies: std::string getStr() { auto huge_str = getDatabaseDump(); return huge_str; } void readStr(const std::string& str ){ //read str.. } int main() { auto str = getStr();…
Re: Starting a tech startup with C++
#84Earlier quoted context omitted.
Indeed, the given strawman alternative languages (Ruby and Python) are far, far worse for productivity. Python changes are totally unreviewable since one cannot in any way reason about the correctness of a function call without reading the definition of the function itself, and all the functions to which it passes the arguments, all the way down, which of course takes forever. At least with C++ you can reason that if…
Type declarations in python have another name: unit tests.
Re: Starting a tech startup with C++
#85I would find it hard to believe that c++ can be that much faster for many websites since the bottleneck would be the I/O subsystem. I don't understand how they are getting this 40x speed up. I wonder what the benchmark looks like.
I get down voted for posing a logical question?
Re: Starting a tech startup with C++
#86I'm more curious as to the decision not to stick with Rust. Sounds like there was a prototype. I'm guessing there were some libraries missing. Would be cool to know more about that.
Ditto. I'm also curious if D ever came up. My impression is that it was (until recently) much more stable than rust.
Re: Starting a tech startup with C++
#87Earlier quoted context omitted.
Not to dredge up this debate for the umpteenth time, but the same can be said of unit tests: they are not a proof of correctness, and they often give you a false sense of security.
The Internet has, indeed, conducted this argument thousands of times. My point here is only about the difficulty of reviewing Python code. I find myself sometimes having to hold up a piece of paper to the screen to see if the indentation has been done right, in addition to the aforementioned function-body-reading chores. Of course my opinion is of no concern to people except those who work with me, from whom I refuse…
If you seriously "refuse to review Python code" because you feel you need to visually check indentation, I think you might want to take a step back and evaluate your methods.
Re: Starting a tech startup with C++
#88Earlier quoted context omitted.
Programming - principles and practice using C++[1] should be appropriate for beginners. It's a long book at 1000+ pages, but it is designed for novices and explains subjects such as why one needs functions, how to handle errors, GUIs, testing, etc. The C++ Programming language (4th ed)[2] is for experienced programmers. A tour of C++ is the short version of the former.[3] [1]: http://www.stroustrup.com/programming.ht…
Ohh... thnx! Nothing changed since I graduated in 2001 ... I recollect Stroustrup since then. It's still C++ bible.
Re: Starting a tech startup with C++
#89Sounds very inspiring. Any other good places to start learning about C++ 11/14 for complete beginners with JS and other programming languages? I'm very much interested to create proof-of-concept for high performance SaaS services and play with C++ as it might be useful to build Node.js extension later.