Live data from Hacker News

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

derwiki.tumblr.com

51–60 of 104 posts

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

#51
post #49
post #46

Earlier quoted context omitted.

"the post-modern "developer productivity" family of languages' lack of core dumps is a bug" Lisp doesn't dump core, it will drop you in a debugger prompt where you can Frankenstein your programmer to life as you wish. Forget Lisp, Scheme and other languages with full continuations will give you the entire run trace of your program in a video tape, where you rewind and fast-forward as you wish. C is not a language who…

FWIW, I don't consider CL a member of the "developer productivity" gang of languages. In practice, it is much more like a better C than it is like python: you have C's relative poverty of libraries and richness of tools. Still, I meant what I said. "Lisp doesn't dump core, it will drop you in a debugger prompt..." What if the user isn't a developer, but, y'know, a user? On the other side of the country, who doesn't c…

You didn't read what I wrote earlier, so here is your Lisp core dump:

  (handler-bind ((error #'(lambda (e)
        (save-lisp-and-die "lisp.core"))))
           (YOUR-PROGRAM-ENTRY-POINT))
Autopsy is not that hard with Lisp ;-)

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

#52
post #48
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.

The biggest problem with screen is that it breaks ordinary virtual terminal scrollback, which is something that I can live with, but…

"Ctrl-a [" will put you enter the copy buffer mode and let you scroll up

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

#53
post #51
post #49

Earlier quoted context omitted.

FWIW, I don't consider CL a member of the "developer productivity" gang of languages. In practice, it is much more like a better C than it is like python: you have C's relative poverty of libraries and richness of tools. Still, I meant what I said. "Lisp doesn't dump core, it will drop you in a debugger prompt..." What if the user isn't a developer, but, y'know, a user? On the other side of the country, who doesn't c…

You didn't read what I wrote earlier, so here is your Lisp core dump: (handler-bind ((error #'(lambda (e) (save-lisp-and-die "lisp.core")))) (YOUR-PROGRAM-ENTRY-POINT)) Autopsy is not that hard with Lisp ;-)

You're absolutely right that I skipped a whole paragraph of your reply; mea culpa.

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

#54
post #53
post #51

Earlier quoted context omitted.

You didn't read what I wrote earlier, so here is your Lisp core dump: (handler-bind ((error #'(lambda (e) (save-lisp-and-die "lisp.core")))) (YOUR-PROGRAM-ENTRY-POINT)) Autopsy is not that hard with Lisp ;-)

You're absolutely right that I skipped a whole paragraph of your reply; mea culpa.

+1, no problemo hermano!

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

#55
post #31
post #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.

I upvoted this by mistake. But I don't believe "not to troll" and "anyone who believes vim is a better environment is an idiot" can go together. And this is coming from an emacs user ;)

Not to mention the "would you say that to someone's face?" test. There might be an argument for Eclipse (although I think it's terrible compared to Emacs:-), but calling people idiots is not the way to make that argument.

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

#56
strace is another extremely useful tool. Sometimes it's really nice to be able to see exactly what's happening at the OS/program boundary (what exactly are we reading from the file? from the network?), and strace can do that in a very non-intrusive way - no root reqired, no recompile required.

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

#57
post #52
post #48

Earlier quoted context omitted.

The biggest problem with screen is that it breaks ordinary virtual terminal scrollback, which is something that I can live with, but…

"Ctrl-a [" will put you enter the copy buffer mode and let you scroll up

Sure, but that's only a poor substitute. I can't just press shift + pg [up,down] or drag scrollbar in the terminal emulator or use mouse wheel.

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

#58
post #56

strace is another extremely useful tool. Sometimes it's really nice to be able to see exactly what's happening at the OS/program boundary (what exactly are we reading from the file? from the network?), and strace can do that in a very non-intrusive way - no root reqired, no recompile required.

Seconded. That apache process is chewing cpu, is it spinning in an inf loop internally to userspace? No, strace shows it repeatedly doing backend conn/op/disconnect - aha!

Another trick in this vein is/was to use 'pstack' to pull a C backtrace from a looping process. If you do that every second for 10 secs, you'll probably find where the process is looping. As a bonus, it also acts as a poor-man's-retroactive profiler (process X intermittently takes 30s to handle it's job instead of 2s - watch for one and when it happens, strobe the process with pstack to see what it's up to). Can be used in production, no need to deploy profiling build and run for ever to catch problem, etc.

(And a variant of this trick for interpreted languages is to hook an unused signal (SIGUSR2?) in your language to say "dump me a perl/python/etc backtrace to the log file". Assuming the loop is in your app code this will give you a language-level backtrace if you strobe the process with the signal)

NB1: pstack doesn't do anything which scripted gdb couldn't do, it's just more convenient

NB2: pstack is unavailable on 64-bit arches?

NB3: pstack needs some symbols to work with in the binary, which probably won't be the case with your system apache+mod_xxx

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

#59
post #12

c++filt - an absolute necessity. Also, he should have just pointed out that all IDEs are ass for C++. Java is simple enough that an IDE can be a big help, but C++ is too complicated and too slow to compile. (The remote access thing is just a matter of the work environment being adapted to one set of tools and not another -- the real issue is that text editors beat IDEs for C++.) Otherwise, an excellent list.

The real issue is that C++ is too complicated and too slow to compile. Languages that are easier to throw together a reasonable parser for (Lisps, Smalltalk, Lua, or even C) have a much lower barrier to entry for development tools. Keeping the language syntax simple enough means that somebody scratching an itch can write something useful in an afternoon or a weekend, rather than taking a team and months.

> Languages that are easier to throw together a reasonable parser for (Lisps, Smalltalk, Lua, or even C)

Heck, even Java.

People (rightfully) complain a lot about how verbose some parts of java are (like how instead of anonymous functions or functions that can be passed as a parameter you have anonymous classes), but ignore the fact that the designers intentionally made that sacrifice to maintain consistency.

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

#60
post #57
post #52

Earlier quoted context omitted.

"Ctrl-a [" will put you enter the copy buffer mode and let you scroll up

Sure, but that's only a poor substitute. I can't just press shift + pg [up,down] or drag scrollbar in the terminal emulator or use mouse wheel.

Yeah I know, Shift+PG[up, down] not being usable is kinda a bummer but as a bonus you can use / to search the scrollback buffer plus all the vi movement keys are available.
Post reply on HN