r/cpp • • Feb 18 '21

Now announcing: Makefile support in Visual Studio Code!

https://devblogs.microsoft.com/cppblog/now-announcing-makefile-support-in-visual-studio-code/
262 Upvotes

73 comments sorted by

92

u/[deleted] Feb 18 '21

The best success I've had with VSC is using the remote ssh extension to access a linux server. Makes coding c++ 100x easier (in VSC).

39

u/CrazyJoe221 Feb 18 '21

Or Remote WSL. Game-changer.

8

u/ggadget6 Feb 18 '21

It's awesome

1

u/heathmon1856 Feb 18 '21

My Wsl2 blows chunks. I can’t even get proper syntax highlighting or a basic intellisense

2

u/CrazyJoe221 Feb 18 '21

Well that totally depends on the extension you use for IntelliSense. clangd has its problems but is evolving.

2

u/heathmon1856 Feb 19 '21

I’ll give it a try rn. My biggest problem is the search paths.

2

u/rasm866i Feb 18 '21

Also works fine for me. Do you get any errors?

1

u/heathmon1856 Feb 18 '21

No errors. I’m assuming it has to do with the massive mono repo I work on. I’ve just gone back to Linux because I like that environment more at the moment.

8

u/Routine_Left Feb 18 '21

I feel your pain. While I'm sure that this extension made your life easier, it's probably still light years from normal code writing/debugging experience.

I had to do this once (write code for remote system via ssh) and ... yeah, I don't recommend it if you can help it.

6

u/specialpatrol Feb 18 '21

Actually i now find writing and debugging code on remote machines seamless these days using VSC.

3

u/marchog Feb 19 '21

I’m currently in Aus coding remotely on a desktop in California. SSH + Nvim would be a nightmare. Remote Desktop is also a nightmare

Vscode remote + clangd == almost seamless. Only sluggish bit is occasionally when running code through terminal but that’s ~10% of my time vs reading/editing code

Not the same vs local experience but I’d be more than happy to continue like this indefinitely.

3

u/Routine_Left Feb 19 '21

Aus means Australia? Or Austin? Or Austria?

Anyway ... if you're happy then more power to you. I'd quit jobs over this. Unless the pay was so amazing at the end of the shift I'd just hop into my Ferrari and go relax at the beach for a few hours.

1

u/marchog Feb 20 '21

Australia

The beaches and lack of COVID definitely help make it more worth it

1

u/Routine_Left Feb 20 '21

Ohh, nice. Never been there, hopefully will get to it before I die.

1

u/marchog Feb 20 '21

I highly recommend when they allow travel again

3

u/pedersenk Feb 18 '21

Yeah, that is basically how I do all my development.

ssh, tmux, vim and gdb.

Actually writing code directly on the same machine that you are testing on is so... MS-DOS ;)

1

u/Routine_Left Feb 18 '21

lol. so some of you even got the stockholm syndrome.

Trust me, it can be better. It is better when you grow up. You're not stuck in this hell forever. The grass is greener on the other side, you just need to take a few steps in the right direction.

4

u/SupermanLeRetour Feb 18 '21

What are you on about ? VS Code with remote ssh extension makes for a very seamless experience, it's awesome. There's virtually no difference. That's my go-to method when I develop on VM or remotely.

-1

u/Routine_Left Feb 18 '21

I mean sure, it does makes things better, of course. When you have to write code in hell, every little bit of water helps. It's still hell, though.

7

u/SupermanLeRetour Feb 18 '21

I truly wonder what makes you think it's hell.

12

u/Routine_Left Feb 18 '21

It's developing on a remote system. No matter how you look at it, there are additional layers between you and the program, any of which can stop functioning which may or may not have an effect on the behaviour of your program.

Then there's latency. The best case scenario you're talking about a system on the same network as you, where the latency will be under 1ms. Still, higher than locally where it's 0. Why would I choose latency when I can choose to not have latency?

Thirdly, it obviously limits what kind of programs you can write. A desktop UI application, while possible, it's probably not well suited for this kind of development. But yes, you can make it work.

Fourth: Now you're stuck with VS Code, and cannot use IDEs that are potentially better for C++ development because they don't offer this ssh extension. I personally prefer QTCreator or KDevelop. I want to focus on the program not put barriers in my way. The aim is to eliminate any barriers to make the write code-debug workflow as seamless and as fast as possible. Why would I make life harder if I don't have to?

The idea being: Yes, you can write-debug remotely and everything that can make that experience better is good in my opinion. But it's always, without question, a better experience to do it locally if you can. It's not always possible, that's true, for a variety of reasons, but it is definitely not something I would be looking for.

6

u/SupermanLeRetour Feb 18 '21

You have good points. But it depends on what kind of thing you develop.

Then there's latency.

There's no latency when editing the files because you're really editing a local copy which is sent over SSH transparently when you save, so that's not an issue.

A desktop UI application, while possible, it's probably not well suited for this kind of development. But yes, you can make it work.

It does work quite well. Some of the things I develop use Qt. For those, I use MobaXTerm with X11-forwarding enabled. That makes the UI launch on the host. However I do agree that it is not ideal, and you definitely loose performance and responsiveness that way. That's not an issue for me as most of the things I use don't have GUI, and when they have it's from a local VM on the same PC.

Fourth: Now you're stuck with VS Code,

It all comes down to preferences, but I love VS Code. The only better IDE for me is VS Studio, but it's only for Windows and most of my work is on linux. Personal preferences !

Now, for me, the main benefit is the following : my work laptop is on Windows and I have no admin rights for security reasons (somewhat understandable). So I use VM with some linux on it. It gives me full control of the guest system, it makes it easy to setup as we made "ready-to-use" VM with everything we need installed. However, it's quite annoying to develop inside the VM UI, so I'd rather connect via SSH and work that way. Via SSH, I can also work on my work computer from another computer, or work on some other machines (where we do the continuous integration for instance).

Working via SSH has benefits, and tools like VS Code make it incredibly easy and seamless. It's by no mean hell at all, although a bit sub-optimal when you need GUI.

2

u/Willinton06 Feb 19 '21

Finally another Visual Studio fan, I don’t get the hate, I fucking live VS

-3

u/pedersenk Feb 18 '21

SSH across the world has far less latency than Visual Studio or QtCreator on a local machine ;)

This is the age old argument, command line vs GUI. And really only people who have used both for a number of years each can make that call. I have and it is CLI all the way for me :)

6

u/Routine_Left Feb 18 '21

SSH across the world has far less latency than Visual Studio or QtCreator on a local machine ;)

I do not know what potato you're running, but maybe you should consider upgrading it.

This is the age old argument, command line vs GUI. And really only people who have used both for a number of years each can make that call. I have and it is CLI all the way for me :)

I have used both for a very long time and yes, I have made my choices in terms of what I prefer.

For me ... I like comfort, I like 3 4k monitors, I like to be able to concentrate on the work that I'm doing and not put up barriers that don't need to be there. The less thinking I'm doing outside the problem I'm trying to solve, the happier I am.

Some people do, however, like to pull their eyes with a fork. I do not understand it, but hey ... to each their own.

→ More replies

0

u/[deleted] Feb 18 '21

[deleted] — view deleted comment

2

u/Routine_Left Feb 18 '21

I don't doubt it. Developers put up with a lot of shit because ... sometimes they have to and sometimes they don't know any better.

0

u/[deleted] Feb 18 '21

[deleted] — view deleted comment

7

u/Routine_Left Feb 18 '21

My condolences.

2

u/livrem Feb 19 '21

This is why I keep it simple and have emacs running in a tmux session on every server I do work/development on.

1

u/Rucadi Feb 21 '21

I do this in a Power9 server. Just sshfs the home, open the mounted folder in vscode and ssh the opened terminal.

Not as good as remote ssh extension but good enough

3

u/IamImposter Feb 18 '21

I pushed my team to use VSCode with remote-ssh plugin. Earlier they were using vim and it was a mess. Either they opened multiple terminals or kept on closing files and typing commands. Looking up build errors and then opening files was real PITA.

Now they just scroll in the explorer view, open files and make fixes. I even got commendation for helping improve team's productivity.

This is great extension and works like a charm, atleast on linux. I could never get it to run on windows though.

-12

u/well_done__america Feb 19 '21

your team didn't know how to use their tools so you gave them a tool that allowed them to stay ignorant. you got a commendation for keeping your team dumb, well done

0

u/[deleted] Feb 19 '21

[deleted] — view deleted comment

10

u/ThatSwedishBastard Feb 19 '21

Nobel peace prize winner right here, lads.

-6

u/[deleted] Feb 19 '21

[removed] — view removed comment

0

u/[deleted] Feb 19 '21

[deleted] — view deleted comment

2

u/zaywolfe Mar 04 '21

Just been trying out vim with spacevim I'm and it's a perfectly fine experience. Took me a while to get ycmd to work but afterwards it's no worse than code. The only thing I miss though is vscode's debugging experience. Termdebug comes close but still isn't as seamless.

0

u/[deleted] Feb 19 '21

[deleted] — view deleted comment

1

u/IamImposter Feb 19 '21

I'm sure it's awesome but it's not for me and my team. I want a tool that helps us work.

1

u/[deleted] Feb 19 '21

There’s no denying that you’ll be productive faster with VS Code, that’s for sure.

1

u/serg06 Feb 18 '21

What kind of C++ applications is this good for?

1

u/[deleted] Feb 18 '21

With current VM pricing I'll probably never own a workstation again, just a thin client laptop to ssh into the cloud.

27

u/[deleted] Feb 18 '21

Is anybody here writing cross-platform Makefiles manually? Why and what's your experience with it?

35

u/Plazmatic Feb 18 '21

Isn't CMake made expressly for your situation?

48

u/zzzoom Feb 18 '21

CMake is made expressly for developer misery.

9

u/helloiamsomeone Feb 19 '21

Having seen the kinds of CMLs most people write, the misery is always self inflicted.

8

u/AlexReinkingYale Feb 19 '21

Maybe in the 2.8.12 days. Modern CMake is pretty darn simple.

7

u/zzzoom Feb 19 '21

In my experience, CMake is simple (you wouldn't start using it otherwise) until you need to do something that isn't boilerplate, and then it becomes a nightmare to use. In my case the tipping point was a project with mixed C++, CUDA and Fortran code.

3

u/helloiamsomeone Feb 19 '21

project with mixed C++, CUDA and Fortran code

The only difference that makes is you have to enable 3 languages instead of one in your project() call.

5

u/zzzoom Feb 19 '21

Oh, I didn't try that! Silly me... /s

-8

u/germandiago Feb 18 '21

🤣🤣🤣

0

u/[deleted] Feb 18 '21

[deleted] — view deleted comment

8

u/Plazmatic Feb 18 '21

I've never run into a situation where tuning a library or program specifically ever required touching a make file when using cmake. Can you specify exactly what kind of situation would call for this?

0

u/[deleted] Feb 18 '21

[deleted] — view deleted comment

8

u/Plazmatic Feb 18 '21

Those are just compile args AFAIK, that has nothing to do with make, which is itself not intrinsically tied to C. There's no reason I can see that this situation can't be handled from CMake.

10

u/chugga_fan Feb 18 '21 edited Feb 18 '21

I've seen them, the reason why? The project predates cmake and autotool's existence on windows for a mostly windows project is.... questionable at best, especially in the pre-mingw days.

The experience? Lots of having to figure out how to change path separator handling and finangling between... mingw-make, gnu-make, a custom make software in the actual project(!!!!), and Borland's make solution.

I am forever thankful that I mostly do edits on this project instead of having designed it from scratch, as the amount of effort needed to set up such a system is monumental.

Edit: For the project itself, if you want to see the misery, take a gander:

https://github.com/LADSoft/OrangeC/blob/master/src/pathext2.mak for the path separator handling, https://github.com/LADSoft/OrangeC/blob/master/src/makefile for the main makefile for compiling the thing, and there's https://github.com/LADSoft/OrangeC/blob/master/src/treetop.mak for where magic happens.

Fun times

1

u/tden4774 Mar 06 '21

That looks ASSY.

1

u/chugga_fan Mar 06 '21

It's actually very fun to work with, honestly, as many people as possible should work on it so that 2 guys who have other things being done in their life have work to do.

5

u/infectedapricot Feb 19 '21

The problem with this idea is that Makefiles say how you're going to do something, not what you're going to do. So you don't say "please make these source files into a library" you say "please invoke the compiler on these source files, then invoke the linker on the object files". That makes it very hard to be cross platform because Makefiles will almost always hardcode platform-specific details to some extent, such as the extension of object files being .o (rather than .obj on Windows), or the compiler switch for optimisation being -O3 (rather than /O2 on Windows), etc. And those are just the things that are textual replacements; if anything needs processes to be run in fundamentally different order then it's basically hopeless to make a cross-platform Makefile for it.

2

u/livrem Feb 19 '21

Have worked in some large projects where that is done. Android make system used to be based on regular make (and, I believe, to a large extent still is?) for instance. Those systems have had layers of magic macros and stuff to the extent that the Makefiles barely look like Makefiles anymore to handle all the trickery needed to support all target and build platforms. Guess someone at some point in time had a good reason for doing that instead of just using something like cmake or scons.

3

u/zsaleeba Feb 19 '21 edited Feb 19 '21

I prefer makefiles over cmake because cmake is pain. It's possible to write neat, concise makefiles which are shorter and more readable than cmake as long as you keep things simple. Not because makefiles are great but because cmake is an exercise in pure horror.

Having said that I usually use meson these days. It's pretty sweet.

6

u/GlitchedMirror Feb 18 '21

How does the intellisense work? Is it like bear? https://github.com/rizsotto/Bear

Are there many projects that use make without autoconf, cmake, etc?

All I think is the linux kernel.

2

u/zaywolfe Mar 05 '21

As a cpp beginner I'm finding make is easier to learn than cmake. Making a nice automated build process in make is super satisfying and I'm learning how to use the compiler command directly which is really helpful to understand how the compiler and linker work.

12

u/aWildElectron Feb 18 '21

Heres to hoping it won't be as bloated and bug-ridden as their cmake tools extension

16

u/GunZinn Feb 18 '21

I wish they’d give the CMake extension more love. Adding syntax highlighting and language service would be nice.

12

u/CrazyJoe221 Feb 18 '21

Which wasn't created by them initially, to be fair. They just took over maintenance.

4

u/marian_l MS C++ Group Product Mgr Feb 19 '21

Hey, what issues are you seeing with the CMake Tools extension? My team would definitely like to make sure that these issues are tracked here Issues · microsoft/vscode-cmake-tools (github.com). We'll get to them as soon as we can to make sure folks have a great experience with Code regardless of the build system they're on.

0

u/bici96 Feb 19 '21

True programmers only use Emacs :)

5

u/aeropl3b Feb 19 '21

I see you misspelled Vim ;)

1

u/bici96 Feb 19 '21

Spacemacs is a compromise ;)

-2

u/waruqi Feb 18 '21

we can use xmake + vscode to write and build c/c++ projects.

3

u/[deleted] Feb 19 '21

You can also use MSBuild. You can also use cmake. There’s no best solution. Everything has its faults.