Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Using ADT to mean “abstract data type” does not mean anything more than what most people mean when they say “type”. Outside of distinguishing from other meanings of the word “type” there is no practical reason to ever say it. It doesn’t sound fancy, it just sounds like getting high on your own supply of acronyms. It is not an important term to learn as a beginner in the first chapters of a programming book. We should stop using it in resources like this.

Otherwise, ADT can also refer to “algebraic data type” which means the ability to compose types together thereby adding or multiplying the different values the resulting type can take. Product types (aka structs) multiply over their fields; two int fields when taken together can take on (# different values of int) * (# different values of int) different values. Sum types add over their variants: a Rust enum “enum OptionalInt { Some(i32), Maybe(i32), None }” can take (# different values of i32) + (# different values of i32) + 1 different values.

Most languages have structs and that’s the “product type” sorted, so ADT generally refers to a language having tagged enums. C doesn’t have that but you can emulate it (quite badly) with unions and enums. Good examples of languages with ADTs are OCaml, Haskell, Rust.



> Using ADT to mean “abstract data type” does not mean anything more than what most people mean when they say “type”.

Abstract data type is a type where you don't get direct access to the information contained in it. The encapsulation is what makes it "abstract".


We should call it an opaque data type then.


That thing was named much before the other ADT became popular. The name is spread over a lot of past texts, and not in wide use anymore.

There's no point in changing anything.


Is a Java ArrayList considered an ADT like stack, queue, set, etc?


In the context of C programming, ADT usually means an opaque struct with some related functions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: