Live data from Hacker News

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

numbat.dev

11–20 of 122 posts

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

#12
How does Numbat infer the type/unit for operations that involve transcendental functions like the trigonometric functions and the natural logarithm? How about for exponents that are not integers (rational or irrational)?

I've seen from to time some empirical equations that result to this. Usually, it's just hand-waved away and the non-integer units are ignored or dropped when the transcendental function is evaluated. I guess the trivial answer is probably add an extra factor with a value of 1 with the reciprocal units to result to the said type 1 for dimensionless units?

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

#13
post #10

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

Can you provide examples?

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

#14
post #10

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

Can you provide examples?

https://crates.io/crates/uom trivially convertable to cpp

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

#15
post #10

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

Can you provide examples?

https://www.boost.org/doc/libs/1_82_0/doc/html/boost_units/U...

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

#17

Earlier quoted context omitted.

All are physical units. In particular in special relativity time is couples with position and you myst use cuadrivectors (t, x, y, z).

Time exists independent of location and can not be visualized in any "physical" way. The same is true for lots of other units of measure. https://phys.org/news/2012-04-physicists-abolish-fourth-dime...

Physical can be understood to mean "of or relating to matter and energy or the sciences dealing with them, especially physics." Light, temperature, and time are described by physics, so I would consider "physical" to be an accurate adjective for those units. You seem to be using a more limited definition of physical, closer to the word "spatial."

Also, btw, you might want to read the article you linked. The article is discussing a fringe idea that some scientists have. Scientists are free to explore new ideas, and they make for good click bait for science journalists. Until those ideas gain traction, they don't provide for compelling arguments, though.

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

#19
How does something like `let y: Time = 1 year` work? Does it take into consideration the idea of leap years and leap seconds, counting a single year as 365.2422 days[0]? Or does it count as 365 days?

I got curious and installed the CLI tool[1] and found that it does indeed account for leap second / leap years:

>>> let jahr: Time = 1 year

>>> let tage: Time = jahr -> days

>>> tage

    = 365.243 day    [Time]
References:

0: https://museum.seiko.co.jp/en/knowledge/story_01/

1: https://numbat.dev/doc/cli-installation.html

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

#20
post #8

So if I try to get the Falcon to do the Kessel run in two Parsecs, Numbat will raise an exception.

Because that’s too short (12 parsecs being close to the theoretical maximum without being swallowed by a black hole) or because it thinks that you confused a unit of distance and speed?
Post reply on HN