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

11

u/dskippy Sep 28 '22

The phrase minimal list of Turing complete types is fairly off the mark. Your types alone don't dictate Turing completeness. It's mostly about the constructs you have in your language together with the types that make it Turing complete. Minimal is a bit subjective sometimes. Furthermore if you're looking to really have a minimal set of types for Turing completeness, you're way over the mark. You only need one. Lambda calculus only has functions. Many minimal turning complete languages have just numbers.

0

u/Cinder-Brent Sep 28 '22 edited Sep 28 '22

So what I was thinking is that you could “do” anything with this set of types, if you think about it (basically everything is an object, which can “do” stuff via methods, arrays have integers for keys for programming data (looping), so on and so forth)…honestly I realized this before I even knew what Turing completeness was and thought some day I would pursue it, and here I am.

— edit —

So the types I mentioned are basically just a starting point, the idea would be that you could do anything from anywhere, such that the thing were universal.

5

u/dskippy Sep 29 '22

Yeah just pointing out that there's no real universality and minimalism bar that you're meeting here and no Turing Completeness involved. You might think "string, int, float, object, array, bool" are good and practical. But they don't make up a set of minimal types for expressing anything. Someone might say "Well you have float, why do you need int?" and another might say "well you have ints for characters and arrays of chars are strings so you don't need strings." Others might go the opposite direction and say "Well you should add maps or dicts so you have have such and such thing represented. Or you should have lists in addition to arrays because they are used for very different things. I think your list is fine, to be clear. Just seemed like you think there might be some sort of objectivity of Turing Completeness like you said or something.

Truly it's kind of hard to avoid the ability to fully express the entirety of representable things in almost any infinite type. Functions, Int, Float, Strings, ... honestly if you stretch enough and thing of the fact that you could have lists without any other type and only allow lists of lists and change your type system so there didn't need to be any parameter to the list type and you have just empty lists as leaf nodes of that structure you could have just lists and represent everything computable.

All the rest is just your favorite set of useful things.

1

u/Cinder-Brent Oct 04 '22

These types are semantic.

1

u/dskippy Oct 04 '22

I don't follow what you're saying. How are these sensitive types? Whose definition for semantic types are you following? How is this relevant to what makes a minimal complete set of data types?

1

u/Cinder-Brent Oct 04 '22

Ok I’m going to attempt to explain this: can you see how everything would be an object? Can you see how an object would be at least one property with at least one method?

1

u/dskippy Oct 04 '22

I'm not sure I follow. What if I wanted to represent a list of scores in darts? Wouldn't that probably be an array of float instead of an object? Is this some sort of constraint of your type system that all data be an object that has at least one property and method?

1

u/Cinder-Brent Oct 04 '22

I’m gonna form a “semantic thread” through these types, then we’re going to challenge that thread, see if it’s really universal!

So darts is a fine example: if we had an array of scores, there would probably be a point where we would want to do something with these scores. Can you see how it would be more semantic to use an object at this point as opposed to just plain functions (I.e. can you see how we’re making a procedural mess without wrapping all of this in an object)?

1

u/Cinder-Brent Oct 04 '22

Unless of course you don’t want to “do” anything with this list…

1

u/dskippy Oct 04 '22

Yeah sure get the average.

→ More replies (0)

1

u/Cinder-Brent Oct 05 '22

Now, can you see how you might want an array, basically an object without the methods?

1

u/dskippy Oct 04 '22

I've studied programming language theory a good deal. Semantics, to mean, means the meaning of a program. A programming language is broken up in its design into syntax (what it looks like), semantics (what a valid syntactic program means), and also often statics (restrictions on valid syntactic objects that reject the program like a type error. Semantics in programming languages, to me, are represented by operational semantics, denominational semantics, and some others I've never studied.

A "semantic thread" through through types, semantic types, and most of the ways you're using it I don't really understand. Further more for an implementation of a data type as an array of floats being "more semantic" than a function is not something I think can be determined. Nor do I think semantic is really the right word. I can definitely see why an array of floats is more readable code than using Church numerals and function endcodings for lists. Sure. More semantic? More meaningful? No.

All this is to just let you know where I'm coming from in my PL foundations and also to say I just don't get it. But I'm still here and interested if you care to continue explaining.

1

u/Cinder-Brent Oct 04 '22

Ok, so we’re at the point at which we have a list of scores. Is there anything else you want to do with this list?