|
|
Subscribe / Log in / New account

Generics for Go

Generics for Go

Posted Jul 1, 2020 19:13 UTC (Wed) by acarno (subscriber, #123476)
Parent article: Generics for Go

Not that I know much about Go, but why not look at generics in languages other than C/C++/Java? For example, Ada has (strongly-typed) generics:
https://www.adaic.org/resources/add_content/standards/05r...


to post comments

Generics for Go

Posted Jul 1, 2020 19:53 UTC (Wed) by dvdeug (guest, #10998) [Link] (2 responses)

C++ templates were designed after Ada generics, and Alexander Stepanov, who wrote the Standard Template Library for C++ and pushed for C++ templates with Bjarne Stroustrup, did his first proto-STL in Ada. So C++ and Java should show a more refined form of Ada generics.

Personally, I've worked with Ada generics. The Ada type system added complexities in places that don't seem to have wins in retrospect, and Ada generics reflect that. They don't have the sheer power that C++ templates have, or the usual elegance of Java. I'd be interested to see languages from a universe where Ada was more successful and modern languages stuck more to its design principles, but in any case, Ada generics were the first major generics implementation, and it shows.

Generics for Go

Posted Jul 8, 2020 6:58 UTC (Wed) by ncm (guest, #165) [Link] (1 responses)

C++ generics do not, in fact, draw on Ada generics, and the Ada attempt at an STL was a dismal failure, as it would also be in Java were it attempted.

C++ generics do owe a lot to ML (not "machine learning"; there was a language ML that also influenced Haskell). Java generics are extremely limited, and their backward compatibility means they offer no performance improvement over older mechanisms.

Generics for Go

Posted Jul 16, 2020 10:17 UTC (Thu) by jch (guest, #51929) [Link]

> there was a language ML

Why in the past tense? ML is doing fine, the dialect with the most active community would appear to be OCaml, https://ocaml.org/ . (It looks to me like ML was an important inspiration for Rust.)

Generics for Go

Posted Jul 2, 2020 8:25 UTC (Thu) by k3ninho (subscriber, #50375) [Link]

>Not that I know much about Go
Read the "Featherweight Go" journal article [1] and its parent, "Featherweight Java"[2]. I think Rob Pike looked and though Featherweight Java more relevant because of the user-facing side of Go is more like the C++/C#/Java kind of object orientation than the approach taken by Ada. You should be heartened that both Featherweight approaches prove (rather than merely providing) type safety.

K3n.

1: https://arxiv.org/pdf/2005.11710.pdf
2: https://dl.acm.org/doi/10.1145/503502.503505


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds