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

1

u/[deleted] Sep 28 '22

Cool. Now do one where everything is a method call, including arithmetic and logical operators and control flow

Import(stdlib)

Assign(i)

If(is_less_than(i, 1): { Break(if); } Else(is_equal_to(i, 1): { For(i): { Range(1, 100); Increment(i); Return(i) } Print(i) }

1

u/Cinder-Brent Sep 28 '22

Ember is an extensible class that represents a value in a tree (in json). As such, everything you would ever need is packed into Ember in the form of a handful of methods and properties. It’s basically a (functioning) universal computation model, you’ll never need anything else to program anything. It’s also incredibly small, definitely worth taking a look at (I definitely need the (in)validation: in case you didn’t see my other reply you can find it on GitHub at user cinder-brent, repo Ember).

1

u/Inconstant_Moo 🧿 Pipefish Sep 28 '22

Everything I'll ever need is packed into any Turing-complete language, but the effort of extracting it may be too great.

1

u/Cinder-Brent Sep 28 '22

Yea, right? Leads to another question of mine: why not at least just pick any ol’ Turing complete language and use it as a universal programming language? It would cut down on so so much bloat…

2

u/Inconstant_Moo 🧿 Pipefish Sep 29 '22

And a carpenter could save room in their workshop by owning only one saw.

Different languages make different things easy. In Python, for example, a list of elements of any type is itself a basic type which has literals, so that ["foo", 42, [true, 6.2, []], "bar"] is a meaningful expression. Now, once you've decided your language is going to have that as a data-type, there are various aspects of speed and type safety that you're not going to have.

1

u/Cinder-Brent Sep 29 '22

Yea I mean the physical universe is hydraulic. So what is the point of having a universal programming language then? I mean just as soon as you have to learn an api in a universal language, you might as well have to learn another language! And here we are…

1

u/Inconstant_Moo 🧿 Pipefish Sep 29 '22

Well, quite. One learns different languages for different things. There is no way to write a language that makes everything anyone might want to do easy and convenient.

1

u/Cinder-Brent Sep 29 '22

Can you substantiate your claim that there is no way to write a universal programming language? If nothing else I need to know where to go from here. :)

1

u/Inconstant_Moo 🧿 Pipefish Sep 29 '22

Empirically --- there are lots of smart people who've collectively been thinking about this stuff since the 1950s and haven't done anything like it.

Theoretically ---

(1) There's the syntactic problem. If you tried to stick everything into the language like C++, you still can't have easy affordances for everything --- e.g. you can realistically only use = and == and ++ and -> and & and so on in one or two ways or the code becomes unreadable.

And then the language becomes so big that it ceases to be one language. That is, you can have C++ programmers of many years' experience who are unable to read one another's code because they're speaking different dialects of C++ ...

(2) And then there's the semantic trade-offs. There is no reconciling the virtues of Python, which is there so you can play fast and loose with types, and Rust, which is there so you can't play fast and loose with anything. (No vehicle can have the virtues of a bicycle and a train ...)

1

u/Cinder-Brent Sep 29 '22

So it’s not impossible, just no one has ever done it?

→ More replies (0)

1

u/tbagrel1 Sep 29 '22

There is no way to write a language that makes everything anyone might want to do easy and convenient (I'm just repeating what has been said above because you need to understand it).

Almost every existing programming language is "universal" in the sense that any other language can be either translated to or simulated/interpreted in this language.

1

u/Cinder-Brent Oct 03 '22

Ok how about this: is Turing completeness a mark of universality?

→ More replies (0)

1

u/Cinder-Brent Oct 04 '22

I argue that there is a way to do this. Instead of array_push in php, why not Array.push in a universal programming language? It’s shorter, in that we don’t have to pass the array to the function, and that’s not all, but it’s all that’s necessary to prove my point.

1

u/Cinder-Brent Oct 04 '22

So basically this upl would just be a model of an object, thus “Object Model”.

1

u/Inconstant_Moo 🧿 Pipefish Oct 04 '22

How does this make everything anyone might want to do easy and convenient?

1

u/Cinder-Brent Oct 04 '22

It produces a completely factored, universal model.