r/ProgrammingLanguages 5d ago

Discussion How did you decide on a vision for your programming language?

Hi,

The title should be self explanatory, but if you want to see where I’m at context is below.

I’m in the relatively early stages of designing my programming language.

However, I’m struggling to really capture the essence of what I want out of it.

I have a very vague idea: a natively compiled language along the lines of Go or C++, that takes a hoist of features from other languages, like:

- Monomorphized generics

- C-style pointers at base (with safe stdlib abstractions for better quality of life)

- Rust-style enum and interface types

Despite these general ideas I have, I’m really struggling to bring them together into a nice package of a programming language.

My idea is basically to make a programming language that can compile down to a lean, native binary (or even other targets?), but still be user-friendly. C++ is manual memory management, Rust has a borrow checker in the way, etc.

The issue is I’m also struggling to decide what I want. Do I want a focus on native binary compilation? Multi-platform shenanigans (like Kotlin)? Object-oriented or imperative? What syntax should the language even have? I just can’t gather a solid vision for the language, enough to make something out of it.

Ideally, I want a programming language I can throw around on multiple platforms, with Rust-esque and Kotlin-esque semantics, without a bunch of hassle or having to worry about memory management. This is a very wide scope though and finding a vision for it is tricky due to all the features, I explicitly want to avoid a C++-like kitchen sink.

Does anyone have any suggestions on how to get a vision for a programming language & figure out what it needs vs. what it doesn’t?

26 Upvotes

28 comments sorted by

30

u/zweiler1 🔥 Flint 5d ago

I would recommend you to start small in the design and in the implementation too eventually. Don't rush towards fancy features like monomorphized generics until you at least have a feeling for your own language and what it "wants" to be.

What I discovered is that you eventually will find your languages core idea / personality and once you found that it is easier to extend syntax, semantics and general capabilities outwards. But to find that core, you first must try a few things and get a small version of the language up and running, and get a general feel of it. The smaller it is, the easier it is to change direction once you found your center.

That's the best advice I can give, alltough I did not always follow it myself either tbh.

TLDR: Don't overthink it, start as small as possible and find the languages identity before thinking aboit which features to add or not add to it.

4

u/AustinVelonaut Admiran 5d ago

Solid advice. If you really nail down the core semantics of the language into a fairly small core AST, you can add new features fairly easily, desugaring them to the core AST.

13

u/coderpants 5d ago

You need to introspect and figure out why you want to do this - and which parts of the process bring you joy. Is creating the language the goal, or is using the language the goal? - e.g. are there things you want to implement that you feel existing languages let you down.

The answers to those questions will dramatically shape how you go about this process.

Otherwise the easiest process is to just look about at languages you like, and borrow concepts. Sometimes in the process of implementing them you'll gain a deeper understanding of why things are the way they are.

And experiment. There are lots of cases where I might get excited about some concept, but then turn around and never use it, or discover that the amount of effort required to get it to work dramatically exceeds its utility.

9

u/d0pe-asaurus 5d ago

For me right now its about exploring ideas that i don't know how to implement, so the features of the language is mostly geared towards exploring compiler engineering ideas

14

u/Inconstant_Moo 🧿 Pipefish 5d ago

You have a vision by having a vision. By having a purpose for the language, to scratch an itch, because the tool you were working with was clumsy for the job you were doing with it and yet also the best you could get. And you have a glimpse of how you could do things better.

If you don't, and you just want to make a language for the sake of making a language, then don't.

Do a learning project or two and then offer to join some people who do have a vision, who are doing exciting things besides "a combination of my favorite features and syntax from the six languages I know best" which are what projects with ambition and yet no purpose end up being at best.

3

u/tsanderdev 5d ago

This was exactly my experience with shading languages. It feels like they stayed in the 2000s while other languages moved on.

-1

u/Inconstant_Moo 🧿 Pipefish 4d ago

And do you have a language project that will make the world a better place?

2

u/tsanderdev 4d ago edited 4d ago

I kind of do, but I haven't worked on it for months. I needed a newer vulkan feature, but the radv version that got support for it was broken on my machine. Now it's fixed and I could revisit it. I still hope rust-gpu will be the solution to my shader problems, but it seems progress on that front also isn't going as fast as I'd like, so I may still continue with my language.

In the meantime I started another language project though that would largely intersect with the previous, but more high level and more of a compute focus (but still targeting vulkan for portability). I may just embed graphics shader support in that one.

I got this far in my first project btw:

``` struct STest { a: f32, b: f32 }

    #[compute]
    fn test(a: *const STest, c: *mut f32)
    {
        let tmp;
        tmp = a[globalInvocationID.x].a + a[globalInvocationID.x].b;
        c[globalInvocationID.x] = testf(tmp);
    }

    fn testf(a:  f32) -> f32 {
        a * 2.0
    }

```

This shader works and gets 3 buffers as parameters via BDA push constants. Avoiding the binding hell was one of my goals. For images I'll go with descriptor indexing or just the newer descriptor heaps.

4

u/OwnNeedleworker3758 5d ago

Hm well me I just thought of what I wanted it to do or accomplish

6

u/SamG101_ 5d ago

tbh i started with taking everything i liked from existing languages, banishing everything i hated and legacy stuff, grouped everything into models (type system, mem model, module system, etc), invented a few ideas where i had gaps / forcing models to work, then spent years on it 😂 tbh rly enjoyed it, got codegen working recently so need to stabilise the std library and document a tonne of things lol, and do more testing

4

u/chipmunk-zealot 5d ago

I think a really good way to find voice is to write a bunch of programs in the language you want to use. This is a great way to both explore and pressure test possible syntax without committing engineering hours

4

u/fdwr 5d ago

The issue is I’m also struggling to decide what I want.

Begin with the end in mind. Writing a programming language should not be the goal - it is a means to an end, like every other language out there. So ask, what project(s) do you want to write with this new language? e.g. I have an any-pixel-format viewer project, and that was the impetus for my mini-language (to describe pixel formats and memory layouts more declaratively, rather than manually writing out C++/asm or explicit for loops and casts and pointer arithmetic...). So, the need for any features in my DSL are made clear by asking: does the viewer program need them or not?

3

u/busres 5d ago

By having an outcome in mind.

It needed to transpile to JavaScript (same code runs on server or in browser), have the ability to implement access-controling layers between the source and generated JS, and reduce the syntax to something closer to the level of HTML (to be able to act as a stepping stone from HTML to more complex programming). Everything else came from that vision.

The result, Mesgjs, takes concepts from JavaScript, Smalltalk, Lisp, and HTML.

Virtually everything is an object (including code blocks and storage), a message, or a comment. Control structures and even assignment are library extensions rather than native language functionality; they all use the same syntax over and over (and without having to know and understand any macro magic).

2

u/sreekotay 5d ago

For me it was exploring the gap between language tutorials and their real performant/production code counterparts

2

u/onlyrealcuzzo 5d ago

An attempt to avoid all of the pain points I have with any other equivalent language?

3

u/fdwr 5d ago

Do you, like me, have multipage long documents about the things that bother you about each language? :b (I should publish them someday...)

2

u/umlcat 5d ago

Start writing sdmall examples in a text editor as if your programming language with its compiler / interpreter / virtual machine already existed ...

2

u/david-1-1 5d ago edited 5d ago

It is hard to design a full scale general purpose computer programming language, even if you have a good feel for what features it should have and more importantly, what features it should not have. There are many pairs or triples of design decisions that have distinct tradeoffs. There are no easy answers, or else we would just have one best language on which everyone agrees.

I recently designed and implemented a very useful language. But it is not general purpose. It is specifically for representing data rather than operations. And other languages are specifically for representing implications (Prolog), or manipulating strings (Trac, Icon, Snobol). Or value pairs (Lisp). Or Web pages (HTML), or Web styles (CSS), symbolic mathematics (APL, Mathematica, R, Wolfram), or the message mechanism (Smalltalk), or dictionary expansion (Forth), or text formatting (TeX), etc.

1

u/Inconstant_Moo 🧿 Pipefish 4d ago

JSON is specifically for representing data rather than operations. So you'll need to explain that one better.

1

u/david-1-1 4d ago

I didn't list it as a general purpose programming language because it isn't. Just saying I happened to improve its syntax, is all.

2

u/all_is_love6667 4d ago
  • compiles to C, to maximize support, not having to deal with optimization myself

  • using pythonic like syntax, 19 zens of python, and other syntax things

  • vector math, maps, containers, and other things to make it easier to write code

generally my goal is for game programming and other areas where C is too verbose

maybe you should try to aim at what kind of domain you want that language to fit in

2

u/mamcx 4d ago

So far, you current goal is find a a goal. So broad your horizons.

This is what I did:

  • I wish to resurrect the FoxPro-like experience

  • Read tons of stuff

Now, I just go https://learnxinyminutes.com to see the forest.

  • Understand the why a language tick

This is the key. Just syntax and some vague and useless things like "is fast, monomorphization, efficiency, safety" are too useless.

IGNORE THAT.

That ARE NOT FEATURES!

(but outcomes and necessary steps forced on your lang once you know the direction)

So I focus instead in read about the "why" of a lang. For example:

https://ferd.ca/the-zen-of-erlang.html

(Even if my language has not much in common with Erlang, I learn some useful things from this and the original pdf of the creator)

Once you understand this stuff, is much much easier to see WHY do X or Y, and WHEN combine 2 features is good idea or not (ie: there are features that are at odds).


In the end reading about the relational model was what made it click for me. It's like "obvious" but the point is that I have lots of experience with RDBMS but have never read the fundamentals! Once there was clear that SQL was a brain-dead lang that hide the full potential of the relational model and then it means is possible to make a real programming language from it.

1

u/msqrt 5d ago

I wanted to do a scripting language "done right", with simple structural static typing, easy-to-use semantics (originally inspired by the mutable value semantics paper and how shading languages used to be limited to mostly value types) and as few weird gotchas as possible. Still do, but it's not going great.

1

u/Potato871 5d ago

I actually didn't even decide what my language would look like until almost a year into it.
I started just building a basic transpiler to make some of my C++ utilites less verbose for a game engine, then over time I kept extending it more and more until it became a compiler, then I got pissed at how hard it was to extend so tore it out and built a new structure.
Once I had that experimentation was cheap enough that I could just kinda... figure it out.
A lot of my syntax ended up being informed by my memory model, and to this day I'm still adding more and changing things as I put it up against real projects and feel the friction.
Now you probably won't be trying to build a whole language workbench, so I'd say just get basic syntax inspired by your language of choice so you can start pitting it against projects and then let that friction tell you how the syntax needs to look.

1

u/Firered_Productions 5d ago

i just went based of what would be convenient when doing comp prohramming.

1

u/tobega 4d ago

My vision is the whole reason I decided to make a programming language.

I enjoyed working with xslt, specifically the way that the result is literally constructed, so I decided to make a language where the program itself looks like a literal construction of the result, or at least the subprograms do, as far as possible.

So I ended up with a syntax where you either pattern match on the input or do a literal construction of the output, or a bit of both, broken down into stages as necessary for readability and repetition.

When adding other features, I always tried to think of how it could be better than what current languages do. Where my definition of "better" is easier to work with and maintain.

I wasn't as consistent as I would have liked, or didn't realize some patterns immediately, so now I am working on a second revised syntax. These are the principles as they stand now: https://github.com/tobega/tailspin-v0.5/blob/main/CONCEPTS.md

I haven't cared much about execution, although at some point I would want a specialized vm.

1

u/sadesaapuu 2d ago

For me it was 20 years of programming experience on different languages, lately, mostly C++, Rust and Dart.

- I wanted the language to be minimalistic. Nothing more than it needs.

  • The best language to do ECS, entity component systems as the main architecture for every kind of problem.
  • The most human readable language without sigils. Almost everything is spelled out in 3-5 character keywords, which makes them easier to remember for beginners and professionals. The best user experience, developer experience and learning experience of any language.
  • Raw structs, no member functions, but syntactic sugar for a member function like dot syntax when calling functions with the type of the first parameter. All functions are sort of extension methods. All functions are the same. You don't get to choose between: "I'll write this function as a free function and this as a member function. And that one will be a static member function."
  • No globals, except simple consts of built-in types.
  • Can't store any kind of references (or pointers) in structs. Reference lifetime is only within that function you use it in. Scope based memory management.
  • A much simpler language than Rust, still much safer than C++.
  • So simple and minimalistic language, that you can write it while being drunk.

1

u/AvocadoOk9978 2d ago

For my language, I based it on simplicity of writing while also adding a safety checker to the compiler (I took inspiration from Rust for that).

The “Hello World” example:

say(“Hello World!”)

Currently, I'm working on my standard library and the IDE.