News for hackers. Stuff that matters.
Re:Show HN: Numbat – A programming language with physical di... by pif on Thursday November 16, 2023 @11:23AM (#38291498)
You don't need a new programming language for something that C++ templates with integer constants give you for free.
Re:Show HN: Numbat – A programming language with physical di... by antoineMoPa on Thursday November 16, 2023 @11:27AM (#38291566)
Can you provide examples?
Re:Show HN: Numbat – A programming language with physical di... by pif on Thursday November 16, 2023 @11:32AM (#38291635)
- you define a template class accepting 1 constant integer for each dimension you want to consider (length and/or time and/or mass and/or temperature);

- you define addition and subtraction between objects of one type returning an object of the same type;

- you define multiplication and division as returning an object of a type with the dimensions summed or subtracted;

- and you get dimensional correctness via type safety.

Re:Show HN: Numbat – A programming language with physical di... by n_plus_1_acc on Thursday November 16, 2023 @11:34AM (#38291663)
Re:Show HN: Numbat – A programming language with physical di... by n_plus_1_acc on Thursday November 16, 2023 @11:33AM (#38291646)
https://crates.io/crates/uom trivially convertable to cpp
Re:Show HN: Numbat – A programming language with physical di... by leakim on Thursday November 16, 2023 @01:15PM (#38293240)
Re:Show HN: Numbat – A programming language with physical di... by vlovich123 on Thursday November 16, 2023 @01:23PM (#38293363)
Some of us don’t want to wait until the heat death of the universe for the code to compile (not a snipe at boost as a whole - boost units is quite bad iirc). There’s also performance problems if the compiler isn’t able to see through all the templates although that’s true for many things in this space. Finally iirc it doesn’t let you define your own custom units which is a common challenge with dimensional analysis as a library.

If rust ever gets more complete const generics, then things like tiny-uom might work.

Re:Show HN: Numbat – A programming language with physical di... by adamdegas on Thursday November 16, 2023 @02:48PM (#38294465)
Came here to say this. As soon as I saw the first example on the linked web page, I immediately thought of C++. Reinventing the wheel.