Live data from Hacker News

Show HN: Numbat – A programming language with physical dimensions as types

numbat.dev

41–50 of 122 posts

Re: Show HN: Numbat – A programming language with physical dimensions as types

#43
post #10

You don't need a new programming language for something that C++ templates with integer constants give you for free.

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 dimensions as types

#45
Frink (https://frinklang.org/) is an older language with similar design goals.

Frink runs on the JVM and is also available on Android.

I use it as a general purpose calculator on my smartphone.

It's really nice that Numbat is written in Rust :) Will have to try it out.

Re: Show HN: Numbat – A programming language with physical dimensions as types

#46
post #5

I can't resist mentioning F# Units of Measure aka UoM :) https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...

Or unitful.jl in Julia which evaluates the units at compile time resulting in no performance loss at runtime.

Re: Show HN: Numbat – A programming language with physical dimensions as types

#48

Frink ( https://frinklang.org/ ) is an older language with similar design goals. Frink runs on the JVM and is also available on Android. I use it as a general purpose calculator on my smartphone. It's really nice that Numbat is written in Rust :) Will have to try it out.

There's also Insect for interactive use: https://insect.sh/

Re: Show HN: Numbat – A programming language with physical dimensions as types

#49
the classic problem for such number systems is linear algebra https://yosefk.com/blog/can-your-static-type-system-handle-l...

the issue is that each column and each row of a matrix can have different units. worse, gauss-jordan elimination chooses which rows to operate on dynamically. there is eventually a solution to this problem in c++ far down the comments thread

i don't see anything in https://numbat.dev/doc/type-system.html about aggregate types such as vectors, matrices, maps, arrays, lists, trees, records, etc., though it does have a suggestively named scalar type. i wonder how it handles this sort of thing

Re: Show HN: Numbat – A programming language with physical dimensions as types

#50
post #25

Or you could just use Nim [0], where this sort of thing can be implemented in Nim's macro system. Then you have a regular programming language combined with CT safe units. :) It even pretty much looks identical to those Numbat snippets! import unchained let earth_mass = 5.972168e24.kg let solar_mass = 1.9885e30.kg let lunar_mass = 7.342e22.kg let distance_sun = 1.AU # astronomical unit let distance_moon = 384_400.km…

'can be implemented' is different from 'has been implemented'

how does unchained handle gaussian elimination

Post reply on HN