Hacker News new | past | comments | ask | show | jobs | submit login
Functional javascript in one page (osteele.com)
60 points by alifaziz on Feb 29, 2012 | hide | past | favorite | 6 comments



This works, but it still looks dirty, mostly due to javascript's lack of concise lambda-syntax.

If you want to use a functional language, it would seem more fitting to create an actual functional language with actual list comprehension, something javascript is ridiculously weak at, and so on.

Ofcourse that would then have to be compiled into something which runs in the browser. Another argument for web-bytecode I guess.

Edit: To not just throw hot air around, I tried doing something similar (with typing on top!) during a weekend long long ago. I wasn't happy about the result, but I left the code online.

For those curious about my take on the same problem: http://code.kjonigsen.net/js/spicejs/test.html

You'll have to view the source to see how it works, and open the web-developer console to see the output.


I haven't tried this yet, but it would seem like a good option: http://uu-computerscience.github.com/uhc-js/


"In one page" is pretty meaningless if you make the page arbitrarily long :P

That said, it's a nice reference for a nice library.


I think this is one of the inspirations for underscore.js


Seems awesome. I wonder if there is performance penalty for compiling the string partial functions though. e.g. '>2'.


They are cached, so if you use one in a recursion or iteration, you only take one hit. For maximal faux-lispiness, consider building the strings, e.g. Using CoffeeScript's string interpolation to insert literals.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: