Live data from Hacker News

Making a GTK Video Player with Haskell

lettier.github.io

21–30 of 42 posts

Re: Making a GTK Video Player with Haskell

#22
post #19

Is there any fully formed application made with Haskell out there?

llpp, depending on your definition of "fully formed". And there is/was a tiling window manager, but everyone I know who used it at some point migrated away because the configuration was Haskell as well.

llpp is (mostly) written in OCaml.

Re: Making a GTK Video Player with Haskell

#23
post #14

Is there any fully formed application made with Haskell out there?

The examples mentioned in the other posts confirm my impression that Haskell is a good language for text processing and server applications but a pain for writing rich desktop applications. One of the things I miss in Haskell is a way to compile to C, and a convenient declarative GUI which also compiles to C so that all code can be linked together, and distributed as a single binary. The GUI doesn't need to be native…

Red uses DSL's to make it pretty easy. It's a REBOL-like language that's easy to parse and macro kind of like LISP. Here's an early demo of how that looks with examples:

http://www.red-lang.org/2016/03/060-red-gui-system.html

I don't know Haskell but I know Galois does DSL's like Ivory language with it. So, I imagine doing something like Red's GUI in Haskell would be worth exploring. Alternatively, building such a clean abstraction on top of a cross-platform library with messy stuff generated automatically from DSL version.

Re: Making a GTK Video Player with Haskell

#24
post #14

Is there any fully formed application made with Haskell out there?

The examples mentioned in the other posts confirm my impression that Haskell is a good language for text processing and server applications but a pain for writing rich desktop applications. One of the things I miss in Haskell is a way to compile to C, and a convenient declarative GUI which also compiles to C so that all code can be linked together, and distributed as a single binary. The GUI doesn't need to be native…

I'm currently playing with Reflex, a wonderful functional reactive programming library that lets you compile the same code into into webapps with GHCJS (a JavaScript backend for GHC) or into standalone desktop apps (using WebKitGTK).

It's wonderfully expressive and doesn't feel like you're painfully imitating C++ in Haskell. On the contrary, it's very idiomatic.

https://github.com/reflex-frp/reflex

However, FRP is ... unusual, and takes a bit of time to get the hang of.

Here's a stripped-down todo app "tutorial" in Reflex:

https://gist.github.com/mrkgnao/1a5c06cc1e188f2238c8c11cb74e...

And this is a full-featured TodoMVC in Reflex:

https://github.com/reflex-frp/reflex-todomvc

--

FLTK is a GUI toolkit that has Haskell bindings. It's a very C++-like API, but the library is in heavy development.

https://github.com/deech/fltkhs

The developer is also quite friendly, and I believe there are good docs. Here are a few demos:

https://github.com/deech/fltkhs-demos

Also, GHC does have a C backend, afaik, although it's deprecated nowadays and only available if you build it yourself in "unregisterised mode", which people do when porting GHC to a new architecture.

Re: Making a GTK Video Player with Haskell

#25
post #14

Is there any fully formed application made with Haskell out there?

The examples mentioned in the other posts confirm my impression that Haskell is a good language for text processing and server applications but a pain for writing rich desktop applications. One of the things I miss in Haskell is a way to compile to C, and a convenient declarative GUI which also compiles to C so that all code can be linked together, and distributed as a single binary. The GUI doesn't need to be native…

To be fair. Good desktop applications pretty much require teams and are more about user acceptance than metrics you can capture in the type system. Or tests.

Re: Making a GTK Video Player with Haskell

#26
post #14

Is there any fully formed application made with Haskell out there?

The examples mentioned in the other posts confirm my impression that Haskell is a good language for text processing and server applications but a pain for writing rich desktop applications. One of the things I miss in Haskell is a way to compile to C, and a convenient declarative GUI which also compiles to C so that all code can be linked together, and distributed as a single binary. The GUI doesn't need to be native…

Most rich desktop APIs are very imperative and the Haskell bindings are often just a thin veneer on top. For an example of a really nice Haskell UI API, see threepenny-gui:

https://github.com/HeinrichApfelmus/threepenny-gui/blob/mast...

Re: Making a GTK Video Player with Haskell

#27
post #13

Very nice project keep going, would love to see more haskell projects arising from this. Code related: I'm by no means an haskell expert, but your main function in Main.hs looks a bit lengthy, usually i dont see haskell methods with 50+ lines, might be better to split them up and provide names for subfunctions.

The main function would read pretty much the same in any language. Slicing it into multiple functions doesn't really do anything that couldn't be achieved by adding a few comments. I guess Haskell just doesn't do much to solve the problem of setting up GUIs, at least when it has to interface with a framework like Gtk+.

The GTK bindings it uses are pretty low level overall -- e.g. dealing with ManagedPtr's and whatnot. You could probably make it nicer and easier to read, at least, if you spent some time wrapping a few of those UI bindings with a couple data types and helpers, made it a little nicer, etc.

Overall there's going to be some unavoidable "setup gunk" though. You could make some of the code nicer, but the application is pretty small. For such a small little thing, I think abstracting away any further might end up in too much fluff, anyway.

Re: Making a GTK Video Player with Haskell

#28
post #13

Very nice project keep going, would love to see more haskell projects arising from this. Code related: I'm by no means an haskell expert, but your main function in Main.hs looks a bit lengthy, usually i dont see haskell methods with 50+ lines, might be better to split them up and provide names for subfunctions.

The main function would read pretty much the same in any language. Slicing it into multiple functions doesn't really do anything that couldn't be achieved by adding a few comments. I guess Haskell just doesn't do much to solve the problem of setting up GUIs, at least when it has to interface with a framework like Gtk+.

If you have good function names, you do not need comment.

Re: Making a GTK Video Player with Haskell

#29
post #28
post #13

Earlier quoted context omitted.

The main function would read pretty much the same in any language. Slicing it into multiple functions doesn't really do anything that couldn't be achieved by adding a few comments. I guess Haskell just doesn't do much to solve the problem of setting up GUIs, at least when it has to interface with a framework like Gtk+.

If you have good function names, you do not need comment.

If your imperative code is readable and well-commented, why break it up into single-use functions?

Re: Making a GTK Video Player with Haskell

#30
post #19

Is there any fully formed application made with Haskell out there?

llpp, depending on your definition of "fully formed". And there is/was a tiling window manager, but everyone I know who used it at some point migrated away because the configuration was Haskell as well.

still using it. only tiling wm I've found that plays well with desktop environments.
Post reply on HN