Futhark is really such a great idea. I'm not convinced that dependent types are worth the cognitive overhead in general, but it's definitely worth it to include the length as part of the type information for dynamic arrays, e.g.:
concat(Vec<T, n>, Vec<T, m>) -> Vec<T, n+m>
matmul(Mat<T, n, m>, Mat<T, m, l>) -> Mat<T, n, l>
head(Vec<T, n+1>) -> (T, Vec<T, n>)
This would have saved me so much headache debugging CUDA kernels and numpy!! I wish it were a first-class feature in those frameworks, and even general-purpose languages, but alas.
The Pyrefly type checker is starting to work on this kind of shape hinting - so far it only works on Torch but I believe the plan is for it to work with other array packages (eg. JAX, NumPy)
You can do this with templates in C++ and generics in Rust I'm pretty sure. I think the Eigen C++ library supports this. (I have yet to do a linear algebra heavy Rust project, so I can't speak to the options that exist there.)
I'm talking about cases where the array size is not known at compile time. For example, say the user passes in a list of numbers as command line arguments. Then we have
argv: Vec<String, argc>
If I want to map these to ints, then I'd like a compile-time guarantee that the resulting array
nums: Vec<Int, argc>
is the same length as argv. Lean and Idris can do this, but AFAIK no commonly used languages can. But unlike general dependent types, these are not hard to wrap one's head around and would save a lot of frustration, in my experience.
Arrays are not dynamically sized though (handling runtime sizes) and don’t have efficient append/concat. The point of the dependent types is that you can have the type system track that concat creates an M+N length vector, sort preserves length (and adds a sorted guarantee that slice preserves), etc.
Sure you can do a lot with templates, but that’s advanced templates not just “C++ arrays” in a throwaway “literally that” way.
It would be nice to not name your language after another language. (Yes I know it's a script, that doesn't change my point). I came here expecting something else.
Yeah, when naming your language, it's important to keep mind the expectations of people seeing headlines about articles about your language on blog aggregation sites :^)
Now I'm thinking about "Smalltalk by Example" and "Slang by Example"
Same. Thought I had a copy of Uthark [1][2] on my shelf too but alas I seem to have only retained Svartkonst [3] during the tragic downsizing of my library.
Futhark is pretty great! And I have to say that the maintainer is insanely quick. It has happened on more than one occasion that I reported a bug and it's solved within the day. I have been using Futhark in prod for two years now and never had serious problems.
Couldn’t have chosen a more difficult (and ambiguous) name to pronounce, could you? It almost sounds like a curse that I often hear people say out in the bad streets of New York City.
Elder [0] and Younger [1] Futhark (or Fuþark) are the name of two runic writing systems used by Germanic and Scandinavian Vikings. The name Futhark is a combination of the first 6 runes /f/, /u/, /ð/, /ɑ/, /r/, and /k/. Similar to how you get the name "alphabet" from the first two letters of Greek's writing system.
Futhark is really such a great idea. I'm not convinced that dependent types are worth the cognitive overhead in general, but it's definitely worth it to include the length as part of the type information for dynamic arrays, e.g.:
This would have saved me so much headache debugging CUDA kernels and numpy!! I wish it were a first-class feature in those frameworks, and even general-purpose languages, but alas.Here they are in Futhark:
And here's the pathological case (length cannot be determined at compile time): Other pathological cases include conditionals and loops.The Pyrefly type checker is starting to work on this kind of shape hinting - so far it only works on Torch but I believe the plan is for it to work with other array packages (eg. JAX, NumPy)
https://pyrefly.org/en/docs/tensor-shapes/#how-it-works
Shape functions and shape analysis are basically mundane infra in almost every ML compiler/language/DSL.
https://mlir.llvm.org/docs/Dialects/ShapeDialect/
You can do this with templates in C++ and generics in Rust I'm pretty sure. I think the Eigen C++ library supports this. (I have yet to do a linear algebra heavy Rust project, so I can't speak to the options that exist there.)
I'm talking about cases where the array size is not known at compile time. For example, say the user passes in a list of numbers as command line arguments. Then we have
If I want to map these to ints, then I'd like a compile-time guarantee that the resulting array is the same length as argv. Lean and Idris can do this, but AFAIK no commonly used languages can. But unlike general dependent types, these are not hard to wrap one's head around and would save a lot of frustration, in my experience.Yeah, C++ arrays are literally that.
Arrays are not dynamically sized though (handling runtime sizes) and don’t have efficient append/concat. The point of the dependent types is that you can have the type system track that concat creates an M+N length vector, sort preserves length (and adds a sorted guarantee that slice preserves), etc. Sure you can do a lot with templates, but that’s advanced templates not just “C++ arrays” in a throwaway “literally that” way.
It would be nice to not name your language after another language. (Yes I know it's a script, that doesn't change my point). I came here expecting something else.
TIL:
https://en.wikipedia.org/wiki/Runes#Runic_alphabets
Yeah, when naming your language, it's important to keep mind the expectations of people seeing headlines about articles about your language on blog aggregation sites :^)
Now I'm thinking about "Smalltalk by Example" and "Slang by Example"
Jackson Crawford's youtube channel is very helpful academic source.
For those that don't know, Futhark is comes from the first 6 letters of the runic alphabet (F, U, Þ, A, R, K)
https://www.youtube.com/@JacksonCrawford
Same here, I was very confused for a bit.
Was expecting to see some examples of how to read runes, but I am nonetheless equally satisfied.
https://en.wikipedia.org/wiki/Elder_Futhark
Same. Thought I had a copy of Uthark [1][2] on my shelf too but alas I seem to have only retained Svartkonst [3] during the tragic downsizing of my library.
[1] https://archive.org/details/karlsson-thomas-uthark-nightside...
[2] https://www.84cxrarebooks.com/pages/books/090763/t-ketola-th...
[3] https://www.miskatonicbooks.com/product/thursakyngi-iv-svart...
Futhark is pretty great! And I have to say that the maintainer is insanely quick. It has happened on more than one occasion that I reported a bug and it's solved within the day. I have been using Futhark in prod for two years now and never had serious problems.
Interesting, what do use it for if you can share?
Optimization algorithms. The build in automatic differentiation is great!.
What is your use case?
Futhark is a glimmer of light in the wasteland of C/C++ styled low level GPU languages.
We also need to have StarLisp back, it would be quite fitting.
Couldn’t have chosen a more difficult (and ambiguous) name to pronounce, could you? It almost sounds like a curse that I often hear people say out in the bad streets of New York City.
Elder [0] and Younger [1] Futhark (or Fuþark) are the name of two runic writing systems used by Germanic and Scandinavian Vikings. The name Futhark is a combination of the first 6 runes /f/, /u/, /ð/, /ɑ/, /r/, and /k/. Similar to how you get the name "alphabet" from the first two letters of Greek's writing system.
[0]: https://en.wikipedia.org/wiki/Elder_Futhark
[1]: https://en.wikipedia.org/wiki/Younger_Futhark