Live data from Hacker News

What I Wish I Had Known About Developing C/C++ From Linux Before I Started

derwiki.tumblr.com

21–30 of 104 posts

Re: What I Wish I Had Known About Developing C/C++ From Linux Before I Started

#21
post #7

There's an incremental find option in Eclipse. Ctrl-j or was it Ctrl-i (or something like that) which is pretty nice and I wish all IDEs (read: IDEs) have that. That beats Ctrl-F any day. How did you do refactorings? Or you just don't?

In Vim, install ack, then put "set grepprg=ack" in your .vimrc. Then, open your project in Vim, do a ":grep ", and use ":cn", ":cnf", ":cp", ":cpf", ":cr", etc. to move about. Combined with strong knowledge of setting marks and using ":s/" substitutions, and I often wonder how people who use IDEs do refactorings! ;-)

I think you misunderstood what refactoring means in an IDE. Suppose you want to rename a method. There might be many other methods of the same name in different classes, local variables of that name in other methods, or even classes with that same name in differen packages. Eclipse automatically does all of this for you.

I honestly don't understand how regexps and strong bookmarking skills could help you - the editor needs true knowledge of the language to carry out this task.

Re: What I Wish I Had Known About Developing C/C++ From Linux Before I Started

#22
post #10
post #9

When I started developing in C in Vim there are two things I've gotten used to that I can't live without now: ctags and auto-complete (they help with eachother). Ctags is great, especially for navigating someone else's code. What does this function do? Just ctrl-] and suddenly I'm at its definition. Something in there I don't recognize, same thing. Ctrl-t to go back up the tag stack. Ive become so used to navigating…

Of course, if you use an IDE, it can do all of this for you and much more, and more accurately than ctags.

Ctags is just as accurate at scanning C declarations as an IDE, and with a bit of vim magic, it even auto-updates when you save files.

One thing to realize is that vim IS an IDE of sorts. Only, it's far more extensible for the same effort. (although, from my brief forays with emacs, emacs certainly beats vim for extensibility)

Re: What I Wish I Had Known About Developing C/C++ From Linux Before I Started

#23
post #21

Earlier quoted context omitted.

In Vim, install ack, then put "set grepprg=ack" in your .vimrc. Then, open your project in Vim, do a ":grep ", and use ":cn", ":cnf", ":cp", ":cpf", ":cr", etc. to move about. Combined with strong knowledge of setting marks and using ":s/" substitutions, and I often wonder how people who use IDEs do refactorings! ;-)

I think you misunderstood what refactoring means in an IDE. Suppose you want to rename a method. There might be many other methods of the same name in different classes, local variables of that name in other methods, or even classes with that same name in differen packages. Eclipse automatically does all of this for you. I honestly don't understand how regexps and strong bookmarking skills could help you - the editor…

[deleted]

Re: What I Wish I Had Known About Developing C/C++ From Linux Before I Started

#24
post #3

I use "screen" a lot, but I wish it had a better name. It helps if you search for "gnu-screen", but not much. Here's a tip that has saved me once or twice. If you start a long-running process, but forgot to use screen or nohup, bash lets you 'disown -h' its jobspec.

One day I took the time to work this out for my .screenrc, and it's served me well since: # Set up my status line at the bottom of every frame caption always "%{gb} %{ck}%m-%d %C %{gb} %{gb}%?%-Lw%?%{ck}%n*%f %t%?(%u)%?%{gb}%?%+Lw%?" All of the %{gb} things are color codes. It looks like this: http://shenani.gen.nz/~scott/screen-statusbar.png Binding ! @ # etc. to select 10, 11, 12, ... is handy, too.

That's good. Here's what I'm using:

  hardstatus alwayslastline
  hardstatus string "%n: %H (%h) %t"
For bindings, I find '10 '11 etc to be efficient enough. But I also make heavy use of :number to reorder my windows so that I know which one is which. There's also shift-A, to give them meaningful labels in the ctrl-A " list.

Re: What I Wish I Had Known About Developing C/C++ From Linux Before I Started

#26
Why are we taking C/C++ programming advice from somebody who has been doing it for just over a year?

And not to troll, but anyone who honestly believes vim is a better development environment than one of the mature Linux IDEs (Eclipse, Code::Blocks, KDevelop) is an idiot.

Re: What I Wish I Had Known About Developing C/C++ From Linux Before I Started

#27
Worse is NOT Better; use a safe and high-performance programming language and learn its foreign-function interface to call out to C and C++. Life is too short for core-dumps and premature optimization, plus you only have two feet to shoot at.

The better designed a language the better its development process feels. You can get immersed in a lowly Lisp, J, or Forth listener. Just a little black xterm with nothing else to it, and you feel productive already (never mind the amazing environments there are for Lisp.) BADLY designed and malignant languages have 3rd party tools to augment its functionality. There are things to bolt on, hammer in and stuff to bake into the scaffolding before you stuff in boxes. The C and C++ equivalent of a listener is `cat` or maybe the system-shipped vi or nano or pico. Can you seriously feel yourself getting something done?*

* (I will answer myself and say yes; I learned Unix programming over a serial line, but it was not an immersive experience; I had books on my desk and lap and was flipping back and forth to get anything done; a masochistic sort of fun, fueled by the mischievous possibility of breaking into another account ;-)

Re: What I Wish I Had Known About Developing C/C++ From Linux Before I Started

#28
post #22
post #10

Earlier quoted context omitted.

Of course, if you use an IDE, it can do all of this for you and much more, and more accurately than ctags.

Ctags is just as accurate at scanning C declarations as an IDE, and with a bit of vim magic, it even auto-updates when you save files. One thing to realize is that vim IS an IDE of sorts. Only, it's far more extensible for the same effort. (although, from my brief forays with emacs, emacs certainly beats vim for extensibility)

Emacs also supports ctags. I didn't find it very useful with C++ though, which is my usual language, since it didn't autocomplete member functions - I think it's supposed to work, though I couldn't be pushed to tweak it.

Cscope, as commented on the article's website, sounds quite interesting too.

Re: What I Wish I Had Known About Developing C/C++ From Linux Before I Started

#29
post #27

Worse is NOT Better; use a safe and high-performance programming language and learn its foreign-function interface to call out to C and C++. Life is too short for core-dumps and premature optimization, plus you only have two feet to shoot at. The better designed a language the better its development process feels. You can get immersed in a lowly Lisp, J, or Forth listener. Just a little black xterm with nothing else…

I didn't really mean for this to be a battle of which language is better, although I prefer not to use a screwdriver for a nail -- I'm doing systems level/kernel programming, so C makes a lot of sense.

Re: What I Wish I Had Known About Developing C/C++ From Linux Before I Started

#30
post #22
post #10

Earlier quoted context omitted.

Of course, if you use an IDE, it can do all of this for you and much more, and more accurately than ctags.

Ctags is just as accurate at scanning C declarations as an IDE, and with a bit of vim magic, it even auto-updates when you save files. One thing to realize is that vim IS an IDE of sorts. Only, it's far more extensible for the same effort. (although, from my brief forays with emacs, emacs certainly beats vim for extensibility)

What about conditionally compiled code, based on preprocessor definitions? And what happens when you change one of those definitions in the editor? Visual Studio, for example, will re-scan the source in the background.

And what about tokens created using the token pasting operator ## from include files that are included multiple times (e.g. code generation hackery)? Visual Studio will at least locate the include file which introduced the token, and of course will be able to complete on the token, aware of its type etc.

Post reply on HN