3 ms·
Ask HN: Should we use C++ instead of C? Which version of C++?
For a new data service I'm building at work, I'm seriously evaluating using C++ instead of C (I can't use Java/Scala due to memory footprint). I'm confident our team can cope with either so I don't see that as an issue.
Advantages of C++ over C, as I see it:
- Slightly easier memory management
- Better standard library: strings, STL, Boost etc
- Access to modern libraries open-sourced by Google
(http://stackoverflow.com/questions/4721824/what-libraries-has-google-released-for-c),
Facebook (https://www.facebook.com/notes/facebook-engineering/folly-the-facebook-open-source-library/10150864656793920) et al.
Cons:
- The language is more complex; should choose the right subset
- More chance for library/version incompatibilities?
I'm not too aware of the state of C++ nowadays. Does anyone have any recommendations for which version of C++ to go for, which style guidelines to follow etc? (All our environments are Linux)
- pramodbiligiri 14y agoI must add that I've looked at this recent HN thread on the same (http://news.ycombinator.com/item?id=3953434 http://news.ycombinator.com/item?id=3953434) by the author of 0MQ. But I felt the question is still valuable enough to stand on its own.
- papaf 14y agoHave you considered using a mix of languages? For instance Python with C in areas that are performance critical. I'm seeing this used increasingly on scientific projects and I have heard no complaints. The reason I suggest a mix of languages is that, as you probably already know, writing in C slows development time and writing in C++ is like walking through a minefield where seemingly simple things explode in complexity. In my experience/opinion C codebases are more maintainable although the code probably took longer to write.
- pramodbiligiri 14y agoHm, I haven't given that serious thought. I'm used to doing cross language calls on the JVM but not to native code. In our use case we need to load a lot of data and serve it. The client library could be written in Python. I'm trying to decide on the language to use for the lower level.