Re: [Haskell-cafe] Embedded scripting Language for haskell app

On Tue, Aug 17, 2010 at 7:07 PM, Christopher Done
Sadly this is true. I went ahead and tested this to confirm; compiled mueval (which uses hint), copied the executable to a virtual machine and it required the GHC package repo among other GHC-related libraries.
The size is indeed a problem. But how much? How does this compare to Lua et al?
IIRC, the Haskell Platform installer for Windows has around 70 MiB. So, if you want a simple installer to include in your installer, be prepared to have another 70 MiB. I said a dozen mebibytes (12 MiB) because I think the bare minimum needs to have at least this size to have something useful for an app, but this isn't backed up by anything. Lua, on the other hand, is embedded in the executable and weights less than 200 KiB, probably much less than a typical Haskell executable. I don't know about other interpreters. I just did a quick look at some executables I had in hand (compiled by GHC 6.12.3) and the smallest one weights at 2.3 MiB. Hmmm, let me see something: $ du -hs /usr/lib/ghc-6.12.3/ 588M /usr/lib/ghc-6.12.3/ Wow! That was unexpected. =) $ du -sm /usr/lib/ghc-6.12.3/* | sort -n | tail -n 5 23 /usr/lib/ghc-6.12.3/template-haskell-2.4.0.1 24 /usr/lib/ghc-6.12.3/ghc 77 /usr/lib/ghc-6.12.3/Cabal-1.8.0.6 78 /usr/lib/ghc-6.12.3/base-4.2.0.2 265 /usr/lib/ghc-6.12.3/ghc-6.12.3 $ du -sm /usr/lib/ghc-6.12.3/ghc-6.12.3/* | sort -n | tail -n 5 1 /usr/lib/ghc-6.12.3/ghc-6.12.3/ZipDataflow.p_hi 30 /usr/lib/ghc-6.12.3/ghc-6.12.3/libHSghc-6.12.3-ghc6.12.3.so 43 /usr/lib/ghc-6.12.3/ghc-6.12.3/HSghc-6.12.3.o 56 /usr/lib/ghc-6.12.3/ghc-6.12.3/libHSghc-6.12.3.a 111 /usr/lib/ghc-6.12.3/ghc-6.12.3/libHSghc-6.12.3_p.a Ah, so this one file alone takes 111 MiB =). But 30 MiB of libHSghc.so probably will need to be included. $ xz -9 < /usr/lib/ghc-6.12.3/ghc-6.12.3/libHSghc-6.12.3-ghc6.12.3.so | wc -c 4507512 So using one of the best generic compression algorithms available, the size of one of the biggest libraries that a program using hint may need comes down to 4.5 MiB. Probably if someone is careful enough to include only what really is necessary, the program installer will be at most 10 MiB and will need at most 50 MiB on disk. I think this is doable, but a lot more than Lua; hint can't be used on set-top boxes =).
Sandboxing and import whitelisting with hint is also a no-brainer -- see mueval and http://tryhaskell.org/. I also implement import filtering here with haskell-src-exts: http://github.com/chrisdone/haskell-json/blob/master/haskell-json.hs#L137 So import whitelisting is trivial.
Sweet, I had forgotten about mueval. And wouldn't it be nice if we could hand haskell-src-exts's parse tree directly into GHC? Cheers! =) -- Felipe.

thanks to all for the responses. I tried hint and hslua and haskell and both are very nice. My sincere thanks and kudos to the developers and maintainers of the packages (and to Bulat for the tutorial on hslua). FWIW, a couple of observations: 1. haskell indeed makes a great scripting language (as expected) 2. hint is fast* , for the examples that I ran on. (I had this 'superstition' that haskell , when interpreted, is kinda slow). I was about to toss a coin to decide which one to pickup. Perhaps I should worry about the size. Thanks Hemanth

On Tue, Aug 17, 2010 at 9:12 PM, Hemanth Kapila
I was about to toss a coin to decide which one to pickup. Perhaps I should worry about the size.
You should think about what kind of code you want to support in your scripts. I mean, if you start binding every Haskell library into Lua, maybe it would be better to have used hint =). Cheers! -- Felipe.

On 18 August 2010 01:41, Felipe Lessa
On Tue, Aug 17, 2010 at 7:07 PM, Christopher Done
wrote: Sadly this is true. I went ahead and tested this to confirm; compiled mueval (which uses hint), copied the executable to a virtual machine and it required the GHC package repo among other GHC-related libraries.
The size is indeed a problem. But how much? How does this compare to Lua et al?
IIRC, the Haskell Platform installer for Windows has around 70 MiB. So, if you want a simple installer to include in your installer, be prepared to have another 70 MiB. I said a dozen mebibytes (12 MiB) because I think the bare minimum needs to have at least this size to have something useful for an app, but this isn't backed up by anything.
I mean, not using the Haskell Platform. I think if you're an experienced developer you'd package just the things your project needs, instead of using the whole Haskell Platform. I don't think the Haskell Platform is the bare minimum.
Lua, on the other hand, is embedded in the executable and weights less than 200 KiB, probably much less than a typical Haskell executable. I don't know about other interpreters.
True, that's pretty small.
$ du -hs /usr/lib/ghc-6.12.3/ [..] So using one of the best generic compression algorithms available, the size of one of the biggest libraries that a program using hint may need comes down to 4.5 MiB. Probably if someone is careful enough to include only what really is necessary, the program installer will be at most 10 MiB and will need at most 50 MiB on disk. I think this is doable, but a lot more than Lua; hint can't be used on set-top boxes =).
That's pretty good! Encouraging if I write an end-user desktop application and want to embed Haskell as a scripting language.
participants (3)
-
Christopher Done
-
Felipe Lessa
-
Hemanth Kapila