1. 3

    As an ex-compiler writer have have plenty of sympathy for those trying to make a living selling compilers, but times change.

    The problem used to be competition from many small compiler companies, then the amount of memory available on developer machines exploded, which is the critical factor holding back open source compilers.

    1. 1

      I’ve updated the title to include the date, since it matters in the context of the paper.

    1. 6

      Gearing up for a work conference in Phoenix, USA. I’ll be team teaching a class on embedded C programming and I get to talk to a bunch of customers about compilers, which should be enlightening. I’m supposed to be an “expert”, which is a little intimidating.

      My wife is coming along and when the conference is over, we’re going to do some hiking at the Grand Canyon. I’m really looking forward to the whole thing.

      1. 10

        I read this and I don’t see how it is exceptional to “all the others”. All I got was a list of things that need to be improved.

        1. 4

          The benefit is reproducible hermetic builds and never having builds with undeclared dependencies that only work by accident. No big deal for tens of files, but absolutely essential with thousands of files in half a dozen languages. I would have killed for bazel at one point in my life (but not installed a JRE… There are limits).

          As for why the post just highlights problems, it sounds like they’re making a new tool. Need to have problems to solve for that.

          1. 4

            In which case “Recommended Improvements for Bazel” seems like a more apropos title. That’s really my only issue with the piece: the title doesn’t match the content.

        1. 2

          A link to something more substantial than Amazon would be appreciated.

          1. 1

            Looks like @amontalenti managed to find a talk by the author about the book in the comments.

            1. 2

              I wrote a fast cat once out of actual necessity.

              I was working with an embedded system where, for installation/testing purposes (details forgotten), we had a service running in a VM that would help bootstrap a system. Part of this setup was a script that would run on the target, read a binary blob from a file descriptor and write it to the device. That reading was done with the target system’s implementation of cat.

              As it happened, the sending of the binary blob to the target turned out to be a significant bottleneck. After I profiled it, it turned out that cat was taking a long time to read and write the bytes. I looked at the source and found it was using fread and fwrite. I changed it to use read/write and the transfer time went down significantly. It was great because I’m fairly certain this was part of our automated build system to create images for the devs and the result was that build times went down a lot.

              So sometimes you really do need a faster cat.

              1. 2

                Why were fread/fwrite slow? Aren’t they thin veneers over read/write that do a bit of buffering?

                1. 2

                  For “buffering”, read “copying”.

                  With read/write, it’s just copying into a buffer (read), and then copying out of that buffer (write).

                  With fread/fwrite it’s copying into a buffer (read), then copying from that buffer to another buffer (fread), then potentially copying that back (fwrite), before finally copying it back into another buffer (write). That can really add up - even the read/write loop is more than we’d want ideally, hence stuff like splice.

              1. 2

                I’ve never heard of this joke, but if you want to find a cycle in a linked list, the canonical way to do it is to use two pointers and have one walk one step at a time, while the other walks two. If they are ever equal after they take a step, there’s a cycle. Using signals is – I think it’s safe to say – way over the top. (Unless that’s the joke.)

                1. 8

                  That is the joke. The way I heard it was: keep free()ing the nodes, and if there’s a crash (due to double-free) you found a cycle.

                  1. 2

                    I’ve heard of the two-pointer approach (with pointer variables typically given the names “tortoise” and “hare”), but I really like the double-free approach.

                    1. 1

                      Of course, free(x) could be a noop if you have a garbage collecting C (like Zeta-C)

                    1. 5

                      Adding story text that summaries/previews the story is frowned upon. It’s added for some things, like titles that don’t clearly indicate their content, which tends to happen with academic papers and some trade publications in PDF format.

                      In this case, the story text could have been something like “I reduced my technology use and ended up feeling better.” The current story text (a list of things with a sentence afterwards that explains the list) is not really helpful. I recommend avoiding such story text in future submissions.

                      1. 8

                        Sorry, was my first story submit. Thanks for the editing and help!

                        1. 5

                          No worries. And welcome to Lobste.rs!

                        2. 4

                          I removed it.

                        1. 2

                          They [TrueType fonts] look ugly in my opinion and rendering of these is slower (you can measure it).

                          It’s true they render slower. I have never found it to be a problem. (And I don’t get the author’s deep affection for the Terminus font.)

                          1. 5

                            It is strange, taste in fonts. I’ve searched for a different programming/terminal font a few times but Terminus looks best to me.

                            1. 4

                              It’s pretty much the difference between dot-matrix printing and laser printing.

                              All the bitmap fonts become either ugly or unreadable on a true retina screen.

                            1. 14

                              Another benefit (which doesn’t seem to be in the post) – when you’re building a decision table and realize there’s cases where you don’t know how they should be handled, or (oh no!) you’ve been handling it two different ways, depending on the order different code paths check the variables.

                              1. 7

                                This is how I have used them in the past. Sometimes I’ve even directly encoded the table as a lookup table, mapping the actions to functions.

                              1. 2

                                Bonus points for declare!

                                Thanks @sjl. But now I miss Lisp even more. (And I also appreciate Lisp-2s!)

                                1. 1

                                  I do most of my personal projects in Lisp, so there’s nothing to miss.

                                1. 11

                                  My first suggestion would be to install VirtualBox, put your distro of choice inside that, and then run it full screen most of the time.

                                  You could also try the Windows 10 Linux stuff. I haven’t tried it (because I don’t use windows) but those who do say it is pretty great.

                                  Cygwin would be a very, very remote third. I used it once in $corporate_office_job and the best thing I could say about it was that it was better than nothing.

                                  Worst case, if your manager can’t or won’t provide you with the tools you need to do your job, you need to move on. Never stay long in a job you don’t love, that’s how you lose your soul.

                                  1. 6

                                    My first suggestion would be to install VirtualBox, put your distro of choice inside that, and then run it full screen most of the time.

                                    This is my life right now. It is decidedly second class; all the corporate-mandated bloatware is still there wasting utterly ludicrous amounts of memory and CPU time, but at least I don’t have to look at it and I can use a decent window manager and terminal environment. I certainly consider this preferable to the Bash-on-Windows features (and far, far better than Cygwin).

                                    1. 1

                                      That was my choice for years, too. Most of the times, I ssh‘d into that machine using putty or another terminal emulator. They are not good but you can get the job done. SSH’ing-in also circumvents any input lag, too. Plus side: suspend and resume would work flawlessly with Windows.

                                      Anyways, I switched jobs since then. Doing Linux only now. Macs serve as ridiculously expensive SSH terminals now. No more Windows.

                                      1. 1

                                        Have you noticed significant input lag when running linux fullscreen? Whenever I’ve tried it it’s been too laggy to be usable, but I was running on an AMD FX 8350.

                                        1. 2

                                          My 2 cents - a few years ago I had a powerful laptop (one of the WS Lenovos, maybe 16-32GB RAM, i7, etc.) and I tried VMWare (paid edition - company paid for it), Microsoft Hyper-V, and VirtualBox. I could never get rid of, or stop being bothered by, input lag.

                                      2. 6

                                        Can’t install VirtualBox. This is a workspace, think something like remote desktop. See above for a link.

                                        1. 1

                                          You could also try the Windows 10 Linux stuff. I haven’t tried it (because I don’t use windows) but those who do say it is pretty great.

                                          WSL is good, but not great. I’ve been using it semi-seriously on my home machine for the past year and half and it’s better than it was, but I’m consistently disappointed in all the terminal emulators. The only setup I’m happy with is running urxvt on Xming. You will be disappointed in file system speed, but that seems to be a Windows thing regardless of WSL.

                                          1. 1

                                            Have you tried ConsEmu? https://conemu.github.io/

                                            1. 1

                                              I have. I… do not like it.

                                              1. 1

                                                I suspect one of the fundamental problems at play here is the fact that many of these tools want to be able to embed things like CMD.EXE or PowerShell and don’t have the native characteristics we associate with UNIX terminals.

                                                1. 1

                                                  Possibly, but I just found ConEmu to be hideously ugly. Personal preference thing, really. Other than its grotesque UI, it seems like a capable terminal emulator.

                                                  1. 1

                                                    Ah. Yeah. I’m not so concerned about that :) When you’re trying to make a home in the malarial swamps, first you ensure that you have shelter, then you worry about whether the drapes match the tablecloth :)

                                        1. 4

                                          If the book is so bad, then what is the publisher doing? Isn’t it their job to weed out bad content?

                                          1. 6

                                            I wanted to explore that question some more in the post, but it got out of scope and is really its own huge topic.

                                            The short version is that perhaps, as readers, we think they are asking “Is this content any good?” when what they’re really asking is, “Will this sell?”

                                            1. 5

                                              In the preface of the second edition it says that the first edition was reviewed “by a professional C programmer hired by the publisher.” That programmer said it should not be published. That programmer was right, but the publisher went ahead and published it anyway.

                                              Can you expand slightly on this? I understand that the second edition contains a blurb that someone they hired reviewed the 1st edition and decided it should never be published. I’m slightly lost in meaning here.

                                              1. Did they hire a person for the second edition, to review the first edition where the conclusion was ‘that should have not been published’?
                                              2. Hired a person to review the first edition, the conclusion was to not publish but they still decided to publish and included a blurb about it in the second edition?

                                              I guess the question is, did they knew before publishing that it’s this bad.

                                              Additionally was the second edition reviewed by the same person and considered OK to be published?

                                              1. 5

                                                Here’s a longer excerpt from the second edition’s preface.

                                                Prior to the publication of the first edition, the manuscript was reviewed by a professional C programmer hired by the publisher. This individual expressed a firm opinion that the book should not be published because “it offers nothing new—nothing the C programmer cannot obtain from the documentation provided with C compilers by the software companies.”

                                                This review was not surprising. The reviewer was of an opinion that was shared by, perhaps, the majority of professional programmers who have little knowledge of or empathy for the rigors a beginning programmer must overcome to achieve a professional-level knowledge base of a highly technical subject.

                                                Fortunately, that reviewer’s objections were disregarded, and “Mastering C Pointers” was released in 1990. It was an immediate success, as are most books that have absolutely no competition in the marketplace. This was and still is the only book dedicated solely to the subject of pointers and pointer operations using the C programming language.

                                                To answer your question, then, all we can conclude is that a “professional C programmer” reviewed the first edition before it was published, recommended against publishing it, but the book was published anyway. If the quoted portion were the reviewer’s only objection, then we could surmise that the reviewer didn’t know much either, or didn’t actually read it.

                                                1. 1

                                                  little knowledge of or empathy for … a beginning programmer

                                                  This is an important point I feel that has been left out of the discussion of this book. Yes the book contains harmful advice that should not be followed. It is probably a danger to make this text available to beginners, and it serves as little more than an object of ridicule for more experienced readers.

                                                  However, I think there is something to be gained from a more critical analysis that doesn’t hinge on the quality or correctness of the example. This reviewer takes a step in the right direction by trying to look at Traister’s background and trying to interpret how he arrived at holding such fatal misconceptions about C programming from a mental model seemingly developed in BASIC.

                                                  Traister’s code examples are in some cases just wrong and non-functioning, but in other cases I can understand what he wanted to achieve even if he has made a serious mistake. An expert C programmer has a mental model informed by their understanding of the memory management and function call semantics of C. A beginner or someone who has experience in a different sort of language will approach C programming from their own mental model.

                                                  Rather than pointing and laughing at his stupidity, or working to get this booked removed from shelves, maybe there’s something to be gained by exercising empathy for the author and the beginner programmer. Are the mistakes due to simple error, or do they arise from an “incorrect” mental model? Does the “incorrect” mental model actually make some sense in a certain way? Does it represent a possibly common misconception for beginners? Is it a fault of the programmer or the programming language?

                                                  1. 1

                                                    …an opinion that was shared by, perhaps, the majority of professional programmers who have little knowledge of or empathy for the rigors a beginning programmer must overcome…

                                                    What utter nonsense. This is inverse-meritocracy: claiming that every single expert is blinded by their knowledge & experience. Who are we to listen to then?

                                                    It seems like they’d prefer lots of terrible C programmers cropping up right away, to a moderate number of well-versed C programmers entering the craft over time. Which, now that I think about it, is a sensible approach for a publisher to take.

                                              2. 3

                                                Cynically? The publishers job is to make money. If bad content makes them money, they’ll still publish it.

                                                1. 2

                                                  Exactly. There’s tons of news outlets, magazines, and online sites that make most of their money on fluff. Shouldn’t be surprised if computer book publishers try it. The managers might have even sensed IT books are BS or can risk being wrong individually given how there’s piles of new books every year on the same subjects. “If they want to argue about content, let them do it in the next book we sell!” ;)

                                                  1. 2

                                                    I recommend a scene from Hal Harley’s film “Fay Grim” (the sequel to “Henry Fool”) here. At a point, Fay questions the publishers decision to publish a work (‘The Confessions’) of her husband - she only read “the dirty parts” but still recognized the work as “really, really bad”.

                                                    Excerpted from a PopMatters review: “One proposal, from Simon’s publisher Angus (Chuck Montgomery), will lead to publication of Henry’s (admittedly bad) writing and increased sales of Simon’s poetry (on which royalties Fay and Ned depend to live). (Though the writing is, Fay and Angus agree, “bad,” he asserts they must press on, if only for the basest of reasons: “We can’t be too hard-line about these things, Fay. Anything capable of being sold can be worth publishing.”)”

                                              1. 18

                                                Sounds like the C version of English As She Is Spoke

                                                1. 5

                                                  My wife teaches English and will really appreciate this. Thanks!

                                                  1. 3

                                                    This type of naive translation is really common. A personal favourite

                                                  1. [Comment removed by author]

                                                    1. 2

                                                      In my writeup, in the footnotes, I link to a promotional video for Gibilisco’s book. In the description it says, “One of my new books (co-authored with Robert J. Traister) has come off the press” but in the video he actually forgets his name.

                                                      If you watch the video (which is just bizarre) he says that all he did was redo the diagrams in Traister’s book.

                                                    1. 20

                                                      Here’s his obituary; he died 11 years ago. He seems like he was a nice man.

                                                      1. 21

                                                        I found that in my searches. He did seem like a good person. It’s unfortunate his book is really, really bad.

                                                        1. -3

                                                          It says he’s a politician. That’s a professional bullshitter. That might corroborate he was doing this stuff on purpose for money. Unlike many politicians, he also seemed to use his influence to help and entertain a lot of people. Most (all?) of us do good and bad in our lives. I wouldn’t expect him to be any different, esp ambitious enough for writing books and taking office.

                                                          Note: The jumping in the pool with suit was funny. I’d have liked to see the reactions in person.

                                                        1. 8

                                                          Fascinating read with good, detect work, Sir! :)

                                                          My worries kicked in when you said it was at over 200 libraries. If it sounds true and is horribly wrong, then I thought it could still be polluting peoples’ minds as they start programming. Maybe they’ll think they’re not smart enough as the examples don’t run. Maybe they’ll get past that with bad habits that lead to data corruption, crashes, and/or hacks. Maybe others will correct their bad practices.

                                                          I don’t know but the book at libraries ain’t good. Made me think about sending out emails to those in bigger areas to ask that they throw the book in the trash. Maybe send a recommendation for a good book for newcomers, too. What’s the best one for that you think? In that hypothetical scenario, I’d also note that the language doesn’t change a whole lot over time like most IT stuff. So, whatever they buy they won’t have to replace every year. Lots of small libraries avoid computer books if they obsolete too much.

                                                          1. 10

                                                            Maybe they’ll think they’re not smart enough as the examples don’t run.

                                                            I couldn’t shake that thought the whole time I was reading it and it’s why I really detest sloppy tech books.

                                                            As for the books in the library, I’m thinking of finding the copies (1st and 2nd edition!) in my alma mater’s library and at least leaving a warning note in them.

                                                            1. 1

                                                              Good idea. I might at least do a few on the list. Again, what’s the current, best recommendation for a beginner book in your mind in case they ask about one?

                                                              1. 5

                                                                Truthfully, I don’t know a good C book for beginners. I have not looked at such books in a long time. I learned from K&R, but I was also learning it in university from different books at the time. None of them stand out in my mind. (I don’t think K&R is a great fit for beginners, especially with modern C.)

                                                                If anyone has suggestions, please feel free to comment.

                                                                1. 4

                                                                  There is 21st century C, though it assumes some general programming experience.

                                                                  There is also Head First C, though I have no direct experience with it, as I read through the C# book in the same series, rather than the C book. I recall learning a lot from the book Head First C#, so that gives me some hope for Head First C.

                                                                  To be fair, I don’t know that C is a very good first programming language these days, unless you’re starting in a domain that doesn’t require working with care around allocations, or unless you have someone helping you learn.

                                                                  1. 4

                                                                    To be fair, I don’t know that C is a very good first programming language these days

                                                                    I hope most of us agree on that by now. :) I always encourage them to learn something like Python first just to get into the mental habits of breaking problems down, implementing solutions precisely, and debugging others’ code. That’s hard enough by itself to learn without the low-level stuff in there. Once comfortable with that, then learn the low-level stuff with a book on something like C language.

                                                                    I guess I’m looking for best intro(s) to C to recommend for someone with some programming experience in a high-level language.

                                                                    1. 3

                                                                      21st Century C seemed like a decent introduction to C, and takes exactly that angle. It doesn’t have the abrasiveness of Learn C the Hard way, and starts out explaining the C environment so that you aren’t left ignorant of how to work with makefiles and the like.

                                                                      It does recommend autotools, however.

                                                                      1. 4

                                                                        While it’s a great book, I see it more as a ‘refresher’ than an intro text to a novice. Would still recommend K&R 2nd ed. for essentials, followed by this to get up to date practices.

                                                              2. 4

                                                                My worries kicked in when you said it was at over 200 libraries. If it sounds true and is horribly wrong, then I thought it could still be polluting peoples’ minds as they start programming. Maybe they’ll think they’re not smart enough as the examples don’t run. Maybe they’ll get past that with bad habits that lead to data corruption, crashes, and/or hacks. Maybe others will correct their bad practices.

                                                                The same is true for multiple other wrong books and other texts. Best to avoid anything by Herb Schildt, Yashwant Kanetkar, Zed Shaw, Richard Reese, many tutorials like Beej’s guide to C, etc.

                                                                What’s the best one for that you think?

                                                                K&R 2nd ed. was definitely the best 20 years ago. Now I don’t know, but perhaps “C How to Program” by Harvey Deitel and Paul Deitel or “C Programming: A Modern Approach” by Kim King. And of course “C: A Reference Manual” by Harbison and Steele for reference. Also books written by Richard Stevens for UNIX programming.

                                                                1. 2

                                                                  Why exactly would you say Beej’s guide to C isn’t a good tutorial?

                                                                  1. 3

                                                                    I’d actually like an explanation for all of those—assuming of course, that they aren’t all making the exact same mistake, which seems highly unlikely. I was under the impression that Zed Shaw, albeit controversial, wrote good introductory material.

                                                                    1. 2

                                                                      I don’t have the time to review them again. Now I think that I should write reviews them once and for all and then share every time they come up in a discussion. Like Ed’s thoughts on “Learn C The Hard Way”.

                                                              1. 3

                                                                Reads like Miss Marple.

                                                                I would assume K&R had much more influence than Traister.

                                                                1. 5

                                                                  I would assume K&R had much more influence than Traister.

                                                                  I sincerely hope so.

                                                                1. 6

                                                                  I am currently reading the Git Pro book hosted on git-scm.com. It is freely availble as ebook in many formats.

                                                                  Having read about 1/3 so far I can really recommend it. It is well written and even after using git for years there is plenty of stuff to learn from it. Might it be internals that will become clearer or different aproaches on how to use it.

                                                                  1. 1

                                                                    I think you meant “Pro Git”. :) (I agree, it’s worth reading.)

                                                                    1. 1

                                                                      Yeah I botched that one up, thanks for the correction. :)

                                                                    2. 1

                                                                      The “Git Internals” chapter is pretty eye opening. While not strictly necessary for using git I found understanding how the underlying content addressable store fits into how a repo is put together helps to pull away nearly all the magic.

                                                                    1. 5

                                                                      Recording your screen is an interesting idea. My guess is that what’s really at work is reflecting on what has been done; the screen recording/playback is just a catalyst.

                                                                      If I recorded my screen I’d get a whole lot of… not much since I do a lot of work that doesn’t show up there. Lots of code navigation, trying to make the mental connections to piece together the parts, wouldn’t be fruitful to watch. I do, however, keep notes (both analog and digital) and the act of writing them is often enough for me.

                                                                      Also, it’s a little distressing to see the reason for reviewing the screencasts is to write the program faster. If that’s your goal, you’re setting yourself up for disappointment.

                                                                      (edit: hit “post” too soon thanks to unknown key combination. grrr)