From which programming language did the idea for Golang's interface mechanism design originate?

266 views
Skip to first unread message

xie cui

unread,
Aug 24, 2023, 11:42:43 PM8/24/23
to golang-nuts
I remembe someone in a video in youtube explain the design of interface. But I cann't find it now.

Andrew Harris

unread,
Aug 24, 2023, 11:58:03 PM8/24/23
to golang-nuts
The comments on Go Data Structures: Interfaces mention Emerald, maybe this is what you were thinking of?

Rob Pike

unread,
Aug 25, 2023, 12:28:03 AM8/25/23
to Andrew Harris, golang-nuts
It was dreamed up independently at the whiteboard on the first day of design discussions. We did not know Emerald at the time; the similarity was discovered later.

This is not to claim the idea is original, just that we discovered it independently.

-rob


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/e873392b-47fe-4fa9-b465-efadcde0bfd8n%40googlegroups.com.
Message has been deleted

Thomas Bushnell BSG

unread,
Sep 1, 2023, 10:53:16 AM9/1/23
to Rob Pike, Andrew Harris, golang-nuts
Another precedent for the idea was the use of a "behavior" to specify the methods which a Smalltalk object can receive. Basically, it was realized that the question of the class hierarchy for an object was an implementation concern which the users of an object should not care about. So early Smalltalk books started using the word "behavior" to refer roughly to something like a Go "method set". When Smalltalk standardization happened, the class hierarchy was almost entirely left out of the standard, instead relying on these behaviors to say what methods an object would support. Implementations could then make their own decisions about how to factor those into classes for implementation.

The main difference between these behaviors and Go's interfaces is that a behavior in Smalltalk is only a way to talk about the language; there is no such thing as a behavior datatype in Smalltalk, no syntax for specifying them, etc. It's a way to document what things do, but not something checked by the compiler. However, as soon as you have typed variables, and you would be deciding whether the types should be classes or behaviors, you would certainly pick behaviors (and thus something like Go's interfaces) as superior to classes (like Java or Python typically use).

Thomas

Reply all
Reply to author
Forward
0 new messages