New programming methods: collective programming

Facing the process or the object?

Now we have a better choice! The collective programming!

Video address (in Chinese)

The video above gives a brief introduction to my vision of collective programming.

Online help:

Is there a expert that can use Rust or C to implement a programming language that supports collective programming? Many thanks!

Hi and welcome!

Your video is in Chinese, so it’s a bit inapproachable for most forum members. I’ve extracted a transcript and added machine translation.

Also note that in English, the terms are usually “procedural programming” and “object-oriented programming”, not “facing the process/object”.

click here to expand transcript & translation

Slide 1
近期,我设计了一种全新的编程方法。

I have recently designed a brand-new programming method.


Slide 2
不同于以往的面对过程和面对对象,
我将其称之为“面对集体” (group-facing programming)

Unlike traditional procedure-oriented or object-oriented approaches,
I call this new approach “group-facing programming.”
(Translation note: one could also interpret this as “group-oriented programming”.)


Slide 3
集体的成员可以是对象,可以有成员函数

The members of a group can be objects, and they can have member functions.


Slide 4
下面是一段伪代码示例

Below is a sample piece of pseudo-code.


Slide 5 (Code Snippet)

group Mammal {
    Cat;  // 前文定义过的Cat类 // the Cat class defined above
    Dog;  // 前文定义过的Dog类 // the Dog class defined above
    func eat() {
        Cat.eat();
        Dog.eat();
    }
};

这是一段伪代码示例

Here is the pseudo-code example.


Slide 6
因为 group 中的成员不是一个一个的对象,
而是批量管理一组一组(属于一个或多个类)的对象,
所以伪代码中 group 显式地使用类作为成员

Because the members in a group are not individual objects but instead manage batches of objects (possibly belonging to one or more classes), the pseudo-code explicitly uses classes as its members.


Slide 7
我们可以把一个集体
理解成多个动态数组,
这些数组中的每一个元素
都是对应类的实例化对象

We can think of a group as multiple dynamic arrays,
each element in these arrays is an instantiated object of the corresponding class.


Slide 8
集体可以访问每个成员对象除
private 之外的所有内容
包括成员的成员函数

A group can access everything in its member objects that is not marked private,
including each member object’s member functions.


Slide 9
通过集体调用类的成员函数时,
会自动遍历集体中该类的所有实例化对象,
逐个调用该类每个对象的该成员函数

When you invoke a class’s member function through the group,
it automatically iterates over all instantiated objects of that class within the group
and calls that member function on each of those objects in turn.


Slide 10
group 也可以被实例化,成为数组元素
或其他类、集体的成员,或是函数参数或返回值

A group itself can be instantiated, becoming an element of an array,
or a member of another class or group,
or even a function parameter or return value.


Slide 11
集体也允许嵌套和继承

A group also supports nesting and inheritance.


Slide 12
集体允许不同的对象拥有不同的状态,
也允许通过显式方式访问集体中的特定对象
即可获取特定对象的状态或执行
特定对象的成员函数

A group allows different objects to maintain different states.
You can also explicitly access specific objects in the group to check their state
or execute their member functions individually.


Slide 13
集体中的某一特定成员
可以通过字面方式加入或离开集体
也可以通过隐式方式加入集体

A specific member of the group can join or leave explicitly,
or it may be added implicitly.


Slide 14
让我们回顾一下刚刚
哺乳动物(Mammal)的那个例子

Let’s revisit the Mammal example we just saw.


Slide 15
我们有一群猫和一群狗
(假设它们和睦相处)

We have a group of cats and a group of dogs (assuming they all get along).


Slide 16
我们可以一只一只地把它们叫来,让它们吃东西;
当然也可以选住某一只狗,让它自己一只狗吃

We can call them one by one to come and eat,
or we could pick a specific dog to eat on its own.


Slide 17
不同的狗和猫的饱腹值可以不一样,
狗和猫吃的也可以不一样

Different dogs and cats can have varying fullness levels,
and what they eat can also differ.


Slide 18
我们可以让一只狗或猫加入这个群体,
当然也可以把其中一个踢出来
群体中的动物生下来的崽子,
也自然加入这个群体(仅仅是例子)

We can add a dog or a cat to this group,
or remove one from it.
Offspring born to animals in the group would naturally be added to it (just as an example).


Slide 19
也许有人说:“那么为什么不直接
用储存对象的动态数组呢?”

Some might ask, “Why not just store the objects in a dynamic array?”


Slide 20
集体提供了一种更为集约化的管理方式,
让程序员能够更专注于更重要的地方,
而不是亲自处理数组遍历等细节
集体也可以使代码更经济,结构更简单

A group offers a more centralized way to manage these objects,
so programmers can focus on more important aspects,
rather than manually handling array iteration and other details.
A group can also make the code more concise and simpler in structure.


Slide 21
如果编程语言支持集体这种特性,
会给程序员省下很多麻烦

If a programming language natively supported this “group” feature,
it would save programmers a lot of trouble.


Slide 22
比如在游戏制作中

For example, in game development:


Slide 23
大量类似对象(比如方块、敌人)
就可以用集体处理

A large number of similar objects (e.g., blocks or enemies)
can be managed via groups.


Slide 24
避免了多个动态数组以及手动添加对象的麻烦

This avoids having multiple dynamic arrays and having to add objects manually.


Slide 25
所以说这的确是一种有意义的构架

Thus, it truly is a meaningful architecture.

To be honest, this presentation still contains relatively little in terms of concrete details. There’s a code snippet, but I can’t really say it becomes clear what exactly it means. I’m sure it’s much clearer in your head, but it’s hard to communicate in a set of slides and with no usage code examples.

It seems to me there’s much design work left before one could even start worrying about concrete implementation details, and the question of how&whether “Rust or C ” might be a necessary tool,

It can be fun to share rough design ideas, but this won’t realistically lead anywhere. The world is full of many people who have many ideas. Nonetheless, even the best ideas will usually not result in any “expert that can implement a programming language that supports” that idea.

Note that even if a new programming language is implemented to demonstrate a promising new language design idea, or paradigm, it’s most commonly the case that it won’t really lead to much in terms of other people being interested in actually practically using it.

Realistically, the normal way of making a new (and practical) programming language a reality would involve fully designing the language yourself, implementing a compiler/transpiler/interpreter yourself, and also making (practical) use of it yourself.


The idea is also notably containing relatively little relevance to Rust. Rust can be a reasonable choice for implementing a compiler or interpreter; but it appears to me that the “group-oriented”/“collection-oriented” paradigm you’re describing might be more effectively used by embedding it into an existing language.[1] For instance, this could be as part of a game engine. That being said, I’m not much familiar with game development; I wouldn’t be surprised if game engines already support good abstractions, perhaps even including some DSLs (=“domain-specific languages”) – for concepts such es “entities”, that offer all the general functionality and convenience laid out in your slides.

Your slides speak of objects, classes, and inheritance. Speaking from experience in the Rust world, note that many Rust users might be skeptical about the need of programming languages to support the full  ‘classical’ OOP model & feature-set that this seems to assume and build on.


  1. Which helps cut down the effort to make it happen in the first place, and also gives better/easier adaptability and integration with existing infrastructure. ↩︎

5 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.