Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the relation between "generics" and "higher-order types"?

From this question: What is a higher kinded type in Scala?, I understand what is higher-order types(also first-order type and proper type).

But there is still a question: What's the relation between generics and "higher-order types"?

I know Java supports generics, which is like the first-order type in Scala.

Which of the following are correct?

  1. In Scala, only the first-order type is generics
  2. In Scala, first-order and higher-order types are both belong to generics
  3. In Java, the generics just mean first-order type, it's not complete
  4. generics is a common term means we can "abstract" on types, no matter first-order or higher-order
like image 340
Freewind Avatar asked Nov 10 '22 08:11

Freewind


1 Answers

I'd say (1.) is wrong. I'm not sure about (3.) because I'm a bit out of practice concerning Java. But I'd say (4.) is pretty accurate and somewhat similar to (2.).

As far as I know, the term generics refers just to the usage of type parameters. It applies to both first-order and higher-order types or functions.

Offtopic (and somewhat nerdish): Does anyone else see a hidden reference to Wing Commander in (2.)

like image 92
Sascha Kolberg Avatar answered Nov 14 '22 21:11

Sascha Kolberg