In my life’s journey, I didn’t like philosophy at first, because after China divided the school curriculum into arts and sciences, I naturally took sides with the sciences and hated the arts. However, by chance, I saw professor Yuan Juzheng from the Department of Philosophy of Taiwan University explaining financial news using philosophy on a financial and economic program, which aroused my interest in philosophy and led me to study philosophy.

From the origin of human civilization up to now, there are many philosophical ideas created and spread in the world. I can’t give you any examples here, just a few of the philosophical ideas I know and can apply to my work. Not a philosophy major, please forgive me if there is a mistake.

The existential

Swift has a container called an Existential Container that is invisible to the developer, just like NSGlobalBlock, NSMallocBlock, and NSStackBlock — unless you remove the compiler, Otherwise, it would be hard to detect the existence of this thing. In the following code, the compiled Swift code constructs existentialist containers for the variables foo and bar to store the type instances behind them:

protocol Foo {
  var foo: Int { get}}protocol Bar: Foo {
  var bar: Int { get}}struct Fee: Bar {
  var foo: Int
  var bar: Int
}

let fee = Fee(foo: 0, bar: 0)

let foo: Foo = fee

let bar: Bar = foo as! Bar
Copy the code

We can see that if we allocate memory on the stack according to Foo’s members, then when fee is assigned to Foo, it will inevitably cause a contradiction in the allocation of storage space because Foo has two Int members while Foo has no instance variable members. In C++ there is a similar problem called object slicing, and in much the same way, Effective C++ explicitly lists this kind of behavior as something to avoid. Swift uses “existentialist container” to solve the contradiction in space allocation — a small buffer of uniform size is built on the stack to store type instances of small memory layout, and when the memory layout of type instances is very large, a reference is stored in this buffer and the instance data is thrown onto the heap. For different types, a virtual table for function distribution and special value witness table and Protocol Witness table in Swift are also constructed after the buffer. Swift’s “existentialist container” means that whatever data is stored in the container is stored in the “existentialist container” when the code that uses the container sees what kind of data is stored in the container — the data bound to the variable foo is stored in the “existentialist container,” Using his code foo the variable is of type foo, so foo sees that the data inside the container is of type Foo, and the virtual table behind the buffer is the virtual table of Foo; The data bound to the variable bar is stored in the “existentialist container”. Using his code bar, the variable is of type bar, so Foo sees that the data inside the container is of type Bar, and the virtual table behind the buffer is the virtual table of bar.

This is existentialism, emphasizing that those who apply existentialism do not use rational thinking, but use their own subjective experience for judgment. Switching to Swift code is a variable bound to an “existential container” that looks at the type of data inside the container using the type specified by the variable itself — of course, type coercion still does runtime checking.

In addition, IN the team work, I also began to learn to use existentialism to examine my teammates’ work.

Most of the time we want to write fast and not pretty code, and I’m no exception. This code will later be called technical debt. In fact, from the perspective of economics, I think “technical debt” is the same as “assets and liabilities”. In fact, “technical debt” is a neutral word. If we are in a critical position, we may choose to criticize a teammate for his skill level or work attitude. However, from the perspective of existentialism, when a project team members to work there, and the final project success, then the job is to lead to the success of the project team members work – here I learned to refuse to rational thinking, because human rational thinking are based on the basic of the so-called “analytical thinking” – the things that come to the conclusion that the development of several conditions, And then you do it like you do in high school with a single variable. However, the human mind can never understand all the details of the development of things, and judging things as an indivisible whole can be regarded as an effective means to study complex processes. Here, the use of “analytical thinking” to zoom in and out of a single condition and then deduce the possible development of the situation seems to me very historical nihilism. And I think an “existential” attitude to one’s performance is the basic principle of an organization’s reward system.

Aristotle’s essentialism

Essence, essence. The root esse comes from Latin, where it means “be” — to be. Aristotelian essentialism is about the attributes that cause something to exist out of context.

I often use “Aristotelian essentialism” when designing systems.

For example, in the process of designing the non-wire knitting business architecture of a video editing app THAT I recently participated in, I encountered such a problem:

Should the time and position information of the clip in orbit be a property of the clip?

I’m sure a lot of people will choose to put the time and position of the satellite in orbit into the “satellite” when faced with this problem. But in fact, if we apply Aristotelian essentialism to the problem, we immediately see that: If we remove the “time location information of the orbit of a” vice “, then the “vice” it’s still a “vice” – that is to say, after the idea of “vice” out of context, if we stripped off “time location information of the track,” vice “this concept is still exist. Therefore, “time and position information in orbit” does not belong to the essence of “side film”.

And I realized that the “side film” was no longer the “side film” when it was added to the orbit, but became something else, and we needed a new concept to refer to it. Finally, I invented a term called ClipFrame from the framesetting session to refer specifically to the “side piece” that was added to the orbit, and the ClipFrame recorded the time and location of a “side piece” on the orbit. Tracks, on the other hand, provide the business of adding, removing, and moving “sub-pieces” — they might operate like an array, because some tracks operate like arrays; It is also possible to operate using time positions as parameters, as some orbits allow time gaps between the “sub-slices”. After the track is added to the “sub-slice”, a ClipFrame will be allocated to store the “sub-slice”. When Sequence and Collection operations are performed in Swift, a tuple containing the “sub-slice” and the time and location information in the track will be spit out.

Yes, those of you who are familiar with the database have noticed that I’m doing some normalization. However, sometimes system design is denormalization, so that the performance of the subsystem is higher. However, how to do the specific system design still needs to have performance capacity thinking, with the performance capacity can bear the corresponding design to make a choice.

Objective idealism

How to understand objective idealism? First of all, it should be clarified that “idealism” is a wrong translation. The English word “idealism” is ideal, according to its root idea, the Chinese translation into “idealism” is better — it emphasizes that “material” depends on “idea” and exists.

This idea seems a bit counterintuitive to us — people, as a mass of “matter”, must have existed before they could think about “ideas”. However, every “matter” is itself an “idea”, and we cannot identify the matter without inventing its corresponding idea. It’s a bit of a chicken-and-egg problem. “Idealism” takes the side of “idea” before “matter”. “Objective idealism” emphasizes that a certain objective principle should be upheld when identifying the “idea” of a certain “matter”.

If we can understand objective idealism, then we can also understand why some people say that “object-oriented/object oriented” is a hoax and that the DESIGN of the IS-A pointer is ridiculous.

Imagine designing software systems for a pork dealer and a biologist. They all have the “pig” class.

According to the object-oriented/object oriented principle, the pig class might have the following properties for the pork dealer:

  • Pig’s ear
  • Swine e.
  • The pig hoof
  • The pork shoulder
  • Pork tenderloin

To a biologist, the pig class might have the following types of properties:

  • DNA
  • RNA
  • cells
  • organization
  • organ

However, when we look at a piece of pig skin, we find that the same ingredients that are called “pig skin” by pork dealers are called “the largest organ in the pig’s body” by biology. Or rather than looking at the different properties under the “pig” class, we should know that we have two different “ideas” for one thing in the physical world. In an object-oriented/object-oriented world, we would represent these two concepts in two classes that cannot have the same IS-A pointer — even though the real world stuff behind them is the same.

Faced with this problem, the industry has an architecture called entity-component-system that can completely circumvent this dilemma. In this architecture, any data is treated as an entity; And an entity is composed of multiple components; Finally, systems (or functions) run periodically to select the components to care about, traversing all entities in turn, and calculating them in a system call. In this way, all things are entities and only their components make them different, avoiding the problem of us standing in different positions and establishing different concepts for the same things in the real world.