Hacker News new | ask | show | jobs
by kbenson 1018 days ago
I think the problem here is more that people still need to work on their positions to figure out what they really mean, because while you have some points, regular expressions are the canonical example of a DSL. Their domain is strings, and they make certain things you want to do in them very easy to express.

The problem here is that while you can say “Terraform is more than a DSL” - if you ever back the layers or try have a conversation with someone who’s a true dyed in the wool Terraform zealot and start to try and understand where they’re coming from, you begin to realise they don’t love Terraform, they love this weird half language because they’re an expert in it, and they’ve built their entire career on being an expert on something you can only use for one specific use case.

That's from the article, and that really sounds a lot like talking to someone that knows and loved regular expressions (and I count myself as one of those people). The alternative, which is often done in lower level languages, is either some simple nested conditionals or a state machine, and plenty of people choose to just write state machines. I mean, that's all a regular expression is anyway, a shorthand expression for building state machines to process strings.

It should be no surprise that there are plenty of people that think regular expressions are wasteful and you should just write your own state machine (fewer than there were in the past, but they exist). Regular expressions are exactly like everything else that's being discusses in the article, but many people like them. Perhaps that's a point we should focus on to determine what makes a DSL successful and good compared to the alternative.

2 comments

If you re-read my reply, you'll see that I said that regex is a DSL, but doesn't apply for different reasons.
I did read your reply, and I think your reasons for excluding it are insufficient. You can't just exclude any DSL that succeeds (has become "universal") and say "see? no DSLs are good!" The point of me noting how people resisted (and still resist) regular expression usage is to note that just like any other DSL there are those that dislike it and eschew its use and instead just write the code. It is exactly what the article is talking about, where it advocates writing in the base language and not using a DSL.

If you're going to make a serious argument that "DSLs are, universally, awful" then you're going to need to account for regular expressions a bit more carefully. That can be you admitting that you just dislike them and don't use them so consider them awful as well, but if you don't hate them then you may want to focus on the why, and it is likely a much more interesting conversation topic to pursue than "DSLs bad".

Regular expressions ... this representation is a somewhat fundamental and mathematically general representation of interacting with strings - the DLSs in question here are, quite obviously, nothing of the sort.

https://en.wikipedia.org/wiki/Regular_language

Regular expressions have a deep mathematical background. An ad-hoc DSL from a company that specifies infrustructure does not.

Regular expressions, as used in practice in programming are mathematically general for interacting with strings, but they are in no way fundamental. They are a DSL for generating NFAs and DFAs (depending on the underlying engine). There is nothing fundamental about them, they are just a shorthand (a DSL) for those abstractions. Indeed, the very article you posted notes that anything able to be implemented as a finite automaton is also a regular language due to Kleene's theorem.

> Regular expressions have a deep mathematical background. An ad-hoc DSL from a company that specifies infrustructure does not.

You very specifically went far beyond making any statement about ad-hoc DSLs from companies that make infrastructure. You said "DSLs are, universally, awful".

I'm also interested why you left out makefiles in your original rebuttal. I think makefiles are a good example a simple and useful DSL for accomplishing what it sets out to do. That's not to say it can't turn into a mess (what language, domain specific or not, is free from that concern?), not that it solves all needs to all people, but makefiles are simple, straightforward, solve a useful problem, are well known by many people (and easy to explain and teach), and I don't think most people would consider them a mathematical concept core to computer science. Are they awful? If so, why?

You're grasping at straws now. Just admit that regex is a much more fundamental technology than some ad-hoc, badly specified commercialware and we can be done. Go on, you can find it in yourself ;-D.

Sure, Makefiles are a DSL. Just a horrible one. They just make my point in a different way. Have you used a Makefile recently? They are AWFUL. Brittle, complex, half-bash, invisible-tab-prefixed, abominations, sent from another millenium. Let's take a modern codebase - say Python - you're much better to just use something like pyinvoke - handles all the CLI-level stuff, and you get the full force of the programming language you were writing in the first place.

You seem to have fundamentally misunderstood my purpose for engaging you. I tried repeatedly to move the conversation from a poorly supported absolutist statement from you to a productive discussion about what makes a DSL good or bad, but you're only interested in defending yourself and your over encompassing statement, not in actually having a discussion. Such as why does being fundamental in some way make it a good DSL? Are all fundamental concepts worthy of a DSL?

In any case it's clear you're uninterested in engaging on that and nor are you willing to consider your statement carefully and actually support it with additional examples (beyond some puzzling critiques of makefiles which make me think you don't understand the point of a DSL at all) or walk it back to a reasoned examination. So I'm not sure we'll get much out of continuing this.

The real issue here is a DSL without intention of enforcing limitations permanently.

A Regex, SQL, TLA, CSS and so on are all better DSLs than allowing a general purpose language because they are meant to restrict inputs of lower priority than other goals, where priorities are largely fixed.

A corporate DSL is meant to expand to whatever grandiose plans the company has for accepting impractical input from platinum customers.

Aren’t regular expressions the abstraction to state machines? They all get converted to a DFA or NFA, no?
Yes, and I said as much. All DSLs are abstractions to some sort of code that does some action. What I'm saying is that we have examples of bad DSLs, and good DSLs, and perhaps by focusing between them we can come up with some useful information about what distinguishes one from the other.

To me, that's a much more interesting (and useful!) discussion than just piling onto the DSLs are awful bandwagon, and I also think it's a flaw in any argument put forth in that argument that needs to be addresses before I can accept it.

Exactly. The languages in the article are nothing of the sort.