HNHacker News
TopNewBestAskShowJobs

brehaut

594 karma · joined March 4, 2009

submissionscomments
brehaut··on Thinking in Clojure for Java Programmers
To summarize your posts in this thread, if you have a representation (R) and you discover a new representation (R') where R' is provably better than R. R' however has a cost associated with converting to it, lets call it the impedance.

My reading of your posts is that you advocate ignoring any R' that has an impedance greater than zero. Surely it would be wiser to evaluate the switch to R' if the value of R' less the impedance of R' is positive?

Is this a fair representation of your position?

brehaut··on Thinking in Clojure for Java Programmers
I think using defn as an example here is a poor choice for this argument. defn is not an abbreviation of `define` or 'defun', instead it is a fusion of `def` and `fn`. fn is clojure's anonymous function form and def binds a var to a value. You can see this via macroexpand:

   user=> (macroexpand '(defn f [x] x))
   (def f (.withMeta (clojure.core/fn f ([x] x)) (.meta (var f))))
[edit: clarified an ambiguous initial statement]
brehaut··on Thinking in Clojure for Java Programmers
That holds water only at the most sugary syntactic level.

At the most simplistic semantic level a binary addition operator is a simple mapping of what the machine wants to do (take 2 registers and put their sum in an accumulator register).

Lets expand that simple piece of code. Now you have more than 2 numbers to sum:

   2 + 3 + 40
you have been forced to encode both stages of summing the first pair of numbers and then the result and the third value. Contrast this with a lisp

  (+ 2 3 40)
Lisp has takes care of all of the details for me; i merely need to supply the operands and the language worries about mapping it to the underlying operations as needed.

Clearly, here is a situation where lisp notation elevates me from having to think about the machine.

Touche, indeed.

brehaut··on Thinking in Clojure for Java Programmers
Please justify your claim: In what way is Lisp (in contrast to Python) better suited for computers than for humans?
brehaut··on Impedance mismatch with CouchDB
I've not looked into that at all. Thanks for the pointer
brehaut··on Impedance mismatch with CouchDB
That requires date information to be in the keys of all the views. Some of my views are not chronologically keyed, but i would still like them to have items that i intend to have be published in the future not accessible. I would like to avoid that sort of accidental complexity.

The other issue is that it splits the 'is this a visible fragment' logic across the db and application code boundary. I now have to ensure that all the appropriate checks are in place in two layers rather than one.

brehaut··on Ruby is beautiful (but I'm moving to Python)
clojure package management is built on top of maven typically. There are two main approaches here:

1. Use Maven as Maven with https://github.com/talios/clojure-maven-plugin - My impression is that this option is often more popular with people coming to clojure from java, as you get the full XML and maven experience.

2. Use Leiningen https://github.com/technomancy/leiningen – this is a project and dependancy management / built system built in clojure on top of Maven's libs. You have a single (and simple - no XML) project.clj file that describes your project. My impression here is that lein is popular with people coming to clojure from non-JVM land. Being a former pythonista, this is my preference.

There is also a default maven repo that i believe both work with hosted at http://clojars.org.

In both cases maven handles dependency resolution and package management. My experience is that a global install of jars is not common like it is in python or ruby land.

The other tool that you will want to look at is https://github.com/liebke/cljr which is a repl built ontop of lein's package management commands. This is useful because it lets you run a repl without a project (lein requires a project) but still gives you control over what libraries are available. If you are using incanter (the stats package mentioned by Estragon) you will want cljr

brehaut··on [dead]
Pity too, it looks like a great site.
brehaut··on Antimatter atoms produced and trapped at CERN
Everybody makes bad choices in life, the important thing is to learn from them.
brehaut··on IE removed from spoon.net
http://www.microsoft.com/downloads/en/details.aspx?FamilyId=...

You may also want to check out http://shapeshed.com/journal/testing_with_ie6_ie7_and_ie8_on... if you wish to use virtualbox rather than paying for virtual PC

brehaut··on Ask HN: Java in 5 Years?
If you go by these links, Java programmers (87k) equally well off as Cobol programmers (87k) and both are better off than Ruby programmers (84k). If you really want the dollars, ocaml is apparently where its at (149k)

http://www.indeed.com/salary?q1=cobol+programmer&l1=&... http://www.indeed.com/salary?q1=java+programmer&l1=&... http://www.indeed.com/salary?q1=ruby+programmer&l1=&... http://www.indeed.com/salary?q1=ocaml+programmer&l1=

Caveat: clearly this isn't science, and i don't know how the sites keywords work. might be way off base.

brehaut··on Clojure port of WebMachine released
Aside from just the port itself is the following quote from the project's readme:

"BankSimple's stack is also multi-lingual, using Scala, Clojure, and JRuby. It's important for our development efforts to have a plays-well-with-others project where code can be shared between languages. We think that JVM language crosstalk is going to be a major asset for us moving, and increasingly you see other companies talking about similar experiments. Maybe we're on to something. Clothesline is a way of finding out."

Obviously, some of banksimple's technical people have a history of dabbling in multi-language systems but this sort of intentional crosstalk experiment is very interesting

brehaut··on Reverse.jar
I would agree. Also, the LINQ interface is the monadic interface with Bind / >>= renamed to SelectMany and return renamed to ToIdentity. You can use these directly or with syntax sugar, so i would suggest that they have already turned up in a language.

Anecdotally, I think microsoft flubbed the introduction by overemphasizing LINQ to SQL. This leaving a lot of developers I know thinking it was a one trick pony and never learning (for instance) LINQ over IEnumerable. Those who have since taken time to learn the non-SQL LINQ features do wonder how the lived without them.

brehaut··on Reverse.jar
I think this line of reasoning is why the C# team avoided the M word and introduced Linq for a range of things (sequence comprehensions, reactive programming etc) and is introducing the async syntax for more stuff in 5, even though they could all be implemented with the same more general model.

[edit] the M word is Monad

brehaut··on Ask HN: Whats the best way to start web development on lisp?
First up, i'm using CouchDB, so my data is pretty fluid. Everything is organized as a set of 'fragments' which have a variety shapes; its duck-typed data basically. I havent looked at clojure's SQL stuff at all so i cant answer there.

Working with these fragments is real simple. Clutch deserializes the JSON from various couch views into native clojure data structures (maps, vecs, etc). From there i just use multimethods[1] to work out how to handle each fragment at various points (url generation, various aspects of the templating etc). I should note that cgrand created a great little macro for me to make working with enlive and multis easier, http://gist.github.com/432752

The hardest part about migrating the nominal schema is changing the JS for the views. Clutch does support running a clojure view server for couch which i think would actually alleviate a lot of my pain points but I wasn't on the ball when i got started. I store all my views in little JS files in the project and have some shamefully rough clojure scripts to update the views in the DB.

Migrating existing data (which i've only had to do once) is a simple case of writing a map (and or filter) function and running it over all the content and doing a bulk update with couch.

I havent had to do much migration though because i largely ported over my established python/django project.

hopefully that answers your question?

[1]: http://clojure.org/multimethods

brehaut··on Ask HN: Whats the best way to start web development on lisp?
Nah, id need mongo or dev null for that. i havent got to those yet
brehaut··on Ask HN: Whats the best way to start web development on lisp?
I recently rebuilt my site[1] in Clojure. Ring at the bottom layer (basically a given). Beyond that I'm using Moustache[2] for routing, Enlive[3] for templating and Clutch[3] to talk to CouchDB. I had previously tried with Compojure and Hiccup.

The hardest parts were learning enlive and moustache. Enlive is incredibly powerful and very clever, but can be a bit overwhelming for clojure noobs. You definitely want to check out David Nolen's tutorial[5] for it. Aside from that, #clojure and the ring google group are full of wisdom.

Deployment wise, I build the site with a basic leiningen[6] uberjar and run it from an ssh, background it and disown it. yeah, thats terrible, but im lazy and nobody visits my site anyhow ;) Caveat here: Clojure 1.2 has a small bug with interned keywords[7] that will knock my site over in a couple of days if i forget to start it up with the default JVM profile. the -server profile fixes the trigger issues

Aside from that, I have an nginx gateway server that handles serving my media, nowww redirection and proxies all dynamic requests through to the jvm. the site itself hosts a jetty HTTP server via ring to handle all the requests.

The 'hardest' part of getting started with clojure vs say Python+Django or Ruby+Rails is that there is a lack of 'get you going' magic / tools like scaffolds or djangos admin. Once you get past that though, it is a very enjoyable platform inspite of the API changes.

[1]: http://brehaut.net

[2]: http://github.com/cgrand/moustache

[3]: http://github.com/cgrand/enlive

[4]: http://github.com/ashafa/clutch

[5]: http://github.com/swannodette/enlive-tutorial/

[6]: http://github.com/technomancy/leiningen

[7]: http://www.assembla.com/spaces/clojure/tickets/444?comment=9...

brehaut··on A great logo is recognizable in any form
http://www.mozilla.com/en-US/about/logo/
brehaut··on Web Design is 95% Typography
Is that the theme designers fault, or the person deploying their theme?
brehaut··on Google Maps mashup for post earthquake services in NZ
also relevant is http://www.christchurchquakemap.co.nz/ which plots quakes over time based on GNS data
brehaut··on [dead]
What roleplaying game should we play? http://www.youtube.com/watch?v=Rb_R1q8PEnM
brehaut··on [dead]
It's a meme, where you make your two parties talk across each other as bears on the Paws theme for xtranormal. xtranormal lets you make a movie by typing the dialog.

Others include iPhone vs Android, MongoDB is Web Scale, orthopedic vs anesthetist, Which RPG should we play (that one actually is hilarious). probably bound to be a thousand more.

brehaut··on Clojure 1.2 released
It could be that much of the discussion regarding 1.2 has happened on the RCs that have come out of the last month or so?
brehaut··on The absolute bare minimum every programmer should know about regular expressions
Seeing how im advocating that everyone should know when to be using parsing tools rather than cobbling together a regexp cludge, here are some links to some relevant tools in a variety of languages. Note that these are not parser generator tools, but parser combinator libraries:

    * Python: 
        PyParsing - http://pyparsing.wikispaces.com/ - this   
        is probably the most well respected parser library 
        for python 
        
        picoparse - http://github.com/brehaut/picoparse - My 
        parsec inspired parser combinator library. It is 
        significantly more light weight than pyparsing, and
        I would recommend pyparsing in its place for more 
        heavy lifting parsers.

    * Ruby:
        RParsec - http://rubyforge.org/projects/rparsec/ - A 
        ruby implementation of Parsec. I've heard good 
        things about it.

    * Haskell: 
        Parsec - http://legacy.cs.uu.nl/daan/parsec.html - 
        This is an amazing library, worth anyones time. 
        http://book.realworldhaskell.org/read/using-parsec.html 
        http://www.haskell.org/haskellwiki/Parsec

    * F#:
        FParsec - http://www.quanttec.com/fparsec/ - This is 
        reason enough to learn F#; it is a fairly true port 
        of the haskell library and very nice to use. 

    * Scala: 
        Packrat Parsing - I believe this is part of the 
        standard lib. http://www.scala-lang.org/docu/files/api/scala/util/parsing/combinator/PackratParsers.html 

    * Clojure: 
        fnparse - http://github.com/joshua-choi/fnparse

    * Java: 
        jparsec - http://jparsec.codehaus.org/
[edits: formating]
brehaut··on The absolute bare minimum every programmer should know about regular expressions
Agreed, the impedance of parsers has traditionally been much higher than for regexps. However, a lot of languages now have some sort of parse combinator library which dramatically increases the ease of writing a parser.

I'm thinking specifically of the Parsec inspired family, which has implementations or derivations in many common languages, even C# and Java (despite being noticably more cumbersome in those cases there).

[I cannot speak for perl 6, but i trust you are correct]

brehaut··on The absolute bare minimum every programmer should know about regular expressions
I prefer fishbowl's law

   Every regexp that you apply to a particular block of text reduces 
   the applicability of regular expressions by an order of magnitude.
- http://fishbowl.pastiche.org/2003/08/18/beware_regular_expre...

The minimum any programmer needs to know about regexps is when they are applicable, and more importantly, when they are not.

brehaut··on CoffeeScript -- You Are Totally Gonna Hate It
But the one battery that is included in JS makes it unavoidable, and most programmers (the kind that don't read HN or proggit) are the kind to not want to learn another language. If you have the choice between using the quirky thing you know or learning something else, its a good bet most programmers will choose to use the tool the know, quality of the respective tools be damned ;)
brehaut··on Clojure, Node.js and Concurrency Fail
Smarter people than me have commented on this before: http://nighthacks.com/roller/jag/resource/Fallacies.html
brehaut··on In-Depth Book Review: Practical Clojure
> * a small web app with Compojure

perhaps s/Compojure/Ring/ - looking at how the request response cycle works in ring and how you can write raw handlers, or dispatch via compojure or moustache or aleph etc.

brehaut··on HTML5 Programming with F#
Based on the content of the article, the code written in the F# examples is a very close mapping to what you would write in JS yourself, but you get the advantage of the F# typechecker.
← PreviousPage 2 of 5Next →