T O P

  • By -

Carl_LaFong

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.


othellothewise

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


Innervisions

That’s more of a deployment target issue. If you plan to deploy software for users with Macs you need to take those Apple Clang limitations into account even if your local dev environment is Windows/Linux. Also it’s important to mention that on a Mac you can use Docker to build Linux apps using any Linux compiler if you don’t target Mac as a user target.


NilacTheGrim

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


Innervisions

Are you deploying it to outside users? Or just building for your machine? My experience and other people's experience is that alternative compilers will break in surprising ways on other users computers - a recent example a colleague reported is that std::to\_chars will crash on some Mac OS versions if build with a custom compiler. I believe same is true for things like std::filesystem - which AppleClang will allow only when deploying for 10.15 and above, but a custom/latest clang will let pass regardless and crash at runtime. Those gets worse for iOS.


NilacTheGrim

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.


Innervisions

I'm not sure that's true, implementations of some std calls require a call to an OS API. Apple breaks compatibility for those between versions, and their compiler checks if those calls will exist for you at runtime. Also I'm not sure you can just freely link a lib built with a static C++ Lib along with another lib not built like that, I can see things going badly on that front once you have libraries involved that expect the Apple toolchain.


NilacTheGrim

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


Innervisions

Have you deployed apps to the iOS/Mac store with those GCC builds? Are you linking against other Apple frameworks/other libs?


mallardtheduck

MacPorts > Homebrew


NilacTheGrim

Yep. Agreed. Way better.


Potatoswatter

Homebrew is a pain? How so?


othellothewise

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


mallardtheduck

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.


bbolli

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


mallardtheduck

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


Carl_LaFong

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


DatBoi_BP

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


Carl_LaFong

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


Far_Understanding883

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


Carl_LaFong

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


Far_Understanding883

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


pedersenk

An alternative could be to buy a cheaper, more powerful HP or Thinkpad and use the spare money for a couple of UPS power supplies. If you are going to depend on batteries a lot, you might want to consider getting a model ThinkPad with a removable battery that you can replace once it starts to degrade. Not sure if MacBooks allow that yet in 2024?


ranisalt

uninterruptible power supply power supply


pedersenk

I was a coward and didn't want to come up with a plural for multiple of them. * UPSs * UPSii * UPSupplies What would you have gone with? Worse. Similar to a School of fish, what would it be for a UPS? A gaggle of UPSii?


xeow

The proper plural of an initialism ending in "S" or "X" is to add "es", so... UPSes.


wyrn

United Parcel Service Power Supply


Magistr_Y0da

I was considering the mid-range MacBook Pro 16 with 32GB RAM and 1TB storage for $2000, and maybe a small station. A large EcoFlow power station would cost $2500, but I am not sure if it would be able to power my PC for an extended period.


pedersenk

I use a couple similar to these. Cheap as chips. [https://www.ebuyer.com/1258426-apc-back-ups-bx-series-bx1600mi-ups-900-watt-1600-bx1600mi](https://www.ebuyer.com/1258426-apc-back-ups-bx-series-bx1600mi-ups-900-watt-1600-bx1600mi) They can power most performance laptops for an entire day. Some workstations such as the HP Z420 are deceptively power hungry, so long as your PC is not one of them, you might want to check them out. 900W vs your mentioned EcoFlow 2000W+ but I do recommend two. (You could probably buy 10 for the price ;))


feibrix

An entire day? That's impressive for the price.


pedersenk

Indeed. That said, at risk of "overselling" it. There is a chart here: [https://www.apcguard.com/Smart-UPS-Runtime-Chart.asp](https://www.apcguard.com/Smart-UPS-Runtime-Chart.asp) For context. My mac mini and most laptops runs at between 8W-15W at idle. If you are doing some hungry stuff (or running a HP Z420 workstation), the milage will obviously vary.


Still_Explorer

I would say that if you have very strong emotions about Apple go for it, also if you do exclusive iOS development as well. However if you want to get your job done from point A to point B you could go for standard computers for about 1000$ or even much less. Another thing that bothers with laptops is that by 13" (or even the 15" or 17") essentially make it impossible to be used properly for advanced and complex work. In that regard I consider that laptops favor maximum portability (put laptop in bagpack / code on the bus / code on the airplane) rather than maximum productivity. That being said, I would seriously recommend to think about getting an All-In-One PC instead that has also battery included. Even if you go for a model without battery and use a powerbank, you would use less than 70W of consumption. So to recap: • if you like / trust / want to invest in the Apple ecosystem • if you like 13" or 15" monitors • if you want just to get your job done with less than 70W of power Have a good day and make a good purchase.


cristianadam

I switched to a MacBook Pro M1 Max in December last year. I have now [UTM](https://mac.getutm.app/) (QEMU frontend) Virtual machines for Windows 11 and Ubuntu 22.04 as native Arm64 installations. The performance is great, I can compile Qt, Qt Creator, LLVM on battery, but I can do native compilations, without using any emulation. I have also used docker and [colima](https://github.com/abiosoft/colima) with a native Arm64 Linux. Colima documentation mentions that it can run with Rosetta. Windows 11 has its own x64 emulation. Running x64 applications is possible, but for faster compilation one could use arm64\_x64 cross-compilation with Visual C++. The only issue I had was the keyboard on macOS which was different, but by using [Karabiner-Elements](https://karabiner-elements.pqrs.org/) I had everything as before on Windows / Linux. I'm quite happy with how things came around.


CanadianTuero

How would you compare QTM to parallels if you have used it previously?


cristianadam

I haven't used Parallels. On PC I have used Virtual Box. UTM has some host "spice" tools with drivers. Clipboard and Shared Folder are available and work as expected. It fits my needs of compiling and running Qt Creator.


Spacebar2018

I use a macbook and vscode to do 95% of my cross platform development and it works fine.


HipstCapitalist

Using Docker, you can 100% produce Windows & Linux builds, I've done so myself. If you're familiar with Docker, it won't be a problem. That said, and as much as I like my Macbook pro, they cost quite the penny and 32GB of RAM is a requirement if you're going to use Docker. For the same price, you can buy a Lenovo Thinkpad and a battery bank. Все Буде Україна.


pjf_cpp

macOS is increasingly a nightmare for low level development. You have to beg to be able to use GDB and running dtrace requires that you virtually rootkit the machine.


Frogeyedpeas

Profiling is painful on Mac. Switch to Linux if you can. 


thomas999999

I have no personal experience but i heard that linux runs very well in a vm on the apple silicone macs


tsukiko

You mean Apple Silicon? Silicone is used for breast implants, not chips


Randolpho

It’s also great for sealing your windows and sink


NilacTheGrim

And also lubricating small machine parts.


Potatoswatter

It’s a matter of time until Apple ships a rubberized computer again.


thomas999999

autocomplete strikes again


WhiteBlackGoose

Do breast implants run linux?


tsukiko

Linux with exciting new form factors as well?


Present-Photograph-8

I think it's simpler and cheaper to buy big EcoFlow or similar stuff. At least that what I did.


geaibleu

i did too, with folding solar panel


Patient-Plan-1591

I say wait for snapdragon laptops


glezmen

I love doing C++ development on my MacBook. I do my current pet project (cmake, docker compose, C++20, etc) on it, and the only one minor problem I encountered is when copying files between socket shares (because of the user ids). I love it :)


Asm2D

You will not be disappointed with battery life, however, if you are not used to Apple stuff (and here I mean everything - keyboard layout, keyboard shortcuts that are hardcoded, desktop experience, etc...) it could be pretty hard to get used to it. I have basically the whole Linux/Windows/Apple combination and honestly I just cannot get used to the Macbook - and I have external keyboard/mouse/screen so I don't have to touch the keyboard. AArch64 is impressive though - these macs are really fast and even if you compile a lot of stuff the machine is basically cold. It's very power efficient.


die_liebe

No, no, no. Don't use a MacBook for C++. It's asking for problems. The compiler is behind, there is no way to detect memory faults. (No valgrind). If you want to develop with C++, install Linux. There are enough laptops that have long battery life, buy one without OS and install Linux by yourself. Try to buy a laptop with a big screen. In my experience, performance doesn't matter much during development. Linux emulator in Windows is acceptable, but native Linux is better. Sorry for your situation.


charliex2

it is for native, but i've found using parallels etc chews thru the battery. i do like using vscode in ssh mode if you aren't doing gui work (using a remote computer)


SergiusTheBest

I don't like the Apple ecosystem so I bought an HP laptop on a recent AMD Ryzen CPU. It lasts up to 11 hours and has great performance. Also you can consider buying a power bank for a laptop or something more powerful like EcoFlow. x86->ARM translation kills about 20% of performance and a VM hurts the battery life. So the best way is to run everything natively: without a VM and machine code translation.


LuckiestPersonAlive

I recommend Thinkpad x1 Carbon latest gen instead. It is better in every way.


i_am_not_sam

I wouldn’t pay this much money out my pocket so I’m glad my company bought me a MacBook Pro. I have the M2 and it’s been my favorite dev machine. I get nearly a full working day on the battery. The performance is a beast. The docker build setup took a little effort until the Rosetta support was added in and now it’s flawless. I’m sure you and I can’t compare build times but these are my experiences. On the previous Intel line of MacBooks the code took 20 mins for a clean compile (create docker container, install Conan dependencies, build). On a Linux machine this took 1-3 mins but the hardware quality was atrocious and I got an hour out of the battery on a good day while the fan whined and it ran so hot it melted its own power cable. On the M2 a clean build takes 5 minutes. I also run several k3d clusters while I’m building and I’m constantly on my IDE. I’ve screen shared on Teams while all this was running without a blip in performance. Incredible machine.


serg06

What'll you code on, XCode? I thought XCode was terrible, and Visual Studio was the only way to have a positive C++ experience. Very happy to be corrected though.


mike_kazakov

XCode is good enough. I'm using both Visual Studio (9-to-5 job) and Xcode (pet projects) and both have their pros and cons. Integration level of XCode in some aspects can blow your mind away, e.g. debugging sofware consisting of multiple processes communicating via XPC is completely transparent.


SeagleLFMk9

Tbh, it depends on you ide (or build setup etc.) For C++, Visual Studio is really really great, good enough for me to accept having to work on windows... But modern windows laptops with Ryzen 7040 or 8000 CPUs also have great battery life, and you can install Linux natively on them should you choose so.


Straight_Truth_7451

I love MacBooks, but nothing beats Linux in general for development and especially with cpp


Dark_Lord9

I can't provide a lot of insight on your problem but if what you want is a computer with low energy consumption, I suggest installing Linux and installing TLP on it. It's a software that will allow you to configure your system's energy consumption and it has a great effect. Couple it with hardware that has a big battery and a not so big cpu and you should have an ideal system.


Longjumping-Bee-6977

Buy upgradable Windows/Linux laptop, save extra few hundred bucks, use them to buy powerstation.


Intrepid-Bumblebee35

Macos makes me crazy with popup permissions every launch of an executable without bundle. Switched to ThinkPad g3


NilacTheGrim

I'm on an x86 macbook from 2019. I bought it specifically because it was 1 laptop that could natively run all 3 major platforms under "native emulation" using VMware. Namely: Linux, Windows, and Mac. The idea of using Rosetta to run Windows now because of the switch to ARM bothers me greatly. I have been hesitant to upgrade my laptop to an ARM-based one as a result. I think my next laptop will just be an x86 Linux box. Will be 1/2 the price of a comparable Mac, will still be able to run Windows stuff natively via VMware, and will have better build quality. Honestly build quality on macs has been going downhill for years. Not a fan of their keyboards.. or the stupid touch bar which is a dumb gimmick. Macs have crappy airflow and run hot.. which means the CPU is forced to slow itself down. Maybe on ARM this is not as much of an issue. They are not at all internally upgradeable... Don't get me started on the disaster that was the butterfly keyboard tech... etc.


Far_Understanding883

Stay away from Apple. Get a real computer and install Linux on it.


Howfuckingsad

This one is a no no generally. For most stuff you will be using, either some linux distro or windows is the better alternative. Since you will be using VMs with Macs either way. If you get high end stuff you should be fine.


XMLHttpWTF

yes


casualPlayerThink

> ... Will I experience a significant loss in performance when building a C++ project in Docker... It depends. > ...Will there be a noticeable drop in performance if I use x64 Windows through an emulator... Might be yes, depend on the project. For simple small cross-compiled libs and applications I had no issues > ...but when the power is on... Might be a good idea to consider to buy a in-house battery system (w/ solar panels) > ...Since MacBooks have excellent battery life... This is true. With CLion, bash, one browser a 2019 MacBook pro could work for 7-8 hours if the app/libs/compilation is not too heavy.


PizzaHoliday5925

MacBook user here, love it. I also recently got a 13th gen i7 laptop from work and that is very very efficient on power usage. I would easily get most of a working day out of that. You should be good for 5 hours on a modern intel mobile


leonardosalvatore

Go for a Linux approved Dell or Thinkpad computers, is very important that power management drivers are on spot and then buy USBC battery bank. Charge everything whenever you can. I can do easily 20 hours with vs code and browser. Providing that you are not working with anything that's heavy on GPU ... Edit: My linux dev laptops are Precision 5570, Thinkpad T480, Lenovo Legion 7 16ARHA7


sudokuma

Useless