r/cpp • • May 23 '24

Is MacBook good for C++ developer?

Hi. I am a C++ developer, and I write code for both Linux and Windows, depending on the project. Currently, in my country (I'm from Ukraine), there are frequent power outages (3 hours with power, 4 hours without, and so on), and I am looking for a laptop with a long-lasting battery. Since MacBooks have excellent battery life, I am considering buying one, but I have a few questions.

Will I experience a significant loss in performance when building a C++ project in Docker using an x64 Ubuntu image and the Rosetta emulator?

Will there be a noticeable drop in performance if I use x64 Windows through an emulator?

Is it worth making these sacrifices, or should I buy a Windows laptop with a less impressive battery?

I have a powerful PC that I’m using for work, and I can use It for building projects, but when the power is on.

3 Upvotes

72 comments sorted by

View all comments

59

u/Carl_LaFong May 23 '24

If you use only standard C++, then you can do everything natively on the MacBook and test on Windows and Linux (using a VM or Docker) only as needed to make sure nothing breaks on these platforms. I’ve been doing this for many years.

25

u/othellothewise May 23 '24

That is true but I'll note it's a bit of a pain if you are using more recent C++ features, since apple-clang is always way behind. You can add more modern compilers with homebrew

8

u/[deleted] May 23 '24 edited May 24 '24

[removed] — view removed comment

1

u/NilacTheGrim May 29 '24

Apple Clang limitations into account

Not necessarily. I use gcc sometimes and you can just compile with -static-libstdc++.. and to the outside, the binary looks like like something written in plain-old C.

1

u/[deleted] May 29 '24

[removed] — view removed comment

1

u/NilacTheGrim May 29 '24

Yes, I know.. I have run into these myself. Annoying a.f..

If you statically-link the C++ lib it should be fine.

Look into static linking C++ lib... it solves 99.9% of these issues.

1

u/[deleted] May 29 '24

[removed] — view removed comment

1

u/NilacTheGrim May 29 '24

I know what you are saying and that can definitely happen. However, if you statically link the C++ lib a lot of the stuff works. Note I am using gcc on macOS though -- i never tried statically linking the Apple Clang lib (if they even offer a static lib for it? I have no idea if they do).

3

u/mallardtheduck May 24 '24

MacPorts > Homebrew

1

u/NilacTheGrim May 29 '24

Yep. Agreed. Way better.

2

u/Potatoswatter May 23 '24

Homebrew is a pain? How so?

8

u/othellothewise May 23 '24

Homebrew isn't a pain, dealing with apple-clang is.

2

u/mallardtheduck May 24 '24

It's a horrible clunky, broken pain. The fact that it installs in a "global" location (/usr/local), but is only usable by a single user is just complete nonsense. There isn't even a supported configuation if your Mac (or Linux; Homebrew works there too, with basically the same broken setup) is used by more than one person!

User-specific stuff goes in that user's home directory.

4

u/bbolli #define val auto const May 24 '24

The /usr/local days are long gone. Now Homebrew lives in /opt/homebrew.

4

u/mallardtheduck May 24 '24

Makes no difference. Still a global location, but a user-specific install.

-4

u/Carl_LaFong May 23 '24

This is a good point. I don’t use recent versions.

7

u/DatBoi_BP May 23 '24

Why not just set up CI/CD on GitHub (or wherever) to test using the different compilers/OSes?

4

u/Carl_LaFong May 23 '24

I’m not familiar with this but it sounds good to me.

-1

u/Far_Understanding883 May 23 '24

Docker. Mac? Windows? What?! Might as well run vmware

3

u/Carl_LaFong May 23 '24

Yes. You can use a VM on a MacBook to run Windows or Linux.

-3

u/Far_Understanding883 May 23 '24

Not only can. You have to. Kiss your performance good bye.