- IIRC the earliest version of the C++ language, before a C++ compiler existed, was implemented with C and the M4 preprocessor.
https://en.wikipedia.org/wiki/M4_(computer_language)
https://www.gnu.org/software/m4/
by woodruffw
3 subcomments
- Seems like a bad idea, given that the CPP and HTML have a fair number of overlapping tokens (e.g. `#` for both URL fragments and macro beginnings).
Why not use SSI[1]? It's inspired by the CPP's syntax, but is supported directly by most HTTP servers (and is more powerful, to boot).
[1]: https://en.wikipedia.org/wiki/Server_Side_Includes
- I do this for some very small static sites like: [0]
[0] http://rbl.oc9.org/
by katzenversteher
0 subcomment
- Quite a long time ago I worked at a company developing games for mobile phones in J2ME. The J2ME runtime had a lot of (different) quirks issues on different phones and the phones where also quite different. We used the C preprocessor a lot to make porting the games for different models easier.
- There's also the htp processor that handles the same problem. It has macros (equivalent to #define) file inclusion (equivalent to #include) and conditionals (equivalent to #ifxxx) but is better suited for HTML than the C preprocessor.
https://sourceforge.net/projects/htp/
- I was considering doing something like this just the other day. It had a gnuplot script and it seemed to me that it would be so much more versatile if I could use #ifdefine and #include in it.
I ended up using a Perl preprocessor, but it seems like cpp would work ok-ish for certain use cases that don’t require, say, strict tabs like Python among a few other things mentioned on the cpp manual.
- Why not go all out? Use -DUSERNAME=$USERNAME on the command line to pass in data? Define macros with parameters to affect rendering in complicated ways. Call cpp for every request to generate the html. Could be fun!
by torstenvl
1 subcomments
- https://news.ycombinator.com/item?id=39863492
- Or there's the opposite choice of using PHP as a C preprocessors. Not sure which is more frightening.
- i've used a linux setup for wireless access points that used the unix shell as its html templating engine. (openwrt 20 years ago, maybe?) the web server would run a shell script and send its output to the browser, cgi-style
by babydevkute
0 subcomment
- hi
- [flagged]
- [flagged]