"One-trick" programming languages/applications?
March 30, 2018 10:22 PM   Subscribe

I was quite fascinated with the FPP on AWK, and the commentary that it's A: only good for a couple of things, but B: seems to be -really- good at them. What other languages are like this? Equally, the comment on Humdrum interested me enough that applications of that one-trick would also be very welcome.
posted by solarion to Computers & Internet (14 answers total) 10 users marked this as a favorite
 
How about languages for knitting? "Languages for 3D Industrial Knitting" by Lea Albaugh.

Also if you read the Code Golf stack exchange you will come across many languages like Jelly, designed pretty much only to solve problems in as few characters as possible.
posted by dilaudid at 10:45 PM on March 30, 2018 [3 favorites]


m4 is my faaaaaavorite unsung superhero. To the point where it was hard for me to find good articles for an example to link because none of them sang my baby's praises enough, but try this two part Linux Magazine series: Macro Magic, The Unknown Power Tool. If you are an older unix nerd you have seen a sendmail.cf file, which is the canonical example of both why people love and hate m4. (It's extremely powerful, you can generate a full configuration file from one line if that's all you need; if you are unfamiliar with the macro templates and want to make a simple change, or if you're bad at confusing backtick with singlequote, you might have a day of "try that? nope. start over." ahead.)

m4 is a macro expansion language, so its job is to turn ONETHING into ANOTHERTHING. And possibly ANOTHERTHING into YETANOTHERTHING, and YETANOTHERTHING into EVENMORETHINGs. That's it. That's the deal. There are conditionals available, you can order output through named streams (diversions), but really, it just replaces bits. The key is that it expands repeatedly, and you can nest things pretty much as far as you like.

So here's an example:

divert(-1)
This is a config file that will give you some stuff, and also things.
dnl
dnl This is a simple definition, which we'll use for some decisions
define(`mysubnet',`172.16.0.0/12')
dnl
dnl This is an if-elseif-else, only because we don't have elseif, only else,
dnl we have to nest the tests. It works like: ifelse(thing,is-this?,thing-to-do-if-true,thing-to-do-if-false)
dnl For the record, even I got lost with how many ')s I had on the end.
ifelse(`mysubnet',`192.168.0.0/16',`define(`netmask',`255.255.0.0')',`ifelse(`mysubnet',`10.0.0.0/8',`define(`netmask',`255.0.0.0')',`define(`netmask',`255.248.0.0')')')
define(`stuff',`things')
divert(0)dnl
## This configuration file is generated automatically courtesy of your hero and mine, m4.
network=mysubnet
mask=netmask

This will print:

## This configuration file is generated automatically courtesy of your hero and mine, m4.
network=172.16.0.0/12
mask=255.248.0.0

Anyways, I love m4 and sing its praises and everybody should love it, and it does suit your one-trick-pony-but-REALLY-good-at-that-one-trick but even I have to admit it's not exactly beautiful.
posted by sldownard at 1:07 AM on March 31, 2018 [3 favorites]


Best answer: I think that the term that you are looking for is Domain-Specific Language.

As well as the Wikipedia article, I suggest exploring the Category, as this includes some not listed in the article (e.g. G-code).
posted by James Scott-Brown at 3:03 AM on March 31, 2018 [3 favorites]


For the sake of completeness, sed and AWK are virtually always mentioned together. sed is very good for find-and-replace sorts of operations (really those out of the scope of tr), but you could do floating point arithmetic if you wanted.

Unix commands generally subscribe to "do one thing well", but awk and sed are the two I can think of that seem to answer the question. (I think I'm interpreting this much more narrowly than the Wiki DSL category. I wouldn't see Macaulay2 as an answer to this question, for example--it does many kinds of tasks, just all within a specific domain.)
posted by hoyland at 4:45 AM on March 31, 2018 [1 favorite]


For the sake of completeness, sed and AWK are virtually always mentioned together.

And grep. The holy Trinity to me.

To the original question, SQL is Turning compete (or at least far more powerful than how many people use it, but mostly only used for querying data.

PostScript is almost exclusively used for laying out pages even though it's capable of much more.
posted by Candleman at 7:15 AM on March 31, 2018


TeX/LaTeX/etc! (Postscript reminded me)
posted by supercres at 7:44 AM on March 31, 2018 [1 favorite]


OpenSCAD defines 3D models. xslt formats XML documents. Both are declarative languages, so variables and loops don't work the way you'll expect them to work.

rexx is the glue-everything-together language of IBM mainframes ... and Amigas.

If you're really unlucky, you'll still find Forth in control applications. If you're really, really unlucky, you'll find ladder logic there too - it involves neither ladders nor (conventional) logic.
posted by scruss at 7:50 AM on March 31, 2018


Coq comes to mind, because if you liked that article on awk, then you'll probably enjoy Stephan Boyer's blog post, "My unusual hobby."
posted by Wobbuffet at 7:51 AM on March 31, 2018


Best answer: Forth was originally created for controlling radio telescopes.
posted by adamrice at 8:59 AM on March 31, 2018


More tools from UNIX prehistory -- troff for primitive typesetting, lex and yacc for generating parsers. The latter are still widely used (tho in modern incarnations flex and bison)
posted by RobotVoodooPower at 9:11 AM on March 31, 2018 [2 favorites]


Regular Expressions.

It does one thing. Someone skilled it can do things that seem like wizardry to someone who doesn't know it. It's so useful it's been included in many other languages so it may not seem so special.
posted by SemiSalt at 9:19 AM on March 31, 2018 [2 favorites]


previously on metafilter, the J Programming Language.
posted by vogon_poet at 9:34 AM on March 31, 2018


Five bucks well spent
posted by flabdablet at 12:37 PM on March 31, 2018


Best answer: troff for primitive typesetting

troff is anything but primitive. Some of the most complicated multi-column pagination I've ever seen (in a combined dictionary/thesaurus: thesaurus entries are below the dictionary entries, on the same page, with the relative height of the dictionary and thesaurus content varying every page) was done in troff. Neatroff handles mixed bi-directional text and all the fun feature tables in OTFs.
posted by scruss at 3:08 PM on April 3, 2018 [2 favorites]


« Older This tub has got to go... okay, how do I do this?   |   when I export a video in Premiere Elements 14... Newer »
This thread is closed to new comments.