且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

适用于 Linux 的 C++ IDE?

更新时间:2023-11-12 12:44:58

最初:混淆

最初写这个答案时,我最近从 Visual Studio(具有多年经验)切换到 Linux,我做的第一件事就是尝试找到一个合理的 IDE.在当时这是不可能的:没有好的 IDE 存在.

Initially: confusion

When originally writing this answer, I had recently made the switch from Visual Studio (with years of experience) to Linux and the first thing I did was try to find a reasonable IDE. At the time this was impossible: no good IDE existed.

然后我意识到 Linux 中的 IDE 是带有工具的命令行:

And then I realised that the IDE in Linux is the command line with its tools:

  • 首先你设置你的外壳

    根据您的需要,您必须安装和配置几个插件才能使编辑器正常工作(这是一个烦人的部分).例如,Vim 上的大多数程序员将受益于用于智能自动完成的 YouCompleteMe 插件.

    Depending on your needs, you will then have to install and configure several plugins to make the editor work nicely (that’s the one annoying part). For example, most programmers on Vim will benefit from the YouCompleteMe plugin for smart autocompletion.

    一旦完成,shell 就是您与各种工具交互的命令界面 - 调试器 (gdb)、分析器(gprof、valgrind)等.您可以使用 Make, CMakeSnakeMake 或任何各种替代品.并且您使用版本控制系统管理您的代码(大多数人使用 Git).您还可以使用 tmux(以前也是屏幕)来多路复用(= 考虑多个窗口/选项卡/面板)并保留您的终端会话.

    Once that’s done, the shell is your command interface to interact with the various tools — Debuggers (gdb), Profilers (gprof, valgrind), etc. You set up your project/build environment using Make, CMake, SnakeMake or any of the various alternatives. And you manage your code with a version control system (most people use Git). You also use tmux (previously also screen) to multiplex (= think multiple windows/tabs/panels) and persist your terminal session.

    关键是,多亏了 shell 和一些工具编写约定,这些都相互集成.这样Linux shell 是一个真正集成的开发环境,完全可以与其他现代 IDE 相提并论.(这并不意味着单个 IDE 没有命令行可能缺乏的功能,但反之亦然.)

    The point is that, thanks to the shell and a few tool writing conventions, these all integrate with each other. And that way the Linux shell is a truly integrated development environment, completely on par with other modern IDEs. (This doesn’t mean that individual IDEs don’t have features that the command line may be lacking, but the inverse is also true.)

    一旦您养成习惯,上述工作流程的运行效果如何都不会过分夸大.但是有些人只是更喜欢图形编辑器,并且在最初编写这个答案后的几年里,Linux 已经为几种不同的编程语言获得了一套出色的图形 IDE(但据我所知,不是 C++).即使 - 像我一样 - 你最终没有使用它们,也请尝试一下.这只是一个小而有偏见的选择:

    I cannot overstate how well the above workflow functions once you’ve gotten into the habit. But some people simply prefer graphical editors, and in the years since this answer was originally written, Linux has gained a suite of excellent graphical IDEs for several different programming languages (but not, as far as I’m aware, for C++). Do give them a try even if — like me — you end up not using them. Here’s just a small and biased selection:

    • For Python development, there’s PyCharm
    • For R, there’s RStudio
    • For JavaScript and TypeScript, there’s Visual Studio Code (which is also a good all-round editor)
    • And finally, many people love the Sublime Text editor for general code editing.

    请记住,此列表还远未完成.

    Keep in mind that this list is far from complete.

    1 我从 dsm 的评论中窃取了那个标题.

    1 I stole that title from dsm’s comment.

    2 我以前在这里指的是 Vim.虽然普通的 Vim 仍然非常强大,但 Neovim 是一个很有希望的重启,并且它对一些旧疣进行了现代化改造.

    2 I used to refer to Vim here. And while plain Vim is still more than capable, Neovim is a promising restart, and it’s modernised a few old warts.