views:

484

answers:

6

Hi I am learning C++ and at the very beginning used a Command-line... then I started using Xcode (and since then couldn't switch back to command line) and was just wondering some specific reasons/situations to use Command-line instead of IDE...

A: 

You use command line when you want to automate your software builds. That's typically done when you are ready to release your software, and you need to do other things such as installer packaging in addition to software compilation before you can deliver the software to the users.

Beyond that you should always use an IDE for debugging, compiling and code editing purpose.

Ngu Soon Hui
Always? That's a little too broad :) I can think of lots of instances, with real products, where an IDE is overkill (and therefore unnecessary)
KevinDTimm
Can't say I agree. Might just be my UNIXy heritage, but I'm plenty productive with `gdb` + `vim` + `make` -- and moreover, using those means I can be productive with nothing but a low-bandwidth SSH connection from a netbook in who-knows-where.
Charles Duffy
+1 Charles - I love watching noobs struggle with their GUI configuration errors while I'm getting work done. But, they're married to that GUI. Watch them mouse around from character to character sometime (mouse/type/mouse/type/ad nauseum), it's enough to make you cry.
KevinDTimm
+20  A: 

More efficent for large systems - Try opening a VS solution with a 100 projects and 10,000 files.

Simpler for a lot of tasks, you edit in one window, run make in another, have gdb in a third.

Easier to automate tasks, often easier to work in teams or cross-platform if everyone has gcc and vi (or emacs)

Martin Beckett
+1 Exactly, my workflow mostly consists of switching between windows (using [GNU Screen](http://www.gnu.org/software/screen/)) and hitting uparrow-enter.
Greg Hewgill
Why would you put your 100 projects in a single solution? (not something you would/should do) Furthermore, do you think managing 100 projects and 10k files from the command line would be any easier? I think not. If anything the IDE would make you 10k times more productive :-)
Miguel Sevilla
@Miguel, you underestimate the power of BASH, find, grep, xargs, awk, sed and all the other UNIX commands. Sure, you'd be horribly inefficient on the Windows commandline which absolutely sucks, but on any UNIX variant, BASH+autocompletion+UNIX utilities will beat any GUI in terms of power and speed.
Michael Aaron Safyan
@Michael: Windows now comes with PowerShell which is actually ahead of all Unix cmd shells I have tried (bash, csh, tcsh).
Nemanja Trifunovic
ahead? what about the customer system where they haven't installed PS yet? not a prob in the *nix world, what you need is already there.
KevinDTimm
PowerShell seems nice, but who knows how to use it? There must be a few thousand tutorials out there about UNIX scripts/bash, but not PS.
Qwertie
@Nemanja: PowerShell is trying to solve a problem that does not exist. The UNIX shells when combined with all the othe GNU tools are just as powerful.
Martin York
+8  A: 

A big one for me is the editor. I really love vim, and it's pretty rare that an IDE has good vim emulation - especially since I use dvorak and have to remap a lot of the keys. For a lot of other people, they'd say the same thing except that they'd choose emacs.

Most IDE editors pale in comparison to the like of vim or emacs. There are features that you miss out on or are a lot harder to get to work well. For instance ctags definitely helps you be able to hop to the definitions of functions in vim, but it is nowhere near as good as a lot of IDEs can do since they actually understand the language. And of course, debugger integration and project management and the like aren't going to work as well in vim or emacs because they're not full-blown IDEs (though you can do a lot of that stuff with them). But often, the power of vim or emacs overshadows whatever the IDE has over them.

Also, as far as command-line editors go, they can be run on the command-line when you don't have access to an environment with a GUI, so there are plenty of situations where that flexibility is a big plus.

Of course, it would be great if you could combine all of the great features of vim or emacs with a full-blown IDE - and there are some attempts to do so - but there are always problems with it, and even the best attempts are far from perfect. So, you're often still stuck with the choice of vim or emacs and the features that they bring or an IDE with the features that it brings.

EDIT: Going into why vim or emacs is far more powerful in many respects than your typical IDE could get quite lengthy, and there are already several questions on SO which cover that.

This is a great answer on emacs: http://stackoverflow.com/questions/35809/why-are-vi-and-emacs-popular/35929#35929

This is a good article on vi that seems to get linked to frequently: http://www.viemu.com/a-why-vi-vim.html

For a quick attempt on my part to give some reasons why vim is more powerful:

Your typical IDE is basically a souped up notepad from a text-editing standpoint. You type in text and use your mouse to navigate around (which while sometimes quite useful, it can be quite a bit slower than just using your keyboard). They add code-specific features like code completion, automatic code indenting, the ability to jump to function definitions, refactoring tools, etc. (hence why IDEs can be so useful) But their basic text editing abilites are generally pretty poor. They might add some useful features like ctrl-d to delete a line, but what they add is generally very limited compared to what you'd get in vim or emacs.

Take deletion (a very basic operation) as an example. In vim, you can use the delete operation with any motion command, making for a potentially staggering number of ways to delete things.

  • dd Delete an entire line.
  • 5dd Delete 5 lines.
  • dj Move the cursor up, deleting everything to the left on the current line and everything to the right on the line above.
  • dG Delete everything from here until the end of the file.
  • 7dgg Delete everything between here and line 7.
  • d% Move to the brace or paren which matches the next paren or brace (whichever comes first) and delete everything between here and there, including the brace or paren that you jump to
  • dw Delete everything between here and the next beginning of a word
  • de Delete everything between here and the next end of a word
  • D Delete everything between here and the end of the line
  • d0 Delete everything between here and the beginning of the line
  • d^ Delete everything between here and the beginning of the first word on the line
  • dty Delete everything between here and the next occurrence of y on this line (or nothing if there are no y's between here and the end of the line)

The list goes on and on. And that's just for delete. The same goes for a whole list of other basic commands. And that's just basic commands. There are many, many more commands which are more advanced and quite powerful. Vim can do so much that most people who use it use only a fraction of what it's capable of.

Most IDEs don't even have a fraction of a fraction of such editing capabilities. They have many other programming-specific and language-specific features which vim and emacs either lack or in which they are much harder to get to work - such as good, context-sensitive code completion, refactoring tools, project management, etc. But as for text-editing capabalities, most IDEs just can't compare.

Jonathan M Davis
@Jonathan, the Xcode editor is actually quite good, though.
Michael Aaron Safyan
@Michael Oh, it may very well be. I've actually never heard of Xcode before. I may have to try it out. But most IDEs have fairly poor vim emulation if they have any at all. And I'm so used to vim that unless I can basically make an IDE act exactly like vim (at least for the commands that I use), it can be highly frustrating.
Jonathan M Davis
@Jonathan You didn't really quantify how "Most IDE editors pale in comparison to the like of vim or emacs". I'm an avid IDE user and also have used Vim and even Emacs in the past and I don't see how IDEs are so sub-standard standard compared to Vim/Emacs. Please explain.
Miguel Sevilla
@Miguel, it's a "religious" issue.. I know that those who have mastered emacs, despite its counter-intuitive key bindings, are incredibly fast and efficient with it. I aspire to one day master it as well, but for now I'm too lazy to do so and am more comfortable with GEdit on Linux and Xcode on Mac OS X.
Michael Aaron Safyan
@Michael - the xcode editor is an abomination - and that's comparing it to nearly every other editor out there (IDE or command line). I use the tools available, and try to stay away from religious issues (live and let live) but can say, without a doubt that the current 'worst' editor lives in xcode :)
KevinDTimm
@KevinDTimm, really, compared with what? I can tell you it's 10 times better than Visual Studio. But, really, it's a matter of what you are used to and what you like. Although I agree that the default settings and the default syntax highlighting is pretty bad, but that's why I use my own configuration and style: http://sites.google.com/site/michaelsafyan/coding/articles/other/xcode-codemage-color-theme
Michael Aaron Safyan
A: 

Commandline builds can be automated, and using standard tools such as CMake for your commandline builds make such builds cross-platform (note you can build an Xcode project from the commandline using xcodebuild, but that only works on Mac OS X with Xcode). Automation is incredibly important, because it allows you, for example, to create a "hook" for your version control system to build the project and reject code that doesn't compile or to have a continuous integration server periodically build your project, so that you can easily tell when breaking changes to the code have been made and fix them quickly.

In addition to portability and automation, the commandline is just faster. If you are using a Makefile project or something like the C++ Project Template which uses CMake but has a Makefile wrapper, then all it takes is the simple command "make" to build. The second time you build, you only have to hit the up arrow, and then hit ENTER for it to rerun "make". Although beginners with the commandline may be not be very fast and may find the GUI / IDE easier, once you have used the commandline for a while, it becomes much much faster than doing it with a GUI, and all those mouse movements and clicks seem slow and a waste of effort.

Michael Aaron Safyan
There are IDEs which allow you to run arbitrary commands for your build and thus allow you to retain the advantages of builds on the command-line, but there are also plenty which don't. So, it definitely depends on the IDE that you're using.
Jonathan M Davis
Miguel Sevilla
@Miguel, I acknowledged that you can build on the commandline (xcodebuild); however, it is not a portable build; you could not run that command on Windows, for example. I agree that maintaining Makefiles are horrible, which is why I use CMake.
Michael Aaron Safyan
@Jonathan, arbitrary commands are not the issue; portability is. Actually, it's better to not support arbitrary commands, in my view; allowing arbitrary commands allows one to rely on commands that are specific to the environment or platform. This is a major failing of Makefiles and where CMake really shines.
Michael Aaron Safyan
"up and enter" to re-run make is a poor example given that you'll probably be typing more than a single command into your shell. IDEs always have a one-key build command; good IDEs let you choose the key (I'm partial to F7 myself).
Qwertie
+1  A: 

At least in UNIX, the command line tools are mature. The bugs I have to deal with are highly obscure at this point. vi, make, gcc, gdb - these tools are, in some cases, 20 years old or more. Tried, tested, proven.

Also, they are ubiquitous. Everyone has vi, make, gcc. I don't have to worry about not having my tool-du-joir. I can go to virtually anyones box, and no problem, I can compile, write, debug without any need to learn some fancy tool.

sheepsimulator
+2  A: 

First, there's the increased choice. If you use an IDE, you use the tools that are specifically compatible with it, which may not be the tools you prefer. There are a lot of things that you can get in an integrated package or as components, and people go both ways.

Second, lots of developers got used to Unix tools, which are mature, very powerful, and meant to be used by themselves. There isn't a tradition like that on Microsoft Windows, and IDEs have ruled there since Turbo Pascal. (The big advantage Turbo Pascal had was that, in the days before any sort of multitasking, it wasn't necessary to start and stop the editor, then run the compiler and linker separately before running the test.)

Third, it's really, really easy to automate anything you'd do from a command line. It's harder to do such things in a GUI of any sort, both in that the tools are much harder to develop and in that they're harder to learn. Again, there's a culture gap here, as the Unix tradition is to deal with complicated procedures by automating them, and the Microsoft tradition is to build GUIs and wizards.

Fourth, for handling complicated systems, there's still no method clearly better than a human-readable text representation. The syntax of Unix makefiles is bad, but it would have avoided the issue I had recently, where the configuration of an after-build step in one setup of a Visual C++ project file was wrong in one case, and it was hard to spot. Using a makefile and vim, I can simply and reliably change how a given project will compile and build. It's a lot harder with Visual Studio.

David Thornley