1. 21
  1.  

  2. 13

    Heh. My advice to programmers, in all walks of life, is minimize the use of m4. :)

    1. 4

      If you use m4 a̓u͌t̂o̚t̔o͊ōl̀s͌ ̎w͋i͆l͒l̂ ̽śe̓ǹs͋é ̇y̔o̒u̐, ȁ̲n̮̎d͍̑ ̳͒ẗ̗́h͈̓à̹t̡͂ ̺̂w͓̾â̝y̱͋ ̗̆ĺ̢i̱͊é̮ś̤ ͕͝m͇̔a̯̓ḏ̌n͔͝e͋ͅs̋ͅs̝͋

      I don’t mind general purpose tools, but m4 gets very painful as you try to ramp it up. I’ve always had decent enough luck banging together ad-hoc preprocessors with Ruby, but that probably speaks to how seldom I do web stuff.

      1. 2

        I’ve always had decent enough luck banging together ad-hoc preprocessors with Ruby,

        I’m not sure how sophisticated these “ad-hoc preprocessors” are, but would m4 have worked, assuming you went for that instead? I’m all for sharper axes to cut down problems, but I can’t help but think we’re nicking a few more yaks then necessary with them sometimes. Often this is due to to stubbornness (“I’ll just write my own bug ridden implementation from scratch”), or simply ignorance (not in a bad way, the landscape of tooling is ginormous).

        How many of those bug ridden implementations of $X would be necessary if people just adopted m4, or insert some other generic tool here instead?

        1. 1

          I’m not sure how sophisticated these “ad-hoc preprocessors” are

          Pretty damn unsophisticated, that’s what I was trying to get at - I don’t write enough CSS to warrant something difficult, so take what I say about shaving a yak with a pinch of salt ;)

          but would m4 have worked, assuming you went for that instead?

          Sure - but it would’ve been way more painful.

          That’s the point I really wanted to make: I don’t want to make assumptions about the author, but my guess is that he used a tiny little bit of m4… and has avoided the piles of nasty that it has, like how easy it is to trip up the parser, how it has a nasty habit of looping infinitely on trivial inputs (define('foo', 'foo bar'), and may god help you if your document has ‘foo’ in it anywhere…)

          How many of those bug ridden implementations of $X would be necessary if people just adopted m4, or insert some other generic tool here instead?

          Probably none. But pick a better tool than m4. ;)

          Alternatively, isn’t Ruby + erb templates a pretty damn generic tool? Rather than grow my toolbox to learn the pitfalls and nasties of m4, or the pitfalls and nasties of SASS, why don’t I just use tools that I already have and know to solve the problem?

          1. 1

            Probably none. But pick a better tool than m4. ;)

            I guess I’m missing the experiences necessary to discount m4 as a tool worth having in my back pocket. I’ve not used it much.

            Alternatively, isn’t Ruby + erb templates a pretty damn generic tool?

            Not for someone who has to learn Ruby + erb!

            why don’t I just use tools that I already have and know to solve the problem?

            This is what I would / do do, but I’m starting to question whether or not this makes sense. Investments in general tools that can apply to lots of things make more sense to me, and I think we as a community forget this.

            But, maybe I’m completely wrong?

            1. 2

              Perhaps not erb, but in the particular case of CSS, I’d wager everybody is using some form of generator for their html that can be repurposed for css. Unless of course they generate html using m4 as well, in which case they should use that for css and I will back away slowly.

              I think sometimes people learn general tools but then use them awkwardly. Like when all you have is a hammer… Perhaps a better analogy is a Swiss Army knife. General purpose tool, great for many tasks. But I wouldn’t use its saw to cut down a tree.

              1. 1

                Not for someone who has to learn Ruby + erb!

                Alternatively, isn’t ${PROGRAMMING_LANGUAGE} + ${TEMPLATING_SYSTEM} a pretty damn generic tool?

                better? ;-)

                If you’re using Node / Mustache, or Flask / Markdown, or (whatever else), you’ve got a tech stack that you’re using to handle all your web application needs already - it makes less sense to introduce a new tool to handle CSS; just use the same thing you’re using to generate HTML.

                There is a distinction to be had, as tedu notes, between using one tool for these closely related tasks, and using one tool for something completely orthogonal. But when you’re talking about generating CSS & generating HTML, might as well keep it close, eh?

                1. 1

                  I wouldn’t say it’s a bad idea to learn m4, but I think the value of studying it is to understand tempting pitfalls in language design, which make things hard for downstream users.

                  In particular, everything I’ve ever written in it, I have been unable to read.

          2. 3

            The German Wikipedia generates HTML as an m4 example: https://de.wikipedia.org/wiki/M4_%28Programmiersprache%29

            The nicest sentence at the end of the description of the language features is:

            Darüber hinaus ist M4 nicht nur Turing-vollständig, sondern auch eine praktische Programmiersprache.

            (Above all, M4 is not only turing-complete, but also a practical programming language)

            1. 2

              A decade and a half ago I used GNU m4 to maintain my website, and even published an article about it in Linux Magazine. It was a step up from using cpp, which was my previous solution, but I’ve moved on from either now…

              1. 2

                Wow. A decade and a half ago I read an article on how to use GNU m4 to maintain a website - and found it to be very useful in maintaining my own website.

                Small world.

                1. 2

                  You’re welcome! :-)

              2. 1

                But, do you advocate for reinvention as well? Which is worse: m4 macros, or Less / SASS?

                (I do realize that both Less and SASS provide additional features that aren’t so easily mimicked by m4, but for a large number of Less / SASS users it’s probably enough)

                1. 5

                  But, do you advocate for reinvention as well?

                  Sure, if the result is better

                  Which is worse: m4 macros, or Less / SASS?

                  m4 macros, no contest

                  but for a large number of Less / SASS users it’s probably enough

                  I would guess that every non-trivial SASS project uses nested &-selectors

                  1. 3

                    I found it very easy to learn sass on top of css. In fact, I’d say I learned them at the same time. Learning m4 is quite orthogonal. I wouldn’t be focusing on the problem domain of browser styling, I’d be thinking about text processing.

                    1. 1

                      Learning m4 is quite orthogonal.

                      But your new found knowledge of m4 becomes potentially useful for other contexts! Where as, Less and/or SASS are very domain specific.

                      I agree though, if you’re learning this stuff at the same time, Less / SASS makes CSS better, and nicer, generally. I remember learning CSS way back in the early naughts and thinking “WHERE THE *%$! ARE MY VARIABLES?” There were other problems, but I would have been really happy (until I hit an m4 wart or something, at least) if I had thought to apply m4 macros to it all.

                      1. 2

                        A lot of domains could use a pre processor, but many already have it (C has cpp). So the universal applicability of m4 is questionable. Maybe you can drop an m4 step in front of compiling your C code, but most other programmers will hate that.

                        In the past, if my needs were modest, I’d use awk or sed. Two tools also useful in many contexts.

                2. 6

                  Something magical just happened to me. A co-worker posted a screenshot for an app store search for dash, and explained that it was a documentation browser that’s great for SASS, Ember.js, etc. I suggested they should just have actual man pages, in a “get off my lawn” sarcastic tone. Then, I refresh lobsters and this shows up – m4 actually has a man page, but of course more detailed information in it’s GNU info docs.

                  1. 8

                    Finally someone found the right tool to the right thing, instead of reinventing wheel using overloaded beasts like SASS or LESS.