Live data from Hacker News

What you learn by making a new programming language

ntietz.com

111–120 of 137 posts

Re: What you learn by making a new programming language

#111
post #13

I've had two projects that end up being "oops, I made an interpreter". It starts innocently enough, you just have a JSON that has some basic functionality. Then you decide it would be cool to nest functionality because there's no reason not to, so you build a recursive parser. Then you think it'd be neat to be able to add some arguments to the recursive stuff, because then you can more easily parameterize the JSON. T…

Lots of people learn the same lesson at some price. Data and execution are two separate things and should remain as separate as possible. The reason is that once you mix data and execution, suddenly you don't know what your data is until you execute it. Then you can only deal with it in the context of whatever tools you write and you can never just look at it straight. On the other hand now execution depends on lots…

Nice theory, how do you do in the real world where you have a 'data' whose value depends on the OS used?

Re: What you learn by making a new programming language

#112
post #105

Earlier quoted context omitted.

If possible, I'd say it's best to just stay at 12:00. Let them be "hard coded" in ~/.config/myapp/config.py or such so that it's very clear which edits should only be done by a wizard and which ones are suitable for a user. This way all your users are suitably placed on a slippery slope where one edit in the same language but to another file will transition them from user to contributor. Jail them in a separate langu…

> Besides, config languages never have the level of polish (re: tab completion and static analysis) that the main language does. They don't have to! > Why deny your users the niceties that you set up for yourself? Don't do this, of course. :) For instance, Nickel gained[1] an LSP implementation years before it hit version 1.0. When editing Nickel configs,byou get all the stuff you'd expect for a programming language:…

> there's no reason that a configuration language can't have first-rate tooling!

Perhaps I shouldn't have made it about the configuration language's maturity. What I mean is that however mature it is, it's still yet another thing. At least from what I've been seeing lately, fewer tools > better tools.

Suppose that on first run you generate a config file like this:

    from configtypes import Strategy

    def strategy() -> Strategy:
        return Strategies.balanced
And then the user maybe changes it to

    from datetime import datetime
    from configtypes import Strategy

    def strategy() -> Strategy:
        # be aggressive on Tuesdays
        if datetime.today().weekday() == 2:
            return Strategy.aggressive
        return Strategy.balanced
But actually it's `Strategy.assertive` not `Strategy.aggressive`, so this is an invalid configuration. I'm sure you can set up an editing experience for the user which gives them a red squiggly when they try to reference a nonexistent value, or which gives them an error that indicates a line number when they try to use it. But those are things you want for your dev environment anyway, right?

And maybe the user is curious: "how is this used?". There are editor actions like "go to definition" or "find references" which they can use to find more information. Those will be interrupted if the language is different.

I just feel like whatever time you might spend on integrating the configuration language is going to be better spent on docs, error messages, or making it easy to summon a well-configured editor environment (which is the same both for devs or config authors).

---

I've experienced what you're describing with nix. It's magical. I haven't toyed with Guix yet, but I want to eventually write helix plugins (it uses a scheme for its plugin language, or it will...), so maybe I'll give Guix a try when I get to that "learn scheme" item on my todo list.

For now I'm focused on how to help users who aren't accustomed to navigating a project with files in more than one language (scientists mostly), and I just don't think the juice is worth the squeeze re: creating more than one world, one for them and one for "proper" devs. Maybe maybe I'm overlooking the use case of large non-user-serviceable things because I wish things in general were smaller and more user-serviceable.

Re: What you learn by making a new programming language

#113
post #111

Earlier quoted context omitted.

Lots of people learn the same lesson at some price. Data and execution are two separate things and should remain as separate as possible. The reason is that once you mix data and execution, suddenly you don't know what your data is until you execute it. Then you can only deal with it in the context of whatever tools you write and you can never just look at it straight. On the other hand now execution depends on lots…

Nice theory, how do you do in the real world where you have a 'data' whose value depends on the OS used?

What are you talking about exactly? This thread is about static data files. Did you think I was saying a program shouldn't have variables?

Re: What you learn by making a new programming language

#114

No. No, I really shouldn't. Yes, I might gain a better understanding of how things work. I can do that lots of ways; others may be a better use of my limited time. (For that matter, doing other things that don't give me a better understanding of how things work may be a better, more valuable use of my limited time.) Yes, I could get a language that fits what I need better... in theory. In practice, it would be buggy,…

Having written several toy languages, I think that the process is supremely educational in ways that other efforts are not. In particular, it gives you an awareness of how these things can go wrong so that you can see where your day job efforts can go wrong if extended too far in some direction. You always learn about distinctions that were never apparent before you got into the details.

Without the freedom to make a mess of things, you live too cautious a life. It's worth digging in to some of these efforts even if they do wind up a mess. It's not because the mess will be meaningful. It's because you will understand better what was good and bad about what you did and how you got there.

Re: What you learn by making a new programming language

#115

Earlier quoted context omitted.

It's not its own kernel, but emacs can run on Linux as PID 1, at which point it rather seems like it should count as an OS. Given its affiliation, emacs/Linux probably still counts as GNU/Linux, but still...

I say if it's not running as the kernel, it's not an OS. Otherwise you could "boot to" any terminal app. Nano? OS. Cat? OS. Echo? Believe it or not, OS. Good grief.

Well, cat and echo can't run other programs, so no they wouldn't qualify. I'd have to check the nano docs to see if it can spawn other programs, but I'd be shocked if it's any good at it. In stark contrast, emacs can and is good at running programs, including interactively in terminals that it manages itself. I'm happy to agree that the kernel is a big part of the OS, but a kernel alone does not an OS make.

Re: What you learn by making a new programming language

#116

Earlier quoted context omitted.

I think the point is that - you write some piece of software - then you add a straightforward configuration language - then you add variables because you don't want too much copy/paste - then you add if statements to allow conditional configuration - then you add loops because you are sick of seeing configuration that consists of unrolled loops - ... At some point your configuration system is Turing complete, so coul…

But if configuration is the example, a full fledged Lisp program as your configuration is TOO MUCH. Do you want configuration files functioning as malware vectors? And what about Lisp is enduser friendly? Configuration files are intended to address people that are programming-lite to poweruser-not-programmer level. Lisp s-expressions are recursive tree structures with prefix ordering, which is a "great filter" for th…

A fully bracketed prefix notation is unambiguous. It requires no knowledge of precedence rules. Small children can learn it. Your editor can indent it in a consistent way, no matter how you break it into multiple lines. You're almost never left wondering what element of the program is a child of what other element. You know the argument position of everything; there is no guesswork. If you misplace a parenthesis, the wrong indentation clues you in. Working with Lisp syntax requires few brain cycles; therefore, the syntax per se doesn't demand high intelligence.

If you can fog a mirror, you can probably edit Lisp.

Re: What you learn by making a new programming language

#117
post #103

Earlier quoted context omitted.

As someone with similar mental health barriers, what strategies do you employ to overcome them?

I have not overcome them. Currently on dexamphetamine, my partner has noticed an improvement, me less so. Have been productive for the last week or two so making the most of it. List making, planning, routines, and pretty much anything that follows someone saying "You just need to ..." Doesn't work for me, or for any of the other ADHD sufferers I know of.

I wouldn't say I've overcome anything either but I'll throw in my two cents.

Personally I have accepted a.) most of my projects will be unfinished when I die and b.) if I am just staring at an empty terminal session and nothing is happening, it's not going to help to heap abuse on myself and feel guilty for not being productive. The only path forward will involve accepting that work isn't happening and doing whatever it is I can find a spoon for. On really bad days, that means just going to sleep. The sooner I accept that the sooner I will find a way to the other side, and nothing is getting done before then.

Reading about Taoism and Zen has helped. In terms of productivity, I have appreciated the book The Creative Act: A Way of Being by Rick Rubin. It's an attempt to apply Taoist ideas in a modern context, but where a Taoist text would say "the sage does XYZ," Rubin says "the artist." It's about finding a way to continue being creative when doing so is painful.

Medication and therapy have been a mixed bag for me, but my friends have had to go through multiple medications and therapists, so I remain optimistic. I'm trying to get into the habit of exercising and meditating.

Wishing the best for you both.

Re: What you learn by making a new programming language

#118
post #11

Earlier quoted context omitted.

Is this a joke I'm not getting? Any examples of such software?

Ratpoison, a tiling window manager for Linux, did this. The devs hit the point where they realized they were basically implementing parts of Lisp to allow more configuration. They ended up creating StumpWM in Common Lisp to be like Ratpoison if it allowed more configuration.

That's a cool piece of trivia

Re: What you learn by making a new programming language

#119
I learned that all programming languages come from the lambda calcul, created in the 30s, ten years before the computer era, a simple text rewriting machine using nothing but 2 operators, abstraction and application, working on a sea of words. Something like the Yin and Yang of TAO. More in http://lambdaway.fr .

Re: What you learn by making a new programming language

#120
I've been thinking about programming languages a bit and I agree. I was looking at Odin and some other languages.

I find it fascinating a language can be purpose-built, like Odin. It's a language that was built for game development. It got me thinking what a language built for web development may look like.

It also got me thinking, we have 'game engines' which are tools built around the same idea. Why don't we have web-CRUD engines? Sure we have frameworks, but we don't have entire purpose built applications for building fullstack applications.

Post reply on HN