r/cpp • • Aug 25 '21

Experience C++ developers: do you enjoy using C++ (even for personal/hobby projects?)

Do you actually enjoy using C++, or do you only use it for work, or purely for performance? This question is aimed at people with years of experience, who've worked on large projects in C++. I see people who dislike the language, but use it purely for performance reasons. This sort of discourages me from learning it. I don't want programming to feel like work.

204 Upvotes

327 comments sorted by

View all comments

Show parent comments

3

u/NobodyXu Aug 25 '21

Nah, C++ modules are unlike other languages, where its use doesn’t affect the mangling of the function.

You still need to use namespace.

2

u/germandiago Aug 25 '21

I mean that you can do this (why the negative vote?):

import mylib;
#include <anotherlib.h>
using namespace mylib;
using namespace anotherlib;
// do whatever

And if you are compiling it as a module, it will not leak any using directives or macros outside.

2

u/backtickbot Aug 25 '21

Fixed formatting.

Hello, germandiago: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

1

u/NobodyXu Aug 26 '21

So doesn’t module still require the use of namespace?

Other languages, such as Rust, Python and Java, integrate namespace and module.

Such as (in Rust):

// lib.rs
mod b {
    fn f() {}
}
mod c;
b::f();
c::f();

// c.rs
fn f() {}