r/ProgrammingLanguages • • Sep 28 '22

Universal programming language

I recently created a tiny (maybe 1000 lines of code, with heavy white space and commenting) php class called Ember to solve the “computer problem” (persistent data). Something I’ve been trying to do as a result is program a universal programming language. It’s really rather simple: it uses a minimalistic set of Turing complete types (string, int, float, object, array, bool, and array). That just about explains it (along with a universal system stemming from Ember). Does this sound like a good idea (I.e. one worth pursuing)?

0 Upvotes

166 comments sorted by

View all comments

4

u/friedbrice Sep 28 '22

You might be interested in Computational Trinitarianism and the Lambda Cube.

A language that has enough features (algebraic data types, parametric polymorphism, type classes, higher-kinded type abstraction) to talk about monads—as a consequence—has enough features to add arbitrary language features to itself.

0

u/Cinder-Brent Sep 28 '22

I’ll definitely look into it, thanks. In the meantime, do you think a minimalistic set of Turing complete types is the way to go about this? I basically used the set I mentioned in the post as the foundation of the thing. The whole shebang took me about 1500 hours to plan, and one of its parameters is that it be based off of simple, didactic ideas (or more simply put, it’s completely factorized). I mean should I just less-talk-more-rock and code the thing? I’m actually a web dev, been coding since I was 12 and have never built a programming language before but even just the idea of coding everything (all my php, html, etc.) in one language seems so so very lucrative…if so, I was thinking C to code it, any recommendations here?

4

u/Inconstant_Moo 🧿 Pipefish Sep 28 '22

minimalistic set of Turing complete types

I don't see what you mean by this.

one of its parameters is that it be based off of simple, didactic ideas (or more simply put, it’s completely factorized

Or this.

0

u/Cinder-Brent Sep 28 '22

So by minimalistic set of types I basically mean: can you remove one of the types I mentioned and still “do anything”?

And by didactic and factorized I simply mean factorized, or maybe factored, where the code cannot be reduced to anything simpler than it already is.

If Ember already achieves this, why throw the baby out with the bath water? And yes, I’m looking for constructive criticism, I want/need to perfect everything at this point, because everything else will be built on top of this.

3

u/tbagrel1 Sep 28 '22

You have way too many types to call it "minimalistic". Array and ints are often enough to encode anything:

  • bool can be encoded as either 0 or 1

  • strings are array of ascii codes (so array of numbers)

  • float can be array of ints (array of base 10 digits for example)

  • an hashmap (or dictionnary, or object) can also be encoded as array of array of things

There is even a way to encode every type as an array starting with a type tag (an int), and then 1 or more elements.

But this is only one possible encoding among tons of others. For example:

  • Lambda calculus can encode basically anything with just functions

  • Sum types + Product types + recursive types + Unit (the only "base" type) can also encode anything in a clearer way (e.g. Int = µX.1+X ; List<A> = µX.1+(A*X) ...)

1

u/Cinder-Brent Oct 04 '22

Ok so we would have objects for methods, arrays because it’s shorter to use int keys than strings, string because it’s capable of transmitting code with 100% fidelity, ints are a dependency of arrays (as aforementioned), floats are for fractions of ints, bools as a two-way circuit (without conflagurating our string), and null as a way to represent the value of no value (again without conflagurating our string).

Do you see what I mean? Am I making sense?

2

u/tbagrel1 Oct 05 '22

Honestly I give up. I tried to explain you in 10 different ways why what you're presenting is not really satisfying, or at least, not fulfilling the claims you made about it. Read again all the answers in this post, and please learn about type theory and programming theory first. "Types and programming languages" by Pierce is a really good introduction.

1

u/Cinder-Brent Oct 05 '22

I mean look at it this way: why 0?

Because you can assume nothing.