3 ms·
The Broccoli Programming Language
- fogus 18y ago(fn filter ($func @lst) (:= @ret (list)) (for $e in @lst (if (call $func $e) (:= @ret (cat $e @ret)) ) ) @ret )
- fogus 18y ago(fn map ($func @lst) (if (= @lst (list)) (list) else (cat (call $func (first @lst)) (map $func (rest @lst)) ) ) )
- fogus 18y agoJust a couple examples (below) of what the code looks like. Sigils differentiate between scalars and collections (lists only at the moment). Functions can be passed by name and called either directly (in parens) or indirectly (with the call function). Written in C and Broccoli. Nothing incredibly earth-scattering, but it is my attempt to write the language that I would like to code in.
- aggieben 18y agoOk, but, still: why broccoli? At first blush it looks similar to Arc (granted, I don't know much about Arc) or any other implementation of Scheme or Common Lisp. What's special about Broccoli?
- fogus 18y agoIt is very different than arc (read: less powerful) as it is not really a functional language, has no concept of anonymous functions (although that would be easy enough to add), has no closure, has no continuations, and has no macro facility. The only thing that I have taken from arc is the naming of the defun function.
- SwellJoe 18y agoIt's interesting that you've opted to use Perl-style sigils, given the hatred many programmers experience when seeing them (pg covers it with "no swearing" in his arc guidelines). I happen to like them, particularly for interpolation in strings...and strings are so much of what we do with web applications. "There are $number posts" is much more pleasant, to me, than "There are " . number . " posts". But I might be weird, and there does seem to be an aversion to them in most recent languages that have achieved popularity.
- fogus 18y agoI too like sigils for two reasons: 1) Makes str interpolation (as you mentioned) easier on the eyes. 2) I like to see, at a glance, what a variable "is doing". In Broccoli, there are only two "doings" hold values, or holding a collection of values. 3) I know I said 2, but the real reason.... it is easier to parse. ;) -m
- blogimus 18y agoWhy Broccoli? My curiosity was piqued so I went to your site and found a bit on how to do broccoli, but no links or text jumped out at me as to why to do broccoli. Is it just a novelty, or does it scratch some itch that other languages don't address?
- fogus 18y agoThe latter. As it stands, it is no better than a 1000 different languages out there. I will readily admit that. I personally have a difficult time wrapping my head around ideas like, functional, and closures, and lambda, in the abstract, so this is my way (not there yet BTW) of really wrapping my head around these ideas.
- stcredzero 18y agoWhy Broccoli? Because Broccoli is good for you!
- carterschonwald 18y agoWhat does this language let me do that I can't do more easily / robustly in another language? To elaborate, does it allow for niftiness that I couldn't do with a solid scheme or haskell environment, or does it beat out python or perl for quick scripting in some domain?
- fogus 18y agoI can't speak for Haskell, as I know very little (read: nothing) about it. As for Scheme, it does nothing that Scheme couldn't do.
- carterschonwald 18y agoahh, so the project is moreso a bit of self pedagogy, cool!
- jbum 18y agoI too was looking for a simple "about" page. Correct me if I'm wrong, but here's my description: This is a lisp-like language whose principal purpose is to help the creator of the language thoroughly understand how programming languages (especially lisp-like programming languages) work.
- fogus 18y agoThat is about right. However, the only thing that it shares with lisp at the moment are the parens. ;)