News for hackers. Stuff that matters.
Re:The Claro Programming Language by davedx on Thursday February 29, 2024 @07:17AM (#39548400)
There's some really cool ideas in this, and I love how you're straight into the documentation with examples. Great job.

I raised my eyebrows at this part though where the type constraints part was being explained:

> Coming from an Object-Oriented background, you may be tempted to compare Contracts to "Interfaces", but you'll find that while they may be used to a similar effect, they are not the same thing. The intention of an "Interface" is to encode subtyping relationships between types, whereas Claro has absolutely no notion of subtyping. [1]

IME with e.g. C#, interfaces are exactly for this kind of thing? Abstract classes and classes are more used for polymorphism?

But I admit it's been a while since I worked with C# and I may be remembering this stuff wrong.

[1] https://docs.clarolang.com/generics/contracts/contracts.gene...

Re:The Claro Programming Language by neonsunset on Thursday February 29, 2024 @08:15AM (#39548859)
C# interface is kind of like Rust's trait except the default passing convention by interface is similar to Box<dyn Trait> whilst passing structs implementing interface via generic arg is identical in the form of Accept<T>(T value) where T : ISomeInterface.

Arguably, today the line is somewhat blurred because interfaces can have default member implementations (which are used to extend interfaces without making it a breaking change) but generally you are correct. An abstract class and subclasses that inherit from it signifies what the type is while the interfaces a class or struct implements signify what the type does.

Re:The Claro Programming Language by jasonsteving on Friday March 01, 2024 @07:09PM (#39568432)
This section[1] gives a much deeper dive into how I'm thinking about this.

[1] https://docs.clarolang.com/generics/contracts/dynamic_dispat...