Hacker News new | ask | show | jobs
by hiker 3092 days ago
Reminds me of the evolution of Lua https://www.lua.org/history.html from a configuration language to a full blown programming language.

Awhile ago, we've used this code as data approach in a game development studio for everything. For example, maps/levels were stored as a Lua scripts that get executed on load and contain a sequence of PlaceObject, SetProperty, etc invocations.

It doesn't come without drawbacks, though. For example, Autodesk Maya stores scenes as Mel code (as a bunch of createNode, connectAttribute, setAttribute commands). This script gets executed on load in a single thread (utilizing a single from your N cores) and scene loading can take ~30 min on large scenes. Security is also an issue but it's fixable with proper environment sanitation and sandboxing.

2 comments

This is an interesting aspect, but slightly different from what I had in mind.

Just because you treat data as code doesn't mean you have to force it into a Turing-complete language. It just means that you should document it, format it properly, put it into version control and deliver it for deployment.

Moreover, Turing-complete languages are more of an anti-pattern here. The proper design pattern here is the Rule of Least Power:

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

It means you should choose the least powerful language suitable for a given purpose.

And this is where DSLs or "data as code" can play its advantages: Not just makes it things shorter and simpler, but you can also force it into a less powerful language, which allows you to eradicate certain types of bugs and security issues by not making them even expressible anymore. Moreover, you can run your data structure through different "interpreters" doing different things with it, which is completely inpractical of your data structure describes a too powerful language.

Emacs just used a full blown programming language right from the start. And one of the very best: Lisp.
Then again, while Emacs Lisp is based on Lisp, it's not really the best lisp. Some could say it's not even good, because of how old and crafty and lacking in features it is/was. But thing is, it slowly evolves, and maybe in a decade or two it closed the gap.
> And one of the very best: Lisp.

Got any hard numbers to back up that bold claim?

What numbers do you require? If there was a metric measuring simplicity then Lisp (or perhaps a modern variant, Scheme) would probably win - it is a local optimum of language design, essentially just lambda calculus exposed via a very simple grammar (which aids meta-programming).
Any kind of serious study will do :)
Such studies are very hard to do, it is almost impossible to factor out social preferences. For me personally, I am most productive in languages like Haskell and OCaml.
https://academic.oup.com/bib/advance-article/doi/10.1093/bib...

I also seem to recall a paper from the 90s or early 2000s which compared speed of development & program execution between Lisp & other languages. Maybe it was somewhere on Ron Garrett's site? IIRC, Lisp programs were developed consistently more quickly than C/C++/Java/SmallTalk, and were normally faster than all but the very fastest C/C++ programs — but I could misremember. I remember that it had some interesting-looking charts.

I rate it 10/10. What kind of numbers are you expecting exactly?
Anything which can support the grandiose Lisper claims such as the one above :)

By which measurable metric is Lisp "one of the best"?

I'm genuinely curious, since I keep hearing propaganda about it.

What programming languages do you use? What numbers made you choose those ones? Maybe if you show me an example of some numbers I could help more.

I don't have the time to write up why I think Lisp is great, but you can find essays by many greater (and more famous) programmers than me such as Richard Stallman, Peter Norvig, Steve Yegge, Paul Graham et al. But really the only way is to learn it for yourself. There is a kind of enlightenment that comes with learning Lisp and I would recommend it to every programmer.