r/cpp_questions • • Apr 26 '22

OPEN Is using emacs just a circle jerk?

Or am i using it wrong? I like gnu philosophy&environment but IDEs look like more practical. But i want to see experienced guys' opinions anyway.

0 Upvotes

53 comments sorted by

25

u/flyingron Apr 26 '22

What on earth does this have to do with C++?

16

u/[deleted] Apr 26 '22

So you use Vim, huh. I bet you even use spaces over tabs...

1

u/bert8128 Apr 26 '22

Brian Kernighan uses spaces.

0

u/[deleted] Apr 26 '22

[deleted]

2

u/shadowndacorner Apr 26 '22

Using caps lock at the beginning of words.

I used to have a coworker that did this and it confused the shit out of me. Like, I get it if you're going to be writing stuff in screaming snake case, but for all capitalization???

1

u/ubermenschslav Apr 26 '22

Yes it could be wrong sub but i use it for coding c/c++ so asked it here.

5

u/MysticTheMeeM Apr 26 '22

People are fastest with whatever they are comfortable with. Their decision may not be the best, but they will work the best with it.

With that in mind, I wouldn't recommend Emacs (or vim or nano or any other terminal-based editor) for the general user. There are times where knowing one may prove helpful (for example, when utilising a remote terminal and a visual editor may not be available) but these situations are rare and I can't imagine you'd find yourself in a situation without having a basic grasp on the concept.

With that being said, there are advantages to terminal editors, they typically use fewer resources allowing them to be faster (think about how long it takes VS to start, for example) and keyboard shortcuts are generally faster to input than mouse ones (doubly so because the increased speed may make the program more responsive and "snappy").

At the same time, notice I used the word editor, not IDE. These programs are great for putting data in a file and saving it. They typically don't have a concept of development. They won't be linked to your compiler or build system which will have to be invoked manually (which is fine if you know how to do it, but if you don't then refer to my opening statement). IDEs on the other hand provide a much higher degree of functionality out of the box. This isn't to say that you can't modify your editor/environment to make these tasks easier, simply that it isn't the default.

The takeaway is that it's all opinion. It'll work if you can make it work.

4

u/no-sig-available Apr 26 '22

(think about how long it takes VS to start, for example)

Have you tried this lately?

Takes about 2 seconds on my desktop system.

1

u/MysticTheMeeM Apr 26 '22

I use it daily, it doesn't take long but it takes longer than a terminal editor.

However, the impressions from pre 2013 VS still linger.

1

u/ubermenschslav Apr 26 '22

Is your text editor still provides formatting, auto completion, auto code generation like ides? If not, basic difference with gui editor and terminal editor is mouse i think?

2

u/[deleted] Apr 26 '22

Terminal editor is to IDE, what command line interface is to GUI. (S.A.T. question in 2069)

The IDE is taking all the 'extras' and bundle it up into one easy-to-use program for you.

The text editors leave you to link and configure all those quality-of-life additions. The upside is more customization available, the downside is it's harder to implement.

1

u/camilo16 Apr 26 '22

The best Ide like editor is VS code for this reason, the integrated terminal is a lovely thing.

1

u/MrPezevenk Apr 27 '22

Many IDEs have integrated terminals.

1

u/khoyo Apr 29 '22

Since this is an emacs post, maybe it should be pointed out that emacs has (multiple) integrated terminals too.

15

u/livrem Apr 26 '22

Use it every day. If something is text I am going to use my favorite text editor to edit it. I do not want to switch editor just because I open a C++ file. I use emacs for almost literally everything on a computer. I fully understand if some prefer vim or sublime or whatever Can't say how much of emacs is actually awesome or what is just what I am used to, but it is the text editor that works for me.

9

u/celestrion Apr 26 '22

IDEs look like more practical

They do look that way, but are they really? Probably, if all you ever edit is C++.

But some of us use our text editors for programming in a great many languages (possibly including homespun DSLs), writing long-form documents, writing music, and many other ways of communicating with the computer.

The classic Unix editors are languages unto themselves, in a way that a CUA-compliant editor will never be. If you learn the language of an editor like that, you'll be more productive in whatever you're editing, and you'll be making small edits far more often than you'll use the "refactor" or "rename class" features of an IDE.

5

u/Greenskid Apr 26 '22

To some it is, but to many others it is not. I came to know a little about Vim and Emacs some years ago during my university years, and could not understand why anyone would use either. I much preferred using a professional IDE. But over the years as I looked for incremental improvement in my workflow, to my utter surprise, I found that Vim's modal editing is what I needed to improve my workflow, and actually had joy while learning it. It was like a light bulb going off. I went through it all on my own, so there was no circle to jerk. I was very happy with just Vim and did not think there was any reason I would use Emacs. But in a similar manner when I listed out some further improvements I wanted, to my surprise Emacs ended up being the only thing around that addressed them. These are not user friendly tools, and they require significant investment before the rewards really kick in. For some it's like a hobby and brings joy. I think if you like coding for joy and not just for work, then chances are high that Vim and Emacs become cherished tools.

1

u/Tychotesla Apr 27 '22

Did emacs replace vim for you, or do you still find vim has a place for you?

Context: In my first day in school the professor described vim as having a steeper learning curve than emacs, so I went with vim as I knew I didn't mind investing some time and I figured vim must have some extra power.

Later I found out that maybe I'm missing out on org-mode (I spent a while looking for a planner/notebook and eventually landed on Obsidian), so I've always wondered if I should be slowly dropping vim for emacs.

1

u/Greenskid Apr 27 '22

I use the Vim emulation package in Emacs (Evil mode). So I get the best of both worlds. The Doom Emacs config framework is a nice easy introduction to Emacs for Vim users. I highly recommend it.

5

u/regaito Apr 26 '22

I use a magnetized needle and write directly to ram.

https://xkcd.com/378/

3

u/jeffbell Apr 26 '22

I sometimes use it, especially if I have to do some regex text substitutions.

I’ve been using it for 40 years now, so my fingers know what to do.

But lately Xcode and VSCode and other IDEs are already set up so I go with them.

3

u/bert8128 Apr 26 '22

I work on a program that compiles under Visual Studio and gcc. I have been watching some some people using EMacs for years in this environment. I cannot see any advantage, as measured by programmer productivity. There may be cases where eMacs is better and I appreciate that being able to use the same tool everywhere can be seen as advantageous. But not on this project. This is not an opinion. Those people on my project who choose eMacs do so because they feel happier, but there is no increase in productivity, probably in fact the reverse. I use VS for c++ and VS code for Python and don’t find any problem switching.

2

u/raevnos Apr 26 '22

I find it awkward to try to use anything but emacs to write code in.

2

u/[deleted] Apr 27 '22 edited Apr 28 '22

I think learning emacs requires more time than it is worth.

But, I found several features of emacs very useful that I haven't seen in an IDE (maybe because I haven't looked hard enough)

  1. cut stack: emacs keeps a "stack" of cut regions of text, rather than just the last cut, and you can select which one to paste

  2. undo chain: if you write a paragraph, undo writing it, write a character, and then realize you want the paragraph back, you can undo your undo. This is better than "redo" because an undo chain keeps all the branches of mistakes.

  3. repeat series of keystrokes: if you have a lot of lines of text you want the same edit on, you can have emacs memorize a set of keystrokes, then apply that set of keystrokes repeatedly. This speeds up tedious repeated edits.

  4. ido mode file switching: switching between files or opening an existing file is really easy with emacs. I often only remember part of a filename, and emacs is able to quickly match it. This is much faster than searching in a file browser, especially if you have lots of files in the directory and you don't remember the first character.

  5. multi language support: I work on a lot of multilanguage projects, and being able to seemlessly switch between cmake, c++, python, VHDL, verilog, tcl, bash, asciidocs, LaTeX, etc. in the same editor without having to have some concept of a project is really helpful for me.

  6. side by side viewing: splitting a window to open the same file side-by-side or two separate files side-by-side is pretty easy. Closing one is really quick too.

  7. tool automated indention: I know probably all ide's do this, but I like that emacs can take a file or region and standardize the indentation, swap tabs for spaces (or vice versa if you're one of the tabs people).

features (1) and (2) are really useful to me because they prevent me from losing work to careless mistakes.

emacs can support "tags" to jump to functions like an IDE could. The feature set in emacs is immense. I'm sure my knowledge doesn't even scratch the surface. But, I only need to know enough for it to be useful for me.

you could probably get similar features in an IDE that supports vim keybindings through vim. But, then you would have the same problem with the learning curve.

The emacs learning curve is steep enough that I wouldn't recommend it to a new developer. I think vim is useful in more contexts, and obviously focusing on development instead of your text editor is a good option, but I do think that emacs is genuinely useful. Now that I'm on this side of the learning curve, I wouldn't want to switch.

1

u/JerkyWaffle Apr 26 '22

I like vim fine and probably won't switch until I really need the added functionality of an IDE, for work or for larger, more "professional" projects.

1

u/ShakaUVM Apr 26 '22

I'll flip it around and ask what common tasks an IDE can do faster than using Vim with a few plug-ins installed?

Most people are afraid of Vim and Emacs because it takes time invested into the tool to learn it but if you ask people who know Vim well around 0% ever want to go back, it's that good.

When I use VS or VS Code I always use the Vim plugin, so it's kind of a best of both worlds compromise.

1

u/MrPezevenk Apr 27 '22

Definitely depends on what you mean by "a few plugins". But you can definitely do far more in far less time than it would take for someone to learn and customize emacs etc. I haven't really seen a very good argument for why they are so much better than IDEs. Used them both, I think they do some things well and are more convenient sometimes, still a good IDE just offers more...

1

u/ShakaUVM Apr 27 '22

Definitely depends on what you mean by "a few plugins".

I only use CoC right now.

a good IDE just offers more...

What more does it offer?

2

u/MrPezevenk Apr 27 '22

Out of the box you have a graphical debugger, good autocompletion and many refactoring options, multi cursor, automatic code generation, abbreviations and automatic boilerplate, file system view etc and on top of that you also have an integrated terminal so it's not lacking in that regard. It's not impossible to find plugins for all these things but it's not that easy. I've spent so much time trying to get emacs to comply.

1

u/ShakaUVM Apr 27 '22

CoC does the completion stuff, multicursor has support with no plug-ins, gdb is an excellent debugger, nerdtree does file trees if you are into that stuff (and is much better than Visual Studio's, which does its best to hide where files are on disk), refactoring is easy, and then on the positive side I don't have to waste my time doing repetitive tasks like with an IDE.

1

u/MrPezevenk Apr 27 '22

It's the first time I hear about vim having multicursor without plugins. There is plugins for multicursor so why would there be plugins if there is support for multi cursor?

gdb is an excellent debugger,

Gdb is good, but when you use a graphical debugger it's just infinitely more convenient.

refactoring is easy

What do you mean "it's easy"? Maybe if you have a very small file, otherwise it's not easy, it is very annoying.

I don't have to waste my time doing repetitive tasks like with an IDE.

I don't know what you mean "repetitive tasks".

1

u/ShakaUVM Apr 27 '22

Copying and pasting a line 7 times in octree code and changing each line slightly, for example. Copy pasting the values of an enum into a switch statement, that sort of thing.

1

u/MrPezevenk Apr 27 '22

You can do macros in VS code and other IDEs with easy to install plugins if that's what you mean. I typically use JetBrains IDEs, they support macros out of the box. Furthermore, many have automatic code generation built in that does more or less that (not your specific example necessarily).

I think the reason people think there is a bunch of stuff that Vim and Emacs can do that more modern editors can't is because they've spent a lot of time to see what Vim and Emacs can do, but no one bothers to learn what VS Code can do.

1

u/ShakaUVM Apr 27 '22

I use VS Code when I work on Windows machines, but I'm not talking about macroing specifically.

How would you paste a line 7 times in VS Code?

1

u/MrPezevenk Apr 27 '22

Idk you paste it 7 times lol

→ More replies (0)

1

u/[deleted] Apr 26 '22

Doesn't Emacs (with rtags) have unusually good support for C++?

1

u/[deleted] Apr 26 '22

Always has been

1

u/MrPezevenk Apr 26 '22

Yeh it kind of is. But it's not like it doesn't have some benefits. Like often you want to do other stuff than just write C++. Emacs can be very good at handling a bunch of different stuff at once, although there is a learning curve. I do generally prefer IDEs but I also use emacs for some things. Sometimes it's faster to start, snappier and less distracting.

1

u/v_maria Apr 27 '22

Never took the emacs pill. I don't see the point

1

u/rfisher Apr 27 '22

I don’t use emacs, but I use vim. I haven’t seriously used an IDE since the 1990s.

I wouldn’t want to tackle trying to get my company’s cross-compiling toolchain & build system to play nicely with an IDE. (I’m sure it is possible, but I’m not convinced it’d be worth my time.) Even my coworkers who use IDEs essentially just use them as text editors.

Maybe in a different job I’d use an IDE. Maybe not. Context counts for a lot. Also, I eventually got to an age where switching between different editors wasn’t as easy for me anymore. So using one editor as much as possible whenever editing text makes things go much smoother. I mostly settled on vi/vim because it was the one editor that was already installed on all the systems I used.

1

u/CowBoyDanIndie Apr 26 '22

I think people like it because how easy it is to write extensions and customize it. If you customize it enough it becomes more powerful than many IDEs

1

u/MrPezevenk Apr 27 '22

I don't really believe that's the case, you can spend a hell of a lot of time to customize it and you will get IDE-like functionality, but wouldn't say it would be MORE powerful, at least I haven't seen anyone do that. Your time would be better spend learning to use the IDE better. I like emacs, I use it a lot, but modern IDEs are more practical most of the time.