Hacker News new | past | comments | ask | show | jobs | submit login
Abusing Proxies for DSLs (mcluck90.github.io)
74 points by fagnerbrack on May 20, 2018 | hide | past | favorite | 10 comments



I thought it would be about network proxies and Digital Subscriber Lines...

Why would you want to use this? I'm not sure.

Unfortunately one of the applications that immediately comes to mind is obfuscation.

I did a bit of JS work many years ago, before the whole "framework craze" and massive amount of churn started, and looking at the code written in it now, it almost feels like they're trying to compete on complexity with languages like C++.


It's a trade. For example, you can split the whole program (think execution of hundreds of business rules) into an interpreter - maintained by developers - and the pure rules in an easy to understand text file - maintained by business people.


Has that happened, pretty much ever? It is a great aspirational goal. I've never seen it pan out, though.

Not that there isn't a benefit from reducing things to the language you use to reason about the overall problem, and the language used to implement it. In large, whether you create a "DSL" or not, you almost always move to doing things in terms of the API you are using. Effectively making it a language. Taking a little more deliberate control does seem nice.

That said, I have found benefit in keeping fewer abstractions around. This is especially true as I am supporting an API. Don't hide that API from anything you do. Too easy to hide warts in it that you might otherwise fix.


Has that happened, pretty much ever? It is a great aspirational goal. I've never seen it pan out, though.

That's pretty much the definition of https://en.wikipedia.org/wiki/Inner-platform_effect

Almost every story about a "business rules engine" I've heard was that it eventually turned into an odd Turing-complete programming language, and it'd be simpler to just write the same code in the original language.


Well, it depends, if you can keep the rules structured as data and not as code you're fine.


A similar thing used in the PHP ORM Doctrine. It lets you call methods on repositories that don't actually exist, for example:

  repository.findBy<Property>()
That's one example of a real use that isn't just making life difficult for whoever comes after you.


I think with proxies, you might be able to recreate the magical "sh" library [1] from Python for node.js (wouldn't be surprised if someone already managed this!)

[1] https://amoffat.github.io/sh/


DSL: A domain-specific language is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. (from Wikipedia)

The author does eventually define DSL, but it's pretty confusing until then.


Fun article but you and I just know someone is gonna ignore the warnings at the top and put this into production on some site.


"No, no, it's exactly what the JVM needs!"

-- Martin Odersky




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: