Live data from Hacker News

Starting a tech startup with C++

medium.com

81–90 of 107 posts

Re: Starting a tech startup with C++

#81
post #28
post #16

> 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.

No one who cares about performance enough to be using C++ would do something like this. Allocating on the heap when not necessary is a sign of a dangerous amateur.

Re: Starting a tech startup with C++

#82
post #40
post #28

Earlier 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…

You can still use alloca in C++

Re: Starting a tech startup with C++

#83
post #31
post #26

Earlier 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();…

That isn't about value semantics, what you are describing is a combination of copy elision and ownership.

Re: Starting a tech startup with C++

#84

Earlier 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.

I don't know why this is controversial, in Julia type annotations to expressions are basically asserts

Re: Starting a tech startup with C++

#85

I 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?

I don't see any question.

Re: Starting a tech startup with C++

#86
post #76

I'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.

Rust has been remarkable stable since the 1.0 realease.

Re: Starting a tech startup with C++

#87
post #75

Earlier 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…

My point is that there are tools and techniques that will solve these problems in ways that are more valuable than the compiler's type system.

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++

#88
post #17
post #10

Earlier 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.

The [1] book is exceptionally good for beginners. He completely rewrote it with C++11 and refocused beginners on some key changes to the language to make it much easier.

Re: Starting a tech startup with C++

#89
post #7

Sounds 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.

I think the best book for complete beginners is "Jumping into C++" by Alex Allain. From there, move on to "C++ Primer Plus" by Stephen Prata.

Re: Starting a tech startup with C++

#90
post #76

Earlier quoted context omitted.

Ditto. I'm also curious if D ever came up. My impression is that it was (until recently) much more stable than rust.

Rust has been remarkable stable since the 1.0 realease.

Sure, I was referring to pre-1.0 rust ;)
Post reply on HN