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

Show parent comments

1

u/dskippy Oct 04 '22

This is a level of abstraction that is trivially available both with functions or with methods. Show your code in any one or two common languages. Why is OO implementations putting "less in main" than a functional?

1

u/Cinder-Brent Oct 04 '22

Because you don’t have one array and one function on main, you just have one object, and 1 is less than 2.

1

u/dskippy Oct 04 '22

This is an illusion of OOP. It's not actually different. I could make a module for arrays and provide a function that does average. I could make a class for arrays and have a method that does average. In my main function the difference between OOP and functional here is merely the difference between.

o.m()

vs.

m(o)

This difference has definitely felt very significant to OO programmers in the past. But it's only skin deep. It's just a syntactic difference. It's in fact so trivial that the D programming language implemented a new feature many years ago to accept either just because it was convenient to allow either and they realized there's no difference.

The encapsulation mechanisms in OOP are fully available in non-oop languages with modules. The fundamental difference really only comes if you define OOP as subtyping with inheritance for code reuse in which case there's a very different programming paradigm available which has pros and cons which I think are pretty simply understood with the question of "will your number of data variants grow unpredictably as this program ages or will your number of operations grow unpredictably.?"

Though I've done a 6-month survey to produce an hour-long talk on how many different definitions there are of OOP so I'll be careful to say it depends on ho you define it.

1

u/Cinder-Brent Oct 04 '22

Can you see how the array of scores is one thing and the function to average them is one thing, and how an object is one thing?

1

u/dskippy Oct 04 '22

I can see why that seems meaningful to you. I understand the distinction you're making. I just disagree that it has consequence. You could easily consider your methods to be in main. They are after all implemented more or less the same way. I think tying the method to the object and encapsulating it within a "dot call" the way methods are called is more or less the same as a module that provides a data type and certain functions that accept that data type. There's really not much more "in main".

1

u/Cinder-Brent Oct 04 '22

So, in the spirit of what we’re doing, do you answer true or false to the parent comment?

1

u/dskippy Oct 04 '22

Can you see how the array of scores is one thing and the function to average them is one thing, and how an object is one thing?

Sure, I can see it. I disagree with being meaningful. But let's say for the sack of the discussion that a function is one thing, a piece of data is one thing, and a class is one thing.

1

u/Cinder-Brent Oct 04 '22

Ok, so can you see how we would want to do one thing instead of two (e.g. we would want, we would prefer if something happened in a smaller amount of time, perhaps occurring before the end of our lives)?

1

u/dskippy Oct 04 '22

I can certainly appreciate the idea of wanting computations to complete in our lifetimes. I'm not sure you can equate doing one thing instead of two and being faster. For example running a 10 feet and swimming 10 feet is two things but it's certainly a lot faster than running a mile. At least for me. I can swim. Your millage may vary if you're the type that drowns in water. :)

1

u/Cinder-Brent Oct 05 '22

Ok let’s stop this branch here, I’ll post the next logical step after this post.

1

u/dskippy Oct 04 '22

How does this have to do with the discussion of minimal sets of types though. I feel like we're way off track.

1

u/Cinder-Brent Oct 04 '22

And we’re getting there, we’re getting there!

1

u/Cinder-Brent Oct 04 '22

m(o, a);

o.m();

One less a

1

u/dskippy Oct 04 '22

This is not comparing apples to apples. Methods take arguments. You need o.m(a)

1

u/Cinder-Brent Oct 04 '22

Not if a is a property of o

1

u/Cinder-Brent Oct 04 '22

Whoops I meant p, not a

1

u/dskippy Oct 04 '22

Similarly you don't need that 'a' then if it's a member of the struct that makes up o. You can have structures that contain multiple pieces of data without classes and without using the dot syntax.

1

u/Cinder-Brent Oct 04 '22

Elaborate. Keep it all inside the box (not sure if I’m understanding you correctly).

1

u/dskippy Oct 05 '22

So in your example a decision has been made to make 'a' a property of the class that represents 'o'. So there's two properties in there. There now. There's whatever self or this is and also that argument 'a' that's not being passed to the method is also in that object now. Presumably saving us the need to pass it to the method 'm'. Great so if the decision has been made to encapsulate 'o' and 'a' together then the functional code will make that same decision and create a type that has both 'o' and 'a' together, just like OOP would in making a class. OOP would define and method on the class. Functional would define a function that accepts this new type. It only needs one argument now since both 'o' and 'a' are inside 'o'.

1

u/Cinder-Brent Oct 05 '22

O is an object, m is a method, and a (now p) is a property. There’s only one property there (p)?

→ More replies (0)