4 ms·
I tutored a C++ beginners course on Linux a few times. I have had people ask me for help because the error messages were so long, their terminal history wasn't
by lqet 2y ago
I tutored a C++ beginners course on Linux a few times. I have had people ask me for help because the error messages were so long, their terminal history wasn't large enough to scroll back to the first error. Even if you have basic bash skills, just piping the compiler output to less or head also doesn't work, because the errors go to stderr. It's an incredible source of frustration for beginners.
- wglb 2y agoWouldn't it work if you did 2>&1 as part of the redirect?
- rocqua 2y agoYes, but if someone only just learned about less and piping, they probably won't know about fd 2 being stderr, fd based redirection, and hence don't understand it at all
- professoretc 2y agoFor my beginner programming class, I have them use a script `compile` which handles compilation and linking, while also enabling enabling all the warnings/errors I think are helpful, and also doing the above redirection. An absolute beginner doesn't gain anything from invoking `g++` directly.
- paulddraper 2y agoYes, but most beginners have never seen (or remember) that.
- wglb 2y agoKnowing about some of these shell bits would be useful for someone learning about C++.
- jprete 2y agoI know about that mechanism but I use it so infrequently that I have to look it up every time; the syntax doesn't really match anything else I know. It's also hard to look up because even the right search terms fetch a lot of nearby-concept results so I have to dig for the exact idea. (Probably this is an ideal LLM question though!)
- LoganDark 2y agoThere used to be a search engine called SymbolHound whose entire shtick was to not ignore special characters in the query. Unfortunately it looks like it's gone now, seemingly without so much as a farewell. Their posts just stopped.
- wglb 2y agoIt seems to be part of my muscle memory. I likely got that memorized from the time that I wrote a shell (/bin/sh) tutorial back in the day.
- bogwog 2y agoKonsole's default scroll-back is 1000 lines. I wonder what is the simplest, most realistic error a beginner would encounter that exceeds that?
- usefulcat 2y ago> just piping the compiler output to less or head also doesn't work, because the errors go to stderr |& is your friend: g++ foo.cc |& less
- imron 2y agoHow did I not know this until now. Fantastic.
- dmitris 2y agoI like to do `g++ foo.cc |& tee /tmp/out` then you can `less /tmp/out`, grep the file, open it in an editor etc.
- fransje26 2y agoOr, if you want to save the output to a log file: g++ foo.cpp 2>&1 | tee ./log or, the shorthand of 2>&1 |: g++ foo.cpp |& tee ./log
- jiggawatts 2y agoIf only there was some sort of invention that could be used to replace a virtual teletypewriter that could somehow parse the error messages and put them into a convenient list that could be navigated using simple visual paradigms instead of bits and pieces of a shell scripting engine… /s
- jcelerier 2y ago> I tutored a C++ beginners course on Linux a few times. I have had people ask me for help because the error messages were so long, their terminal history wasn't large enough to scroll back to the first error. A non-problem if you use any IDE which has been able to group error under foldable menus (such things have existed on Linux for longer than some of the people you are teaching may have been on this planet)