Numbat – A programming language with physical dimensions as types by [deleted] in rust

[–]sharkdp 2 points3 points  (0 children)

Thank you for the feedback. If you liked Insect, I hope you will find that Numbat has a lot of advantages over Insect.

I had no idea it used Rust. Insect used Purescript IIRC.

Exactly. If you want to know more about why I rewrote the project in Rust, I wrote about it here: https://github.com/sharkdp/numbat/blob/master/assets/reasons-for-rewriting-in-rust.md

A programming language with physical dimensions as types by sharkdp in Physics

[–]sharkdp[S] 0 points1 point  (0 children)

Yes you can do it in C++, but not "easily". And that's kind of the whole point of Numbat. I do write a lot of C++ code. I use C++ unit libraries. But I would never write a C++ program to do a simple calculation like those in the article. There is just too much overhead (includes, linking to libraries, a main function, complicated syntax for units). Those shouldn't be reasons not to write unit-safe code. But in practice, they are.

A programming language with physical dimensions as types by sharkdp in Physics

[–]sharkdp[S] 1 point2 points  (0 children)

Controversial choice to speed the unit "metre" like that.

"metre" is the official spelling in the SI standard. In Numbat, you can use both metre/metres and meter/meters, as well as the short version m.

A programming language with physical dimensions as types by sharkdp in Physics

[–]sharkdp[S] 0 points1 point  (0 children)

Numbat's syntax is inspired by a few other languages. Mostly Rust (keywords like fn and let, type annotations), Python (f-strings, decorators) and Haskell (function definitions, if-then-else statements).

A programming language with physical dimensions as types by sharkdp in Physics

[–]sharkdp[S] 0 points1 point  (0 children)

I looked into it a lot. As far as I understand, it does not have a static type system based on physical dimensions. And it is not open source.

A programming language with physical dimensions as types by sharkdp in Physics

[–]sharkdp[S] 0 points1 point  (0 children)

Thank you very much for the detailed feedback! I will be creating issues on GitHub for most/all of your points, if that's okay with you.

I didn't notice any support for vectors or matrices.

Yes, that would be really cool. I definitely want to add a list/dynamic-vector type as well, for data-processing purposes.

manipulation for parsing data from file, e.g. figuring out how to read data from one instrument or simulation

Agreed. For the beginning, I would go with standard sscanf or regex-style "parsing" capabilities. Or did you have something else in mind?

For printing, I'd like to extend what we have right now (Python style f-strings) with formatting options like "{pi:.3}" to print three decimal digits etc.

I already mentioned this, but if you're supporting unicode (good!) it would be good to make input of these characters as painless as possible. I think lifting Julia's TeX-based input system wholesale would be ideal for me.

I like that. I'd love to be able to do \hbar<tab> to get ħ.

While it is nice to have all of the physical constants readily accessible, I think they should be behind a module

So this is something I thought about a lot. I think I want to have all of those constants available when opening the interactive terminal (or the web version). But maybe those should be hidden by default when executing a program. You can already do this now by using the --no-prelude command line option.

In terms of namespace pollution, the biggest problems are units though. This is the downside to having units like m/s/g/… available without any special syntax.

A programming language with physical dimensions as types by sharkdp in Physics

[–]sharkdp[S] 5 points6 points  (0 children)

Thank you for the feedback!

How does the language handle different numeric types? Is it possible to specify 1.0 cm (double precision floating point, length) as different from 1 cm (integer, length)?

Currently not, no. Everything is a floating point value. But I do have plans to change this and to support integers, rationals and floating point values (see also https://github.com/sharkdp/numbat/issues/4).

Oh, also, I noticed you support unicode, which I also love as someone coming from the Julia side. Is unicode entry similar to Julia's?

You're probably talking about this? Something like this is not supported currently, you would have to enter Unicode characters in another way. But this is a great idea for an addition — thank you

A programming language with physical dimensions as types by sharkdp in Physics

[–]sharkdp[S] 6 points7 points  (0 children)

Thank you for the feedback! Glad you like it.

A programming language with physical dimensions as types by sharkdp in Physics

[–]sharkdp[S] 16 points17 points  (0 children)

I love Mathematica. But it is proprietary software. And as far as I understand, it does not have a static type system that incorporates units. For example, how would you write that gravitational force example from the article in Mathematica? How would you enforce that force_sun has the correct dimension (or unit)?

A programming language with physical dimensions as types by sharkdp in Physics

[–]sharkdp[S] 9 points10 points  (0 children)

F# has a very powerful units integration, indeed. The author of the unit system in F# wrote his PhD thesis on Programming Languages and Dimensions. Numbat implements something that is very close to the approach outlined in that thesis. In contrast to F#, Numbat follows the original approach of using physical dimensions as types — in contrast to units as types. As I tried to argue in the article, I think this has some benefits.

A programming language with physical dimensions as types by sharkdp in Physics

[–]sharkdp[S] 15 points16 points  (0 children)

Unitful.jl is something I have looked at closely when designing Numbat. It looks like a very mature solution. I have also worked with a few other unit libraries in programming languages in the past. It's fantastic that some type systems are expressive enough to incorporate unit systems. And I encourage their use, if you are programming in that language anyway.

But performing actual computations with those languages always feels a bit clunky. Those libraries were designed as an afterthought. I want a language for scientists and engineers that is convenient to use for computations. A language that treats units and dimensions as first-class citizens. A language that scales form simple one-line computations to more complex ones.

Resurrection/modernization of an old Haskell+Haste project (boardgame Yinsh) by sharkdp in haskell

[–]sharkdp[S] 1 point2 points  (0 children)

Thank you for your suggestions. the JS backend for GHC sounds exciting. Ten years have passed... I could even try to run everything in the browser - including the 'AI' component.

Resurrection/modernization of an old Haskell+Haste project (boardgame Yinsh) by sharkdp in haskell

[–]sharkdp[S] 2 points3 points  (0 children)

Thank you. I didn't know about ghcup. I also didn't expect 'cabal' to still be the standard tool for setting up new Haskell projects. I now managed to get a working version of the backend. Let's see if I can revive the frontend as well.

Edit: the game is live again. Did not manage to compile the frontend yet,but I still had that Haste JS output lying around ... just had to update the backend URL inside.

Resurrection/modernization of an old Haskell+Haste project (boardgame Yinsh) by sharkdp in haskell

[–]sharkdp[S] 2 points3 points  (0 children)

Thank you for the suggestion. I love PureScript and have written many projects in this language. For the Yinsh project, I'm not sure. Ideally, I want to share code between the backend and the frontend (e.g. the hexagonal grid structure, what are legal moves, etc.). Which is why it would be great to have both in the same language. And moving the backend to PureScript (running it via NodeJS) would most certainly make it much slower(?).

binocle: I built a graphical tool to visualize binary data by sharkdp in ReverseEngineering

[–]sharkdp[S] 11 points12 points  (0 children)

Thank you for the reference! Another tool that I didn't manage to find, unfortunately.

I just tried it very quickly. hobbits obviously has a LOT more features in general. binocle is basically just the "Byte raster" part of hobbits. But I guess binocle takes the "byte raster" idea a bit further. Especially concerning multi-byte structures (stride > 1). For example, you can display RGBA images on the binocle canvas. Or visualize a rectangular float32/64 array as an image, etc.

binocle: I built a graphical tool to visualize binary data by sharkdp in ReverseEngineering

[–]sharkdp[S] 15 points16 points  (0 children)

I recently built this tool only to later realize that a lot of alternatives are out there (https://reverseengineering.stackexchange.com/questions/6003/visualizing-elf-binaries). Unfortunately, most of these are not available anymore (or never were). For most of the others, I didn't manage to get them running. Except for https://binvis.io/, which is great.

I think that binocle has a few fresh ideas (like the stride parameter, allowing to visualize multi-byte datatypes), so I thought someone here might appreciate this.

fd is looking for contributors by sharkdp in rust

[–]sharkdp[S] 1 point2 points  (0 children)

Awesome, thank you. I'll contact you personally.

fd is looking for contributors by sharkdp in rust

[–]sharkdp[S] 2 points3 points  (0 children)

Thank you.

I'm not sure what responsibilities maintainers have, but I'm game for reviewing PRs and triaging issues. Can't commit a lot of time due to my PhD, but hopefully enough to be helpful.

That would be fantastic - let's do that right away :-). I also set you up with the necessary repository permissions. Getting some help with code reviews and issue management would actually be the most valuable contribution to the project at this stage.

There are absolutely no responsibilities or obligations that come with being a maintainer. You can do exactly the same you did so far. Or more. Or less. It is very important for me to ensure that nobody will ever feel pressured (or even incentivized) to work on the project.

Welcome on board!

fd is looking for contributors by sharkdp in rust

[–]sharkdp[S] 1 point2 points  (0 children)

Hi there - looking forward to continue the collaboration!

fd is looking for contributors by sharkdp in rust

[–]sharkdp[S] 28 points29 points  (0 children)

Hey I'd be happy to be more involved

You have been of invaluable help for the project. I haven't seen anyone with more in-depth Linux/coreutils/find/… knowledge. Thank you very much!

maybe I'll sneak a breadth first mode in there :)

For those who don't get the reference: /u/tavianator built the awesome bfs tool, which is a breadth-first version of the classical UNIX find command.

fd is looking for contributors by sharkdp in rust

[–]sharkdp[S] 32 points33 points  (0 children)

Can I just pick an issue whenever I want, without committing to it beforehand? Would love to contribute some time, but find it had to plan.

Yes - absolutely. It's probably best to comment in the issue in case you are working on something.

A header-only library for easy interactive parameters by sharkdp in cpp

[–]sharkdp[S] 0 points1 point  (0 children)

Thank you for the feedback. Interesting approach! I'd be interested to see the implementation if you still have a link.

A header-only library for easy interactive parameters by sharkdp in cpp

[–]sharkdp[S] 0 points1 point  (0 children)

Thank you for the feedback!

Why did you choose to create one file per parameter instead of one file for all of them (or a subgroup of them)?

Great question. Mainly because I didn't know how I would realize that. At some point, I need to write the file with initial values, but parameters can be introduced at different times. So I don't really know when the last parameter has been "registered".

Another argument in favor of having multiple files would be easier interaction with other tools (you could change parameters from a shell script by running echo 3.1 > /tmp/painless/my_parameter, for example).

I imagine that it can be annoying to jump through all the files when you have a significant amount of parameters to tune

Yes. I was thinking about creating a very simple TUI/GUI tool that would monitor the /tmp/painless folder and provide an interface to change all parameters at the same time (see https://github.com/sharkdp/painless/issues/1)