On Tue, May 7, 2013 at 10:57 AM, Daniel Fussell <[email protected]> wrote:
> [1.1*] I didn't know haskell could compile to multiple output forms; it > does make learning haskell a more appealing idea. Isn't python able to > do the same thing? I'd heard rumor that such was the case, but I'm so > busy maintaining someone else's perl I haven't had a chance to learn python. I'm not sure if you read the other thread about Monads, but I tried to introduce the way that Haskell allows you to (sort of) reprogram the "do" syntax of the language using a mapping of the operational semantics of your domain-specific language into Monadic form. Well, the encoding of the semantics into Monadic form defines the behavior at a high level, but admits multiple implementations of that monadic interface. Most Monadic code in Haskell directly executes the desired behavior, but you can instead create what's known as a 'Free Monad', which is another term borrowed from category theory, but the gist of it is that encodes your Monadic action as pure, uninterpreted data. You can then run that data through analysis, pass it to an interpreter, or compile it to some other kind of code. Whether you implement your DSL with directly-executing code or with a Free Monad, the surface syntax for the user of the DSL is the same, and it blends in seamlessly with the rest of Haskell. There have been a couple of people who have used these kinds of techniques to generate fast LLVM code or code for an embedded device from Haskell; the LLVM one even links the resulting code into the running binary before executing it. Python has a number of different implementations now, PyPy probably being the most interesting one in terms of compilation technology. It implements a python JIT compiler in python, and with the basic python-implemented language runtime they've also built several other languages. I am not familiar enough with it to know whether you end up with the same sort of seamless integration that you can get with Haskell, but it's probably a more approachable environment if you're not ready to immerse yourself in Haskell and absorb a lot of potentially unfamiliar terminology and programming patterns. I've been a fan of Python for a long time, primarily because it's got a fairly regular and well-documented programmer interface. I can jump in to Python, find the way to do something, and then put it aside for a while without feeling completely lost every time I pick it up again. I have a problem with Perl in that it's got a lot more implicit syntax and opaque symbols that you have to remember in order to be productive, which can be a plus if you're using it regularly, but work against me when I only pick it up occasionally. Haskell has a similar problem with a tendency towards opaque symbols in the syntax, but its static type system and great online library index/search tools (Hayoo and Hoogle) make it a bit easier to refresh my memory; plus I'm just more interested in Haskell than Perl. /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
