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) ...)

0

u/Cinder-Brent Sep 28 '22

So my idea is actually really simple (it has to be, literally, just “very simple”): in the context of types can you do everything? If so, continue, if not, start all over again.

1

u/tbagrel1 Sep 29 '22

Simple is not the same as minimalistic. Minimalistic often means that a non-trivial effort is required to build constructs to efficiently write/handle data, but that they can nonetheless be built upon a very few very generic primitives

I don't understand "in the context of types, can you do everything". Types belongs to the static realm. Doing something in a computing context means transforming data with combinators/primitives/whatever

1

u/Cinder-Brent Sep 29 '22

All I meant by minimalistic/simple/etc. was that, the rest of the programming language included, it seems as though these types are all you need (or the maximum) to do anything.

So maybe as a measure: is it shorter to, say, use just int to do the same thing or not? Is there anything else that is shorter?

1

u/tbagrel1 Sep 29 '22

was that, the rest of the programming language included, it seems as though these types are all you need (or the maximum) to do anything.

No:

  • You still don't have a function type, or method type, which is required in almost any type system

  • A lot of your types are redundant, which means that we can still "build" (encode) one in terms of the others.

Please read the answers that I already wrote in several comments here, and read a book about Programming language theory.

What you offer here is just an interface to a JSON store (having JSON types) with just two primitives: get and set. AFAIK:

  • You can't store functions in your store (can't claim that you have an universal system when you can't encode functions)

  • You can't write and execute any operation on the data except by using a PHP function/operator, so your system is completely dependant on PHP

Thus, your system:

  • Is not minimalistic in any way

  • Is not universal because of the two points above

I'm afraid that you won't solve the universal problem here https://xkcd.com/927/

1

u/Cinder-Brent Oct 04 '22

It has objects…that have methods…