News for hackers. Stuff that matters.
Re:Rust-style resource management in OCaml by mratsim on Friday March 16, 2018 @06:10AM (#16599661)
I think Nim or Ada would fit your needs:

- very strongly typed, you can even make sure you don't add Miles and Meters together, and that Meters * Meters give you square-meters

- destructors

Re:Rust-style resource management in OCaml by thesz on Friday March 16, 2018 @06:18AM (#16599685)
They are not all that well typed. You can't have constrained types, for example (available with type classes in Haskell).

I spent long time with VHDL, which is Ada with third leg. It is not nice language to work with.

Re:Rust-style resource management in OCaml by pjmlp on Friday March 16, 2018 @08:24AM (#16600117)
I also spend some time with stored procedure programming, mostly PL/SQL, most of them are also Ada based, and I find them quite productive, actually.
Re:Rust-style resource management in OCaml by mratsim on Friday March 16, 2018 @08:19AM (#16600093)
When you say constrained types do you mean generics? You have generics and concepts (similar to C++17) in Nim, not too sure about Ada.
Re:Rust-style resource management in OCaml by thesz on Sunday March 18, 2018 @10:39AM (#16612108)
I meant types with constraints, like this one: sum :: Num a => [a] -> a The type variable a is constrained to have implementation of interface Num (integer constant (0), addition, subtraction, etc).

These constraints can be much deeper. For example, I can define a function that allow me to add two somethings if their "regions" (a property I know how to compute) is equal and the result will be produced in "region" of first argument: add :: (Region a ~ Region b, Region a ~ Region c) => a -> b -> c

One use of something similar is addition of integer values represented by bit vectors in Verilog - you should not add bit vectors from different clock domains, otherwise you get unpredictable results.

Re:Rust-style resource management in OCaml by catnaroek on Friday March 16, 2018 @07:42AM (#16599965)
Algebraic data types and ML-style modules are non-negotiable.
Re:Rust-style resource management in OCaml by pjmlp on Friday March 16, 2018 @08:20AM (#16600100)
In Ada, you can get similar concepts via tagged records and generic packages.
Re:Rust-style resource management in OCaml by catnaroek on Friday March 16, 2018 @08:28AM (#16600152)
Tagged records are one possible in-memory representation of sum values, perhaps the most sensible one. But I don't want in-memory representations of sum values. I want sum values themselves.

ML modules are much more than generic packages. ML's module system allows you to take an existing module, hide some of its components, make some of its concrete types abstract, and get a new module. My methodology of enforcing only one invariant in each module is impracticable without ML modules.