Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Plorkyeran posted:

it looks like a pretty straightforward design that isn't very powerful but good enough for a lot of use cases. pretty much exactly what you would expect go generics to be.

yeah, exactly

Adbot
ADBOT LOVES YOU

M31
Jun 12, 2012
it feels like they implemented Canadian Aboriginal Syllabics generics natively. especially since you apparently have to specify the types every time you call a generic method.

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

M31 posted:

it feels like they implemented Canadian Aboriginal Syllabics generics natively. especially since you apparently have to specify the types every time you call a generic method.

good lord. generics without type inference is almost worse than not having generics

urea
Aug 18, 2013

NihilCredo posted:

code:
// Addable is types that support the + operator.
type Addable interface {
	type int, int8, int16, int32, int64,
		uint, uint8, uint16, uint32, uint64, uintptr,
		float32, float64, complex64, complex128,
		string
}
fukkin :lol:

tbf, from reading the proposal, this is just a compromise to allow you to use compiler-magic generic operators with generic functions. most languages that don't have operator overloading dont even try to solve this problem afaik (C#, Java, F#).

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

MononcQc posted:

look you can use the new feature if you type the the pledge of allegiance and swear on a bible at the top of the file, we just don’t think you’re trustworthy yet

love the language, but

Sapozhnik
Jan 2, 2005

Nap Ghost

Xarn posted:

Doesn't Rust do the same thing as C++ in regards to ABI? That is, it says "use C ABI and gently caress off" for places where you require stable and interoperable binary layout.

Not really, there's a spec and everything on Linux.

On Windows there is a stable MSVC ABI but the standard library ABI is not stable across compiler versions, but you shouldn't expose standard library types across module boundaries and the C++ standard library is utter loving dogshit anyway. There's also COM which is a cross-vendor ABI for a subset of C++ (and other languages, theoretically). It's an IDL for defining vtables and also a universal base interface that provides reference counting and dynamic casting services. You can use COM to interop between modules compiled with MSVC and GCC, although GCC isn't used for anything serious in Windows land so it's kind of a moot point.

Zlodo
Nov 25, 2006

urea posted:

tbf, from reading the proposal, this is just a compromise to allow you to use compiler-magic generic operators with generic functions. most languages that don't have operator overloading dont even try to solve this problem afaik (C#, Java, F#).

they got help from one of the haskell guy to design this lol

feedmegin
Jul 30, 2008

Xarn posted:

Doesn't Rust do the same thing as C++ in regards to ABI? That is, it says "use C ABI and gently caress off" for places where you require stable and interoperable binary layout.

I mean, the actual C++ standard doesn't say anything about ABI, but everyone outside Microsoft uses this, suitably modified for different architectures, and has done for about 20 years now. You'll note Qt maintains binary compatibility within major versions quite happily, for example.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

The only good ABI stories are:

- C
- Swift
- CSV

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

sapozhnik’s right on here, but to be clear, the point is that c++ does have a stable and interoperable abi. it‘s much easier to make a stable interface by making it c-style, but it’s certainly possible to do it in c++, because the c++ abi is stable. so rust does not do things the c++ way, it does its own thing

gcc does not implement the msvc c++ abi, so if you’re using gcc for c++ on windows (e.g. in mingw) and want to interoperate with an msvc-compiled c++ library you do need to go through an extern c interface. or you can use clang, which will use the msvc c++ abi when asked

c++ having a stable abi was a recent major controversy on the committee

Plank Walker
Aug 11, 2005

Zlodo posted:

they got help from one of the haskell guy to design this lol

yeah, eddie

Soricidus
Oct 21, 2010
freedom-hating statist shill

Phobeste posted:

good lord. generics without type inference is almost worse than not having generics

the proposal has type inference tho? you only specify types if they’re not visible in the parameters.

go bad but let’s not make things up

Notorious b.s.d.
Jan 25, 2003

by Reene
COM and CORBA were good and cool and my friends

Sapozhnik
Jan 2, 2005

Nap Ghost
Com is still around, to the extent that win32 desktop applications are still around. There is even a new and shiny version of com for winrt, which I'm sure people will start using any day now.

Notorious b.s.d.
Jan 25, 2003

by Reene
COM never caught on outside windows

to the extent that com/dcom ever existed on unix it was a way for busted-rear end windows applications to call into unix without having to use the native rpc protocols

CORBA had real multi-platform support but i think that poo poo is all bitrotten now :\

Sapozhnik
Jan 2, 2005

Nap Ghost
Corba and dcom are another mess altogether. RPC to a particular instance of a stateful object on a particular server somewhere is the single worst idea to come out of the computing industry in the 90s.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
In theory C++ has a stable API on some systems but in practice on windows you can't mix and match versions of msvcrt or stuff will fall down and break you. If a third party hands you a DLL it needs to be on the same msvcrt as you.

gcc/libstdc++ has been stable for a while but until about ten years ago it had no promise to be

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

How in the world did CORBA get greenlit when COBRA is right there?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Sapozhnik posted:

Corba and dcom are another mess altogether. RPC to a particular instance of a stateful object on a particular server somewhere is the single worst idea to come out of the computing industry in the 90s.

It's bad but I don't think modern microservices are any better

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

taqueso posted:

How in the world did CORBA get greenlit when COBRA is right there?

corba was a weapon of those who wear suits at weekends; the coolest they'd ever get close to was printing out system diagrams indistinguishable from doom maps

Sapozhnik
Jan 2, 2005

Nap Ghost
Microservices are absolutely less bad than distributed objects. Microservices are a solution in search of a problem but they are at least tractable in theory.

Distributed objects are an idea shat out in complete ignorance of the most fundamental properties of distributed systems. It is insane by modern standards, but it probably makes sense by the base and animalistic social norms of the day, back when each network service would reside on a single custom-built server and if you needed to serve more users then you would simply order a bigger server.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
ok yeah sure but explain why smb windows filesharing works more often than my google drive app

Notorious b.s.d.
Jan 25, 2003

by Reene

Sapozhnik posted:

Distributed objects are an idea shat out in complete ignorance of the most fundamental properties of distributed systems. It is insane by modern standards, but it probably makes sense by the base and animalistic social norms of the day, back when each network service would reside on a single custom-built server and if you needed to serve more users then you would simply order a bigger server.

distributed objects and refcounting are indeed bananas but you have to consider the context, and also, how these things are actually used

the context was the land of sun rpc and mach rpc, where the rpc protocol was massively underspecified and every application using the protocols had its own little hand-rolled way of discovering the interface and documenting the correct call pattern

dcom and corba made it possible to specify detailed interfaces on how to interoperate with APIs presented over the network, taking the guesswork out of it and making it possible to generate stub clients very rapidly. (i suspect all the object-oriented nonsense was buzzword compliance)

one way that real-life dcom or corba applications sometimes worked was that you created one "object" (for your session) and your interactions with the api were on this object and that was that

it didn't have to be hell-world

Soricidus
Oct 21, 2010
freedom-hating statist shill

Suspicious Dish posted:

ok yeah sure but explain why smb windows filesharing works more often than my google drive app

yeah smb has always been awesome, particularly for use cases like “I’m the nsa and I want to access that computer”

Sapozhnik
Jan 2, 2005

Nap Ghost
It is kind of neat how SMB workgroups in Windows 95 had a distributed consensus algorithm for service discovery approximately 15 years before it was cool

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer

urea posted:

tbf, from reading the proposal, this is just a compromise to allow you to use compiler-magic generic operators with generic functions. most languages that don't have operator overloading dont even try to solve this problem afaik (C#, Java, F#).

f# does some compile time generic resolution for operators and other inline-ables: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/generics/statically-resolved-type-parameters is that solving the same thing or am i misunderstanding this?

suffix
Jul 27, 2013

Wheeee!

lol well it's better than the previous suggestion where you wrote a little interpretive dance of what you wish your type looked like

Cybernetic Vermin
Apr 18, 2005

tbqh i could go along with very limited generics, in that 90% of the usecase for generics is to make collections and collections-adjacent code typesafe. what is really dumb about the proposal operates in a duck typing kind of way, where you'd generalize over "addable", i.e. over having an operator named '+', as if there is such a thing as code which ever should generalize over integers, floats and strings.

Cybernetic Vermin fucked around with this message at 19:17 on Jun 19, 2020

animist
Aug 28, 2018

Cybernetic Vermin posted:

tbqh i could go along with very limited generics, in that 90% of the usecase for generics is to make collections and collections-adjacent code typesafe. what is really dumb about the proposal is doing things like generalizing over "addable", i.e. over having an operator named '+', as if there is such a thing as code which ever should generalize over integers, floats and strings.

i mean haskell has the Monoid typeclass which is pretty much just Addable with some extra semantics around having associativity and an identity element. haskell is pretty silly though so your point stands

Cybernetic Vermin
Apr 18, 2005

animist posted:

i mean haskell has the Monoid typeclass which is pretty much just Addable with some extra semantics around having associativity and an identity element. haskell is pretty silly though so your point stands

if they went all-in on abstract algebra they'd be in famous company yeah, but that is a moment where i think go's "the programmer is not expected to be very clever" principle actually starts being mostly appropriate. but that's not what they're doing, and their tradeoff is worse.

also, of course, haskell does not claim ieee-754 has associative addition.

Cybernetic Vermin fucked around with this message at 19:27 on Jun 19, 2020

animist
Aug 28, 2018

Cybernetic Vermin posted:

if they went all-in on abstract algebra they'd be in famous company yeah, but that is a moment where i think go's "the programmer is not expected to be very clever" principle actually starts being mostly appropriate. but that's not what they're doing, and their tradeoff is worse.

also, of course, haskell does not claim ieee-754 has associative addition.

yeah true.

honestly i've never seen much point in haskell's super-abstract type classes. they make sense in, like, Coq or Lean, where abstraction makes it easier to write proofs, but outside of actual formal mathematics i don't see much use. esp given that programmers aren't trained in abstract algebra / category theory, so you end up with a bazillion "monads are like bananas" blog posts that just confuse everything further

animist fucked around with this message at 19:47 on Jun 19, 2020

Athas
Aug 6, 2007

fuck that joker

Cybernetic Vermin posted:

also, of course, haskell does not claim ieee-754 has associative addition.

Haskell's numeric hierarchy is awful and its treatment of floating point numbers indefensible[*]. Like, Haskell will round floating-point infinity to integers without problem (it's 340282366920938463463374607431768211456 if you ever wanted to know). And NaN is
-269653970229347386159395778618353710042696546841345985910145121736599013708251444699062715983611304031680170819807090036488184653221624933739271145959211186566651840137298227914453329401869141179179624428127508653257226023513694322210869665811240855745025766026879447359920868907719574457253034494436336205824. Useful, that. I have no idea why the Haskell designers decided to return garbage results instead of throwing an exception (there's other partial functions in the Prelude after all), but I suspect they just never did any numerical computing.

[*]: not literally, it's fine if you never care about edge cases.

PS: lawful algebra-inspired type classes are cool and good, and it is cool and good that (modern) Haskell puts so much emphasis on them, even if that brings the horror of having to learn new words and concepts.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Destroyenator posted:

f# does some compile time generic resolution for operators and other inline-ables: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/generics/statically-resolved-type-parameters is that solving the same thing or am i misunderstanding this?

yep. invoking arbitrary methods on generic types has a pretty ugly syntax, but the #1 use case for the feature is generalisation over numeric operators in which case you just need the `inline` keyword and the operator constraints will be inferred by the f# compiler.

worth noting that it's all compile-time resolution that gets inlined at runtime, because the .net runtime doesn't actually support it. so in c# you have to write out the overloads for every primitive numeric type

and no, that isn't an excuse for golang in the slightest because .net generics are FIFTEEN YEARS OLD and they still support about four fifths of the features that the golang draft explicitly refuses to provide

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Cybernetic Vermin posted:

as if there is such a thing as code which ever should generalize over integers, floats and strings.

I dunno, code that’s generalized over ordering of things seems pretty useful.

Cybernetic Vermin
Apr 18, 2005

Subjunctive posted:

I dunno, code that’s generalized over ordering of things seems pretty useful.

right, but that is the exhaustive list, as opposed to the broader class of things which have a total order. those three have nothing useful in common which is not shared by a lot of other stuff. to be clear: the issue is that '+' on those do very different things in a way which makes code for one very unlikely to do something useful for both others.

if the go people had just gone "there are precisely two type classes: 1) the class of things which are hashable and can be checked for equality; and; 2) the totally ordered things. here are all our basic collections defined in a type-safe way in terms of only those two" it would at least have fit their approach of providing a bare minimum as they don't expect programmers to be able to handle anything more.

Xarn
Jun 26, 2015

rjmccall posted:

c++ having a stable abi was a recent major controversy on the committee

AFAIK large part of the problem is that C++ doesn't actually guarantee the ABI stability, but saying "but this breaks ABI" torpedoes proposals. At the same time, MSVC used to change its own stdlib ABI regularly, and while it currently keeps the same ABI, that is only temporary thing.

animist
Aug 28, 2018

Athas posted:

PS: lawful algebra-inspired type classes are cool and good, and it is cool and good that (modern) Haskell puts so much emphasis on them, even if that brings the horror of having to learn new words and concepts.

i like Lean where to implement a classes like that you have to actually supply proofs that the relevant properties hold. like:

code:
/-- A preorder is a reflexive, transitive relation `<=` with `a < b` defined in the obvious way. -/
class preorder (A : Type) extends has_le A, has_lt A :=
   (le_refl : forall a : A,
       a <= a)
   (le_trans : forall a b c : A,
       (a <= b) -> (b <= c) -> (a <= c))
   (`<` := lambda a b,
       (a <= b) && not (b <= a))
   (lt_iff_le_not_le : forall a b : A,
       (a < b) <-> (a <= b && not (b <= a)))
so, `forall a b c : A, (a <= b) -> (b <= c) -> (a <= c)` is a function signature for the method `le_refl`. it should take a proof of `a <= b`, a proof `b <= c`, and produce a proof `a <= c`.

to implement the typeclass for your type, you have to provide a function with that signature... which is basically the same thing as proving that the property holds for your type. so you literally can't provide an incorrect implementation. pretty wild

animist fucked around with this message at 20:36 on Jun 19, 2020

Brain Candy
May 18, 2006

Cybernetic Vermin posted:

honestly i've never seen much point in haskell's super-abstract type classes. they make sense in, like, Coq or Lean, where abstraction makes it easier to write proofs, but outside of actual formal mathematics i don't see much use. esp given that programmers aren't trained in abstract algebra / category theory, so you end up with a bazillion "monads are like bananas" blog posts that just confuse everything further

i would like to express things like units of measurement types without wanting to die

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

you can't eat a monad :colbert:

Adbot
ADBOT LOVES YOU

mystes
May 31, 2006

animist posted:

yeah true.

honestly i've never seen much point in haskell's super-abstract type classes. they make sense in, like, Coq or Lean, where abstraction makes it easier to write proofs, but outside of actual formal mathematics i don't see much use. esp given that programmers aren't trained in abstract algebra / category theory, so you end up with a bazillion "monads are like bananas" blog posts that just confuse everything further
This would be more persuasive if it weren't for the fact that every other modern language ends up having to implement special syntax for multiple different things that are just special cases of monads.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply