HNHacker News
TopNewBestAskShowJobs

pufuwozu

3,196 karma · joined March 18, 2009

http://www.hackernewsers.com/users/pufuwozu.html

Brian McKenna

http://brianmckenna.org/

http://twitter.com/puffnfresh

Senior R&D Engineer at Precog.

submissionscomments
pufuwozu··on Rich Hickey: extensible data notation
In a dynamically typed language, every value is a tagged union.
pufuwozu··on Hopefully more controversial programming opinions
This is even the case after the introduction of the IO monad. Monads allow referentially transparent IO.

My purely functional programs actually do things! Amazing that my ivory tower allows me to say "Hello World".

pufuwozu··on Go is boring
You're comparing ad-hoc polymorphism with subtype polymorphism. Doing so will lead you to the expression problem:

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.

pufuwozu··on Go is boring
Pandoc:

http://johnmacfarlane.net/pandoc/

XMonad:

http://xmonad.org/

pufuwozu··on Joe Armstrong: Why OO Sucks
I started reading this comment and immediately knew you were talking about Pattern Calculus. Awesome to see someone else interested in the idea.

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:

http://bondi.it.uts.edu.au/

If you're interested in playing around, Eric Torreborre posted some of the UTS lab tutorials online and some of his solutions:

https://github.com/etorreborre/bondi-tutorial

pufuwozu··on Less is exponentially more
Hopefully we'd never rewrite Haskell - there's enough people here that know it and Haskell is extremely easy to understand.

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

pufuwozu··on Less is exponentially more
Atlassian is on that list but I know that last year we rewrote our Go code to Python after our main Go developer left.
pufuwozu··on Functional Programming in JavaScript using LiveScript and prelude.ls
You can checkout my JSConf talk at: http://brianmckenna.org/files/presentations/jsconf-roy/ - hopefully the video will be posted soon

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 :)

pufuwozu··on Functional Programming in JavaScript using LiveScript and prelude.ls
Author of Roy here. Would love to hear more about how/where you think it's too far away from JavaScript. I'm trying to avoid that feeling :)

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)

pufuwozu··on Strong functional programming
Java has a type and effect system. Methods return type * effect - this causes problems, a big one in Java is that effects can't be polymorphic.

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/...

pufuwozu··on False Cognates and Syntax: The Importance of Syntax in Programming Languages
Statements only make sense when you have side-effects. Having an "if statement" in Haskell wouldn't make much sense.
pufuwozu··on Why is Haskell used so little in the industry?
I know quite a few people that use Scala in place of Haskell just because it runs on the JVM.

Interoperability matters.

pufuwozu··on Why is Haskell used so little in the industry?
I write useful and novel software. I'm doing that right now in Haskell.

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.

pufuwozu··on SourceMaps in Chrome allow debug of any source language compiled to JS
SourceMap is a tool feature - no need to modify a language (except if you count making the compiler output SourceMaps).

Maybe you're thinking about how the Traceur ES6 to JavaScript compiler outputs SourceMap information?

pufuwozu··on SourceMaps in Chrome allow debug of any source language compiled to JS
In Canary 19.0.1074.0 for me
pufuwozu··on SourceMaps in Chrome allow debug of any source language compiled to JS
Successful Google Summer of Code students get paid for their projects.
pufuwozu··on Tako: a functional web framework for Node.js
my thoughts about web frameworks are actually a web framework now :) https://t.co/zLF9yXBH*

https://twitter.com/mikeal/status/174329057188642817

pufuwozu··on IcedCoffeeScript
ClojureScript (which swannodette works on). You can invent your own language features in a Lisp.
pufuwozu··on Roy: Small functional language that compiles to JavaScript
I would love to see this. But there's two problems with it:

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.

pufuwozu··on Roy: Small functional language that compiles to JavaScript
> ... I am proposing that you increase the ability for both humans and computers to reason about 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.

pufuwozu··on Roy: Small functional language that compiles to JavaScript
> With a proper type system, you can change the world.

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.

pufuwozu··on Roy: Small functional language that compiles to JavaScript
Welcome any ideas on how to make the README better. Better yet, I'll very happily accept pull requests ;)
pufuwozu··on Roy: Small functional language that compiles to JavaScript
The thing that has gotten me the most excited since then has been an initial version of type-safe node.js modules:

http://brianmckenna.org/blog/roy_node_modules

pufuwozu··on Roy: Small functional language that compiles to JavaScript
I would love to write Roy in a language with static typing (I'm definitely up for writing Roy in Roy).

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:

http://roy.brianmckenna.org/

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.

pufuwozu··on Suddenly, Hacker News is not the first result for 'Hacker News'
I fixed submitted a patch for this in the pecl_http PHP library:

https://bugs.php.net/bug.php?id=58442

pufuwozu··on Roy — small functional language that compiles to JavaScript
Monads suit the problem nicely and it's been done in quite a few languages already:

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.

pufuwozu··on Roy — small functional language that compiles to JavaScript
Roy has the same goal as CoffeeScript - create output that would be similar to how a JS dev would write it. If you use Roy but then decide you don't like it, just take the output and keep going.

I could rely on Closure for optimal performance but what I really want is optimal readability.

pufuwozu··on Roy — small functional language that compiles to JavaScript
Bug in the type system. Fixed. Roy could be cached so you might need to force a refresh.
pufuwozu··on Roy — small functional language that compiles to JavaScript
The example sucks but is very simple.

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:

http://brianmckenna.org/blog/cps_transform_js

pufuwozu··on Roy — small functional language that compiles to JavaScript
I decided against outputting like that a while ago but after seeing that example, I can't think of a great reason against it.

I'll have a go and see how well it works. Thanks!

← PreviousPage 2 of 8Next →