Hacker News new | past | comments | ask | show | jobs | submit login
The Broccoli Programming Language (earthvssoup.com)
6 points by fogus on May 29, 2008 | hide | past | favorite | 15 comments



Why 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?


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


Why Broccoli? Because Broccoli is good for you!


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


It'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.


I 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


Ok, 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?


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


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


That is about right. However, the only thing that it shares with lisp at the moment are the parens. ;)


What 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?


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


ahh, so the project is moreso a bit of self pedagogy, cool!


  (fn map ($func @lst)
      (if (= @lst (list))
          (list)
       else
          (cat 	(call $func (first @lst)) 
                (map $func (rest @lst))
          )
      )
  )


  (fn filter ($func @lst)
      (:= @ret (list))

      (for $e in @lst
           (if (call $func $e)
               (:= @ret (cat $e @ret))
           ) 
      )

      @ret
  )




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: