3,196 karma · joined March 18, 2009
Brian McKenna
http://brianmckenna.org/
http://twitter.com/puffnfresh
Senior R&D Engineer at Precog.
My purely functional programs actually do things! Amazing that my ivory tower allows me to say "Hello World".
http://en.wikipedia.org/wiki/Expression_problem
Anyway, there's been quite a few proposals to add extensible records to Haskell, which would allow row polymorphism, similar to what you just showed in OCaml:
http://hackage.haskell.org/trac/ghc/wiki/ExtensibleRecords
Too bad that it has gone nowhere in a long time.
I live a couple of blocks over from UTS and went to a programming language event there. I only found out about pattern calculus after talking to Barry Jay. Turns out UTS students have been working on an implementation, called Bondi:
If you're interested in playing around, Eric Torreborre posted some of the UTS lab tutorials online and some of his solutions:
The team rewrote from Go to Python for various reasons:
* Tool support (debugging, etc) was supposedly poor
* The standard library wrappers were supposedly buggy
* They had to write a lot of wrappers and libraries themselves
* People on the team were already familiar with Python - after Atlassian's single "Go developer" left, there wasn't much reason to keep it
I wrote an article about it for IEEE's Internet Computing magazine: http://brianmckenna.org/blog/roy_ieee
I've also started writing an introduction but it has been shelved while I work on making the typesystem sound.
Hopefully I'll see you at SpainJS if you make it :)
brian@brianmckenna.org
(also, I'm writing an untyped typeclassopedia for use in my compiler - I'll be releasing it soon - definitely feel that'd be a complement to prelude.ls)
Anyway, I wouldn't like to see an effect system in Haskell (though, seems like Scala is getting one). We already express IO and State as a type. How about we express exceptions as types? Easy:
http://hackage.haskell.org/packages/archive/mtl/1.1.0.2/doc/...
Interoperability matters.
It's also deployed to Heroku. You wouldn't know it's written in Haskell if I didn't tell you.
Saying that X (CoffeeScript) proponents make more useful/novel software than Y (Haskell) proponents is pretty crazy.
Maybe you're thinking about how the Traceur ES6 to JavaScript compiler outputs SourceMap information?
1. Bytecode formats are never completely language independent - there's always a feature or change that would make language X better
2. Browser vendors will never be able to agree on a bytecode format
So, to solve those problems, I've been thinking the following approach might work:
1. Write a JavaScript interpeter for a fairly language-independent bytecode
2. Write some small languages, targeting that bytecode (something for everyone: Haskell-like, C-like, Lisp-like, Forth-like, etc)
3. Hope people start writing more languages to target the bytecode
4. Hope that it's hard for browser vendors to ignore implementing the bytecode natively - for performance reasons
This way we avoid committees and just get it done. Let me know if you think this is a good or bad idea. I'm very willing to work on it.
Ah :)
On my TODO list is to create an intermediate representation to more easily reason about Roy's semantics:
https://github.com/pufuwozu/roy/issues/41
I think this would satisfy your objections: hopefully the core semantics are so small that writing a JavaScript version from them wouldn't be so scary.
I should try that as soon as possible. Simon Peyton-Jones has said multiple times that defining a core intermediate-language for Haskell was very important as it meant they wouldn't add things that didn't make complete sense. Working on Roy doesn't give such a strong sense.
My worry about separating the semantics out into an IR is that we might lose information that makes outputting readable JavaScript possible. But we'll never know until I try.
> Will you commit to implementing Roy in Roy?
Would really like to - or at least some modules:
https://github.com/pufuwozu/roy/issues/1
> Will Roy offer a subset or a superset of the type system of the metalanguage (JavaScript)?
Mostly a superset of JavaScript.
> Exhaustive case analysis and polymorphic variants?
Not yet.
> Will you be able to implement the type-checker correctly and safely in JavaScript?
With enough tests I'll have some confidence in it. I don't have enough tests. ;)
> Will your users ever be able to compile their pure Roy code into another functional language?
Probably not - at least not written by me since that's not what I designed it for. But no objections if someone does it. :)
Hopefully some core semantics will make it possible for someone to do that.
You don't have to sell me on type systems - they're exactly why I'm working on Roy.
> If you have further doubts about the viability of this approach, see http://ashimagroup.net/demo/game/ooman/tutorial/ for a rigid body motion model in an OCaml WebGL game compiled to JS.
I know that compiling languages with completely different semantics to JavaScript is possible (I even maintain http://altjs.org/). But they present two problems:
1. They output to ugly JavaScript that is hard to interop with and/or people can't reason about
2. They need a huge runtime
The resultant JavaScript you linked to was ~300K.
Roy takes a different approach and tries to stay semantically close to JavaScript when possible. This is to combat both of the above problems. I'd love to see a Roy example of that demo - I imagine the JavaScript would be a lot more readable and smaller.
But I think CoffeeScript has shown that in-browser compilation and execution is very useful. For example, if I wrote Roy in Haskell, I wouldn't have been able to easily write this demo site:
It means you can play with Roy just by hitting a URL - low barrier to entry.
Another benefit is that you can include the Roy compiler in a page and use that to compile your Roy code - no pre-compilation necessary.
http://lambda-the-ultimate.org/node/4117
http://ocaml.janestreet.com/?q=node/100
http://en.wikibooks.org/wiki/F_Sharp_Programming/Async_Workf...
This is something that JavaScript desperately needs.
Macros aren't so nice for this stuff in non-homoiconic languages.
I could rely on Closure for optimal performance but what I really want is optimal readability.
I didn't add monadic sugar just to be part of the "cargo cult". I added it because I'm eventually going to use it to implement an automatic continuation-passing transform. I've done a similar thing before with ClojureScript's macros:
I'll have a go and see how well it works. Thanks!