0

For most of my professional career, I've never encountered anyone distinguish 类 or 类型 or class or type in spoken or written language, and the two concepts seem to be synonymous in programming.

But when I read HandWiki on this topic, it seems that type dictates the values of data1, where as objects are implemented in classes2.

Does any technical document "in-the-wild" (other than those specifically devoted to explaining their difference for educational purposes) distinguish between class and type?

4 Answers 4

2

(Though I do not major in computer science/software engineering or work in such fields, I am personally interested in programming and sometimes read technical discussions on websites including 知乎. The following are based on what I read)

As far as I know, 类 and 类型 are used differently.

Indeed 类 and 类型 might be interchangeable in many languages where user-defined types can only be classes, but in languages like C#, they need to be differentiated.

Apart from this point, there are still some preferences.

(The "bad examples" in the following part are not necessarily wrong, but they seem to appear less often)

类 is used in contexts emphasizing the OOP features, etc:

这个对象是某某类的实例

*这个对象是某某类型的实例

类型 is seemingly prefered in a question about the type, even if something is already known as an object:

这个对象的类型是什么?

*这个对象的类是什么?

1
  • 1
    I just realized they're different in usage. e.g. integer type: 整型, abstract class: 抽象类。
    – DannyNiu
    Commented Jul 12, 2023 at 13:42
3

Class is concept about OOP

  • class 类
  • abstract class 抽象类
  • superclass 父类
  • subclass 子类

Typing is used for typing system

  • type 类型
  • static / dynamic typing 静态/动态类型
  • strong / weak typing 强/弱类型
  • type inference 类型推导
  • duck typing 鸭子类型
  • built-in type 内置类型
  • boxed / unboxed type 装箱/拆箱类型

In CSS, it could be tricky, but translation consistent

  • class selector 类选择器 (selector match class attribute of some element, .active, .clearfix for example)
  • type selector 类型选择器 (selector match node name of some element, a, span for example)
0

Are class and type distinguished in Chinese

  • class is 級別 (among aircraft carriers, there are different classes)

Example: https://en.wikipedia.org/wiki/List_of_naval_ship_classes_in_service

  • type is 類別 (Aircraft carrier and submarine are two different types of ship)

Example: https://en.wikipedia.org/wiki/List_of_types_of_naval_vessels

Also:

藍鯨是一級受保護動物,虎鯨是二級受保護動物 The blue whale is a first-class protected animal, and the killer whale is a second-class protected animal. (different classes)

馬是素食類動物,貓是肉食類動物,人是雜食類動物 Horses are vegetarians, cats are carnivores, and humans are omnivores (different types)

1
  • Sorry, this question is somewhat technical in nature, and you haven't seem to grasp its essence when answering.
    – DannyNiu
    Commented Jul 12, 2023 at 13:43
0

类 - class, kind, category - A collection of things sharing a common attribute

  • 人(类)

类型 - type, pattern - A particular kind of thing with a customary way of operation or behavior

  • 愛生氣的人/类型
3
  • 1
    I believe OP is talking about "class and type" in the context of computer programming, and not as in everyday common usage? Commented Jul 13, 2023 at 1:45
  • @WayneCheah After further reading into it, I think you are right that he is looking for examples in the field of computer programming, 我是隔靴搔癢:)
    – r13
    Commented Jul 13, 2023 at 2:30
  • 尚未达到天壤之别 : ) : ) Commented Jul 13, 2023 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.