===================
== Martin Trojer ==
Programming Blog

===================

N Queens with core.logic, take 2

clojure core.logic

This post is a follow-up to my previous post on N Queens and core.logic, in which I tried to find solutions using “pure” logic (without arithmetic goals) and basic miniKanren/Reasoned Schemer building blocks.

After excellent feedback and hints from David Nolen (big thanks), I present a greatly simplified (and faster) way of using core.logic to find all solutions. Credit also goes to good old Bratko.

First, let’s fix the safeo function (and def-subo macro). In miniKanren, you can use arithmetic goals given two prerequisites: the fresh variable must be bound to a finite (number) space, and we must use project to bind the values. This means we can get rid of subo altogether.

Read more...

N Queens with core.logic, take 1

clojure core.logic

I’ve been “hammock-reading” the excellent Reasoned Schemer book these last couple of months, on my quest to develop a gut feel for when logic programming, as defined by miniKanren/core.logic, is applicable.

My first attempt is to apply it to a problem where (as it turns out) miniKanren isn’t a good fit: n-queens. What you really need for this problem in the logical programming world is something called constraint logic programming (CLP), which is implemented (for example) in cKanren. The good people at core.logic are working on integrating CLP and cKanren in core.logic in version 0.8, so I intend to revisit this problem as that work progresses.

Read more...

Some thoughts on logging

clojure

Have you ever tried to log from a multi-threaded program? Have you tried to make sense of log output when multiple subsystems were logging to it? Have you tried to do average latency calculations based on that log file?

If you’re reading this blog, I’m guessing you answered yes to a couple of the questions above.

There are multiple problems here: multiple producers (race conditions), out-of-order logs, conflated subsystems in the same logs, etc. You have to put a lot of effort into your log post-processor to make any sense of the data, decorating it with various metadata to make it possible at all.

Read more...

Distributed Actors in Clojure

akka clojure erlang jvm

Here’s another post on a topic that has been discussed since the dawn-of-time: is there a nice and idiomatic way to write Erlang/Actor-style distributed programs in Clojure? There have certainly been a few attempts, but Rich’s post (above) still holds true today.

First, some clarification: I am not primarily thinking about number-crunching, map/reduce-style stuff, where Clojure has a pretty good story:

Akka and the Erlang legacy

I am trying to write programs that solve problems in the areas where Erlang typically excels, such as:

Read more...

What is a software company?

software

Software is different from most other things humans build, hence companies creating/selling/licensing software must be different from other ‘production’ companies as well? Some definitely are but the vast majority are still trying to apply old civil engineering practices to software development. Why are they wasting so much time and money on upfront sizing, planning and tracking when all empirical evidence tells us it maps so badly to the actual process of developing software? Why haven’t most software companies learnt the hard lessons and started to operate like Valve?

Read more...

Enumerate N Queens solutions

clojure

Adding Live Unit Feeds to Frinj

clojure frinj

A couple of weeks have passed since I pushed Frinj to github and blogged/tweeted about it. The response has been pretty awesome, one highlight being when @stuarthalloway showed me a frinj+datomic example gist on the #datomic IRC channel. In short, the Clojure community is #badass.

Frinj comes with a big database of units and conversion factors, and while many conversion factors are “eternal”, others aren’t. Exchange rates, for instance, have to be kept up to date to be relevant. The Frinj unit database was designed to be updatable, both for usability when doing various calculations and for rates that constantly change. This is the reason the frinj.calc namespace exposes the (frinj-init!) function to reset the unit database to a known baseline (in case you write over some factors, etc.). Clojure’s support for atomically updating state is ideal for this purpose; the calculator’s state is kept in a number of refs and, thanks to the STM, always kept consistent.

Read more...

Announcing Frinj, a practical unit of measure calculator DSL for Clojure

clojure frinj

I am proud to announce a new Clojure project called “Frinj”.

Frinj is a practical unit-of-measure calculator DSL for Clojure.

Key features:

  • Tracks units of measure through all calculations allowing you to mix units of measure transparently
  • Comes with a huge database of units and conversion factors
  • Inspired by the Frink project
  • Tries to combine Frink’s fluent calculation style with idiomatic Clojure

Full source code available on github.

To whet your appetite, head straight over to the sample calculations page to see what Frinj can do!

Read more...

ASCII Mandelbrot Set

clojure

Some thoughts on Clojure performance

.net csharp clojure fsharp javascript jvm mono scala

Edit: This post recently re-surfaced on hacker news and caused a bit of a stir, mainly because of a slightly sensational/misleading title (was “Why is Clojure so slow?”). I wrote this before Rich Hickey’s Clojure/Conj 2011 keynote was published, in which he talks about most of my concerns (and outlines possible solutions).

Clojure is great in many ways, but one thing it can’t be accused of is being particularly fast. What I mean by fast here is the speed at which Clojure programs execute. This is a well-known issue in the Clojure community and has been discussed on the mailing list and Stack Overflow.

Read more...
Previous Page 5 of 7 Next Page