top | item 14951116

Ferret – A free software Clojure implementation

266 points| greydius | 8 years ago |ferret-lang.org

79 comments

order
[+] penpapersw|8 years ago|reply
Having written Clojure full-time for the past 5 years while writing cleancoders.com has really spoiled me. Clojure's introspective nature makes for some amazingly fast productivity because you can hook up your IDE to the REPL and have a kind of super-REPL, which can really speed up development a ton if you design your system it right. I'm not sure if this project can keep that aspect because of how it compiles to C++. But if it does, then it could really be invaluable in the Clojure ecosystem.
[+] nakkaya|8 years ago|reply
Author here. If I am not mistaken (I don't do web development.) very early versions of ClojureScript repl compiled code on the JVM side then piped the output to the browser. (Maybe it still does idk) I am thinking of doing something similar using Cling[1]. Ferret can compile and pipe output to Cling and use Cling as the repl.

[1] https://root.cern.ch/cling

[+] vturner|8 years ago|reply
Curious what IDE you have set up to do the REPL driven development you mentioned? I'm just starting out in learning Clojure and am finding various options out there with vigorous proponents of each. I am wondering what someone's real-world experience is after 5 years.

It's hard sometimes to find the editors/IDEs that might suite one particularly well since the vast community is attached to a given platform.

[+] agumonkey|8 years ago|reply
There's a mooc on smalltalk on FUN. You should try it. You'll probably have a blast too.
[+] jwr|8 years ago|reply
This is very interesting. I could really use a good language on microcontrollers, especially if core.async gets ported. Most microcontroller code has a huge (and complex) event-driven state machine at its core. Rather than making all of it explicit, I'd much rather use core.async to make it look like sequential code. It would really help with reducing complexity.
[+] dantiberian|8 years ago|reply
Does anyone have any insight on the legal status of this project? It’s licensed as BSD 2 Clause, but looks to be heavily derived from Clojure which is EPL. AFAIK the EPL is copyleft and doesn’t permit relicensing without the copyright holders’ permission.
[+] nakkaya|8 years ago|reply
Author here. I am actually curious about this myself. I originally released it under GPL but then on another HN thread someone said anything compiled with it also ends up being GPL, so I switched to BSD 2 Clause. I have not copy pasted code from Clojure compiler BUT in order to keep the Ferret semantics the same as Clojure semantics algorithms are identical. [1] shows + function in Ferret and Clojure. As for data structures situation is similar, same semantics implemented in C++ instead of Java with some differences/tweaks geared towards embedded systems.

[1] https://gist.github.com/nakkaya/7050d5daf2c7034a25bb079658d8...

[+] Mikeb85|8 years ago|reply
Hard to say, would depend on whether or not they copied any code from the Closure compiler. It is possible they created their own implementation, but I wouldn't bet on it. Even if you treat it as EPL though, any output from the compiler won't be copyleft.
[+] zaszrespawned|8 years ago|reply
The favicon.ico of this site - looks exactly like half life logo.

http://ferret-lang.org/ferret-styles/favicon.ico

https://www.google.co.in/search?q=half+life+logo&oq=half+lif...

What is that all about...

[+] nakkaya|8 years ago|reply
Author here. It is the Half-Life logo. I wanted a lambda symbol for a favicon, love the game too so I settled on a open licensed logo.
[+] penpapersw|8 years ago|reply
It's the lambda symbol in a circle. Seems more like a coincidence than anything else to me.
[+] ozzmotik|8 years ago|reply
clearly they certainly respect half life a lot. maybe they don't know it exists actually. i don't know who made it because im lazy and didn't check, but I will say, there is certainly a non zero possibility of someone being alive today and never having played or heard of half life, even if only due to youth alone. but either way it is an interesting coincidence. I wonder if it's more than such.
[+] vanderZwan|8 years ago|reply
I wonder if it could also somehow lift the reactive synchronous concurrency bits from Céu[0] in a library. Céu is probably my favourite embeddded language to program in from a "thinking about concurrency" perspective. I'm not sure how one would go about it though, since Céu is imperative, and I'm not sure if that imperative aspect is fundamental to its type of concurrency or if it clashes with idiomatic Clojure.

If it would be possible you'd probably have everything I could want in one embedded language.

[0] http://www.ceu-lang.org/

[+] nakkaya|8 years ago|reply
Author here. Did not knew about Céu till now, just watched the intro video. I maintain a behaviour tree [1] library called alter-ego [2] (code needs cleanup) which already contains some of the constructs. In behaviour tree terms par/or is parallel selector and watching is a interrupter node. [3] So it can be done in Ferret on a general purpose PC using C++11 concurrency constructs, for embedded targets it will require co-operative multitasking which is on the roadmap.

[1] https://nakkaya.com/2010/06/29/alter-ego-a-reactive-ai-libra... [2] https://github.com/nakkaya/alter-ego [3] http://aigamedev.com/open/article/parallel/

[+] gleenn|8 years ago|reply
Seems like a cool project if you already know Clojure and hate the start up time, but also seems like it sidesteps one of the main benefits of Clojure which is Java interop obviously... Which Clojure has to do a fair number of handsprings to accomplish. Begs the question, why pick Clojure as the lisp to compile to C++? Why not Racket or Common Lisp etc?
[+] kazinator|8 years ago|reply
The relationship with Java is both a benefit and a disadvantage of Clojure.

> Why not Racket or Common Lisp etc?

These already have solutions in the compilation space.

Kyoto Common Lisp (KCL), a fairly old implementation tracing back to the 1980's, and its descendant GNU Common Lisp (GCL) compile to C.

Embeddable Common Lisp (ECL) also contains a Lisp to C compiler.

Of course, numerous CL implementations compile to native code without the C route.

[+] piotr-yuxuan|8 years ago|reply
Congratulations, it's both very impressive and promising :) Thank you for that fine example of literate programming :)

I'd suggest you add a way for people to financially support you so you could keep working on this project.

[+] billsix|8 years ago|reply
I've been looking for a language which provides Software-Transactional-Memory with persistent data structures which fits in 2KB RAM on a microcontroller.
[+] tomsmeding|8 years ago|reply
I doubt you'll find that quickly. You can't do much in 2kb if you don't want to mutate your data, I think. I don't know much about STM, but I'd wager that uses some extra bookkeeping memory as well. So unless your own memory requirements are really low, this won't work.
[+] davidgrenier|8 years ago|reply
Always look at the memory management story when you stumble upon something like this.
[+] mtm|8 years ago|reply
It seems well thought out:

* malloc/free (ref counting GC)

* memory pooling (no heap, stack-based for memory constrained systems)

* third party allocators

* third party GC

Details here: http://ferret-lang.org/#sec-4-2

[+] agentgt|8 years ago|reply
You could have provided a link to the memory management section or even mentioned it was ref counting. Otherwise your comment is ... it kills me to say this but pretty useless.
[+] jonathonf|8 years ago|reply
Why? What's "good" vs what's "bad"?
[+] physicsyogi|8 years ago|reply
Does this have Clojure's persistent data structures? The docs say it has immutable data structures, which isn't exactly the same thing. (Edit: added the second sentence)
[+] chrisseaton|8 years ago|reply
Those persistent data structures are implemented in Clojure aren't they? It's not a feature of the compiler I believe. So if it can run Clojure code then that code can be the persistent data structures library if you want.
[+] comex|8 years ago|reply
Viewing the site in iOS Safari, I get several pages of what appears to be random binary gunk rendered as HTML. Something wrong with compression headers?
[+] pivo|8 years ago|reply
Seems to be working fine for me on iOS. Any particular page that's broken for you?
[+] agumonkey|8 years ago|reply
Ohh embedded friendly, you're spoiling me.
[+] StreamBright|8 years ago|reply
This is amazing! I am wondering what was the motivation to implement it.
[+] didibus|8 years ago|reply
Would love to see a "Differences with Clojure" section.