Hacker News new | comments | show | ask | jobs | submit login
Functional Programming in JavaScript using LiveScript and prelude.ls (github.com)
60 points by 0x1997 1740 days ago | hide | past | web | 21 comments | favorite

I really like the coffeescript + haskell feel. I always miss haskell's '$' for function application and '.' for composition. LiveScript has both (<| and .).

Check out the "10 LiveScript one-liners to impress your friends" post. Great stuff: http://gkz.github.com/LiveScript/blog/livescript-one-liners-...

LiveScript is an interesting choice of name. JavaScript was officially called LiveScript back in Netscape Navigator 2.0 beta.

Yes, it's an inside joke for those who know JavaScript well.

This is fantastic! I love that it has currying and composing. I'm going to switch from CoffeeScript to LiveScript.

why use

    map (-> it.length > x), list
    map (call \toUpperCase), 'haha'

for functions with only one free variable?

IMHO it would be prettier to have something like scala's _

    map (_.length > x), list
    map (_.toUpperCase), 'haha'
i.e. automatically build a closure when _ is used eithout the need for additional anonymous function syntax

They discussed this, and decided: a) partially-applied operators fills some of the gap, and b) they're far too complicated to implement.

https://github.com/gkz/LiveScript/issues/19 https://github.com/taku0/placeholder_syntax_for_coffeescript...

ah, thanks, I missed partially applied operators. But then, it seems easy to do it with single method calls too, e.g.

    map (.length) x
rather than

    map (call \length) x
does not fit more complex usage, but it's a tiny improvement I'd think

This is an interesting idea - I will look into it. It does not seem to conflict with the current syntax. Thanks for the suggestion!

I'm not a big fan of scala's _ operator. I find it a poor decision from a language design perspective for

to be a function, but for

to not be a function (unless of course method returns a function)

It also doesn't nest properly

Interesting, but I strongly dislike the use of whitespace indentation for new statements/segments of code,




And I like it when Xcode highlights the brackets/parenthesis because it's just easier to pick up ( and ) and { and } from a line of text.

  If {
      Your {
          Code {
              Is {
                  That {
                      Nested {
Then you at not using the functional programming constructs available to you and have poorly decomposed code. Deep nesting is a major code smell.

have you heard of http://roy.brianmckenna.org/ ? Its basically haskell in javascript.

Yes, I am aware - it is an interesting project. However, it's a couple of steps farther away from JavaScript than I would want to work with.

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


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

Hi Brian, thanks for creating Roy, it's very cool! I've underlined LiveScript functional features in this blog post, but like JavaScript, LiveScript also supports imperative and object-oriented programming. One could port a JavaScript program to LiveScript with relative ease, as it's just syntax changes (with features added on top). I do not think that would be possible in Roy. For some people that's fine, but for my own projects I would prefer using something that maps more closely to JavaScript.

Hi Brian,

I was looking forward to see your presentation in SpainJS next month, but I might not be able to make it.

Is there any of your roy talks online or any gentle introduction to roy besides roy.brianmckenna.org?

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

I'm a JavaScript fan and I'm impressed. Still feel like a bit overwhelmed with so many new ideas though. By the way, does LiveScript (the name really makes me smile and even giggle) support source maps? see http://www.html5rocks.com/en/tutorials/developertools/source... for more info

while it's a great language, and I was a fan of coco for a while, my experience with coco was that it was like a ghost town and I was one of the only users.

Coco is amazing. To avoid becoming a "ghost town", I have made LiveScript much more compatible with CoffeeScript, easing transitions. I have invested time into making a decent website, and have now composed a couple of blog posts promoting LiveScript. Already several people have written projects in LiveScript: https://github.com/gkz/LiveScript/wiki/Projects-using-LiveSc... I hope with my continued efforts that the scenario you describe can be avoided.

I think what you did is great but a very important missing thing is syntax highlighting for ls files on GitHub. Maybe you can make a pull to their Linguist? https://github.com/github/linguist

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact