Live data from Hacker News

Starting a tech startup with C++

medium.com

41–50 of 107 posts

Re: Starting a tech startup with C++

#41
post #36

Earlier quoted context omitted.

You and I can't possibly have the same definition of DMA. It is essential to low latency data communication both in the embedded and server domain.

"Dynamic memory allocation", not "direct memory access".

Ah never seen dynamic memory allocation written as DMA before. Maybe obvious from the context but DMA really only has one meaning for me :)

Re: Starting a tech startup with C++

#42
post #35

Earlier quoted context omitted.

I don't think it is sad. You explained why it is necessary, C++ has been around for a while, is/was great but there are now languages that can compete in terms of performance with fewer drawbacks in terms of security and undefined behavior. If you're starting from scratch, it is important to strongly consider which language and platform best suits your needs. Anecdotally, a lot of companies have found success using n…

> there are now languages that can compete in terms of performance Such as?

If Rust code is slower than equivalent C++, it's a bug. We track performance bugs, please file them :)

Re: Starting a tech startup with C++

#44
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…

> I don't think C++ supports variable length arrays?

VLAs are not part of the standard but GCC supports them. Clang however does not, at least not without a compiler flag I think.

Re: Starting a tech startup with C++

#47
The main problem I imagine is as the platform/codebase matures, there may be compatibility issues as the compiler changes, as the underlying hardware changes, etc. This is something that is well hidden by a language like Python. I remember having to support a cross-database and cross-platform C/C++ server back in the day, and the maintenance was a nightmare. Having the luxury of virtualizing your hardware makes this step a lot easier, that's for sure.

Re: Starting a tech startup with C++

#48
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…

std::array exists. But it isnt variable length. We might get a dynarray in the next standard. I saw a standards committee panel talk where someone asked about it. Ville Voutilainen promised to write standards proposal. I dont miss it much. Usually std::array does what I want.

Re: Starting a tech startup with C++

#49
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…

My question was regarding whether its the norm that C++ programmers use the heap when stack would have sufficed. Parent seemed to be hinting that they do.

And, yeah its disappointing C99 arrays did not make it to C++, one can use alloca to live a little dangerously, better to wrap it so that it allocates on the heap only if more than a certain size has been asked for. Too bad there is no portable way to find out how much stack space does the current process still have. There should have been a system call for that.

Re: Starting a tech startup with C++

#50
No one doubs the performance of C++. What I would really like to see is arguments about speed of development, ease of testing, etc. This articles argues alot about language features or libraries, but what about the bigger picture? It is not enough for the HTTP server be fast. It also needs to do REST API, auth, etc. How does that compare to for example node/js.
Post reply on HN