Futhark by Example

(futhark-lang.org)

49 points | by tosh 3 hours ago

5 comments

  • ethanlipson 2 hours ago
    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.
    • VorpalWay 1 hour ago
      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.)
      • otabdeveloper4 51 minutes ago
        Yeah, C++ arrays are literally that.
        • alpinisme 24 minutes ago
          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.
  • Ferret7446 1 hour ago
    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.
  • guessmyname 27 minutes ago
    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.
  • fulafel 33 minutes ago
    Futhark is a glimmer of light in the wasteland of C/C++ styled low level GPU languages.
  • rowanG077 2 hours ago
    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.
    • keyle 1 hour ago
      Interesting, what do use it for if you can share?
      • rowanG077 20 minutes ago
        Optimization algorithms. The build in automatic differentiation is great!.
    • Reefersleep 1 hour ago
      What is your use case?