Better Abstractions With core.async

core.async is a  Preview Text:  I’ve been a big fan of Clojure’s core.async library since I first heard about it, and have been eagerly using it in a number of ways. I see core.async as fulfilling two roles: enabler and simplifier. Legacy Sponsored:  unsponsored ...

Permalink

Clojure Gazette 1.86

Clojure Gazette 1.86

X-Men, React, Zippers

Clojure Gazette

Issue 1.86 July 27, 2014


Editorial

Hello functional programmers,

First, I have to thank everyone who helped support the Clojure Gazette last week. There were a bunch of new subscribers. It made July the best month in almost a year.

I'm still experimenting with the Gazette. And it takes a lot of work. I've done it for over two years. It's rewarding, but I'd like to start getting a little back for it.

You'll notice this week that I have started putting sponsored links in the post. The first link is for a great organization that does not make a profit, giving free Clojure intro classes to increase the diversity of programmers. It's called ClojureBridge and I'm very proud to be able to give them this listing. ClojureBridge is a quality organization run by awesome people making an important change in the world. Show them some love by letting the world know how awesome they are, and telling them directly, too, on Twitter and contact form. Also tell anyone you know who may be interested in learning Clojure that fits their target.

I hope all of my sponsors can be as great as them. If you'd like to sponsor the Gazette and showcase your product or service, read the media kit and get in touch!

Rock on!

Sincerely,
Eric Normand <ericwnormand@gmail.com>

PS Please follow the DISCUSS links and comment!

React v0.11 Released


A new point release of React, the library behind Om, Reagent, and others. Performance improvements, rendering null, and many bug fixes. DISCUSS

Lisp in Summer Projects 2014 Winners


I was under a rock this year and missed the whole competition. But here are the winners! They look pretty cool, the judges are amazing, and it's a good cause. DISCUSS

Sponsored Link

ClojureBridge Melbourne


This workshop is intended to reach out to women who are interested in learning programming with Clojure. In this workshop, we'll take you through building a complete web application from scratch using Clojure.

lein-oneoff


A cool Leiningen plugin that aims to make it easier to create single-file projects. You declare the dependencies at the top of the file, then start your namespace declaration as normal. lein-oneoff takes care of fetching the dependencies. DISCUSS

Composing Test Generators


Have you ever wanted to write Prismatic Schemas and have it automatically create test.check generators? Well, somebody already did it in what looks like a very well-engineered way. This talk describes how it works and why. DISCUSS

Manifold


Described as a "compatibility layer for event-driven abstractions", this library has the ambitious goal of providing a unifying interface over Java BlockingQueues, Clojure lazy sequences, and core.async channels. DISCUSS

Sponsored Link

Sponsor the Clojure Gazette


The Clojure Gazette has fostered the inspiration of the Clojure community for over two years. Help support the Gazette by sponsoring a link, and get the exposure your product or service deserves. A link to your product could be right here, in front of thousands of Clojure developers. Download the media kit to learn more.

Clojure X-Men


A cute metaphor of the superpowers Clojure gives you. DISCUSS

Zippers Episode 1


Timothy Baldridge has been doing some screencasts, mostly about core.async mostly available for a small fee or a subscription. His screencasts are a different style from mine, so if you like his style better, go for it. This video is about zippers and is free. DISCUSS

Job Listings

Promote your job to the best functional programmers


If you want the best Clojure programmers, speak to the ones who read academic, pragmatic, and quality content every week in the Gazette. Download the media kit to learn more.
Copyright © 2014 LispCast, All rights reserved.


unsubscribe from this list    change email address   media kit (advertising information)

Permalink

Clojure X-Men

https://c2.staticflickr.com/6/5557/14761955842_6a8bf4a66a_n.jpg">

Nobody knows how it happened. Some people think it was due to the rapid expansion and adoption of Clojure. Other people say that the language itself was caused by something deeper and more magical. No one knows for sure. All that we really know is that people starting being born with extraordinary powers. Powers that no human had had before. They were strange and unique to each person they touched. The only thing that they all had in common, was that each was an aspect of the Clojure programming language.

Luke (AKA Lazy Luke)

Luke was a teenager when his powers came to him. His mother always complained that he was lazy. It was true, he did prefer to sleep until noon. He also had a habit of putting everything off to the last minute, like saving all his papers for the night before they were due. One day, though, he noticed something very strange. He could start to see the future. Well not really “see” it. But he could see the infinite possibilities of the future. Not very far into the future, but enough. It was a few milliseconds at first. But now it was up to a full second. He checked the Clojure Docs as soon as he realized his gift. It was lazy evaluation and power to deal with infinite sequences.

Spress

Spress, whose real name is Emily, came into her power early. She was only 5 years old. Her mother had taken her to a farm to visit with the animals. Her mother had pointed at the cow and told her daughter that it said “Moo”. Then, at the horse, saying “Neigh”. Spress smiled and pointed at a bucket and said “cow”. Her mother shook her head at her, but Spress only smiled bigger. She said “cow” again. Then, suddenly, the bucked went “Moo”. She was immediately taken to the Clojure X-Men school, where they identified her power as protocols. She trained her power and now is so good at solving the “expression problem”, she is known as “Spress”.

Multi

Nobody knows Multi’s background. He came to notice in his early twenties with his powers. Ordinary humans process sensory input, (like sight, touch, and sound), in an asynchronous fashion. However, when it gets processed in the brain, it runs into a single pipeline bottleneck – consciousness. Multi’s power is that he can concurrently process his higher level consciousness and reasoning to all this sensory input. The result is that he can move, think, and perform super fast and in a super smart way. He got the power of Clojure’s concurrency.

Dot

Dot always had a way with animals. She had many pets growing up. Later, she would go into the forest and the animals would seek her out. She would be found resting by a tree surrounded by deer and birds. One time, on her walk, she fell down a ditch and had her leg trapped under a log. Her mother arrived, after searching for her, to see a Bear reach down and gently remove the log. She stood dumbfounded, as her daughter thanked the bear and it nodded in reply as it turned away. She could talk with animals effortlessly. She had the power of Clojure’s Interop.

Bob

Bob is the leader of the Clojure X-Men. He seeks out people with the power of Clojure and helps train and educate them. He also is the most powerful. He can come into any argument, problem, or challenge and immediately separate out what is most important to focus on. He always knows the right thing to do, without getting bogged down in unnecessary details . His power is Clojure’s simplicity.

There might be others out there, we don’t know. We can only hope, that they are found by Bob and the Clojure X-Men and use their powers for good.

Permalink

Cljoure X-Men

https://c2.staticflickr.com/6/5557/14761955842_6a8bf4a66a_n.jpg">

Nobody knows how it happened. Some people think it was due to the rapid expansion and adoption of Clojure. Other people say that the language itself was caused by something deeper and more magical. No one knows for sure. All that we really know is that people starting being born with extraordinary powers. Powers that no human had had before. They were strange and unique to each person they touched. The only thing that they all had in common, was that each was an aspect of the Clojure programming language.

Luke (AKA Lazy Luke)

Luke was a teenager when his powers came to him. His mother always complained that he was lazy. It was true, he did prefer to sleep until noon. He also had a habit of putting everything off to the last minute, like saving all his papers for the night before they were due. One day, though, he noticed something very strange. He could start to see the future. Well not really “see” it. But he could see the infinite possibilities of the future. Not very far into the future, but enough. It was a few milliseconds at first. But now it was up to a full second. He checked the Clojure Docs as soon as he realized his gift. It was lazy evaluation and power to deal with infinite sequences.

Spress

Spress, whose real name is Emily, came into her power early. She was only 5 years old. Her mother had taken her to a farm to visit with the animals. Her mother had pointed at the cow and told her daughter that it said “Moo”. Then, at the horse, saying “Neigh”. Spress smiled and pointed at a bucket and said “cow”. Her mother shook her head at her, but Spress only smiled bigger. She said “cow” again. Then, suddenly, the bucked went “Moo”. She was immediately taken to the Clojure X-Men school, where they identified her power as protocols. She trained her power and now is so good at solving the “expression problem”, she is known as “Spress”.

Multi

Nobody knows Multi’s background. He came to notice in his early twenties with his powers. Ordinary humans process sensory input, (like sight, touch, and sound), in an asynchronous fashion. However, when it gets processed in the brain, it runs into a single pipeline bottleneck – consciousness. Multi’s power is that he can concurrently process his higher level consciousness and reasoning to all this sensory input. The result is that he can move, think, and perform super fast and in a super smart way. He got the power of Clojure’s concurrency.

Dot

Dot always had a way with animals. She had many pets growing up. Later, she would go into the forest and the animals would seek her out. She would be found resting by a tree surrounded by deer and birds. One time, on her walk, she fell down a ditch and had her leg trapped under a log. Her mother arrived, after searching for her, to see a Bear reach down and gently remove the log. She stood dumbfounded, as her daughter thanked the bear and it nodded in reply as it turned away. She could talk with animals effortlessly. She had the power of Clojure’s Interop.

Bob

Bob is the leader of the Clojure X-Men. He seeks out people with the power of Clojure and helps train and educate them. He also is the most powerful. He can come into any argument, problem, or challenge and immediately separate out what is most important to focus on. He always knows the right thing to do, without getting bogged down in unnecessary details . His power is Clojure’s simplicity.

There might be others out there, we don’t know. We can only hope, that they are found by Bob and the Clojure X-Men and use their powers for good.

Permalink

Clojure Destructuring Tutorial….

Clojure Destructuring Tutorial and Cheat Sheet by John Louis Del Rosario.

From the post:

When I try to write or read some Clojure code, every now and then I get stuck on some destructuring forms. It’s like a broken record. One moment I’m in the zone, then this thing hits me and I have to stop what I’m doing to try and grok what I’m looking at.

So I decided I’d write a little tutorial/cheatsheet for Clojure destructuring, both as an attempt to really grok it (I absorb stuff more quickly if I write it down), and as future reference for myself and others.

Below is the whole thing, copied from the original gist. I’m planning on adding more (elaborate) examples and a section for compojure’s own destructuring forms. If you want to bookmark the cheat sheet, I recommend the gist since it has proper syntax highlighting and will be updated first.

John’s right, the gist version is easier to read.

As of 27 July 2014, the sections on “More Examples” and “Compojure” are blank if you feel like contributing.

I first saw this in a tweet by Daniel Higginbotham.

Permalink

London Clojure unconference July 2014 report

For the first session I was interested in trying to continue the discussion about the Clojure “sweet spot” we had had on the mailing list. But there was only a smattering of interest so we rolled it up with the discussion on how to convince people in investment banks to use Clojure.

I think Jon Pither’s approach to this is still the best which is to find a business problem and then say that you’re going to address the problem and use Clojure to solve the real problem. A pure technical argument is not really going to get buy-in from outside the developers.

A lot of organisations want to have an approved list of technologies and for institutions that have chronic and acute technical problems like banks then perhaps that is appropriate given the need for external regulation. Where these things exist I usually think it is a case of going through the bureaucratic hoops.

The approval system is not there to be opinionated but to provide oversight. Where individuals have “weaponised” the approval process to advance their view of “right” technology you need to tackle the root problem not just sneak things in as jars.

My personal view is that financial institutions have profound technology problems but that they have no incentive to address them while they continue to make a lot of money. Really their problems should be providing opportunities for new approaches but as the existing institutions have created massive barriers to entry it doesn’t happen and we’re all really just waiting for the next financial crisis to happen, maybe then…

However in the session there was a lot of discussion about whether it is appropriate for managers to determine technology choices: on the one side you want to devolve decisions to the people close to the problem, on the other programmers commonly change jobs in a shorter period that the lifespan of the software they create.

One thing I took away was that before conservative organisations adopt Clojure they will need to see widespread adoption in the companies they see as good leading indicators and the presence of a large hiring population. In these respects Scala is literally years ahead.

Our final conclusion as a group was simply that the easiest way to approve the use of Clojure was to get into management and leadership first and then do it.

For the second session I went to the discussion on React and Om. I’m looking at React currently and there were a lot of questions about what Om layers on top of the basic JS library. Anna Pawlicka provided a number of the Om answers and others chipped in with bits of React and reactive JS knowledge. I was reminded to go and look at the current state of Om and also the new tutorials. There was also some interesting talk of how to define React components, Anna used Sablono but is there still a need for JSX?

The final session of the evening was on Riemann, which in addition to be a basic introduction to what it does was a helpful reminder of the functionality that Riemann has but that I haven’t used personally. Jason Neylon mentioned that every new service they set up has a Riemann instance attached so you can just dump all events somewhere and then build dashboards dynamically as you go along (a lot better than our approach with Graphite).

Tom Crayford introduced me to the effect of clock skew on Riemann (events from the “future” relative to the Riemann server clock are dropped) and then pointed out that clock skew can actually be monitored via Riemann! Also some interesting stuff about pumping logs into Riemann and some personal experience of crazy volumes of events being successfully handled.

Just before the end of the event I dropped in to the Gorilla REPL session to see Jony Hudson demoing his amazing notebook repl that he has been using to share assignments and research with students and colleagues in his department. A really interesting application and I suspect once we get our heads round it a really interesting way of sharing problems and potential solutions as developers.

Mind slightly blown, I was personally really happy with the event and felt that I’d got a mix of advice and the kind of innovation that make the Clojure community so interesting.


Permalink

Faster than transients? ArrayList + PersistentArrayMap

This situation is explicitly for when you are going to perform allot of assoc(s) and you are sure all keys are new, e.g parsing a json message (or any other serialized message).

@timbaldridge pointed it out to me that the poor performance with Tansients is most likely because I’m growing the map only.

So I changed the implementation to do the following:

public final void append(Object val) {
if(k != null) {
arr.add(k);
arr.add(val);
k = null;
}else
k = val;
}

and

public final Object getValue(){
return new PersistentArrayMap(arr.toArray());
}

Let me explain:

The array list just adds values, and doesnt need to check for existing values this is already a performance improvement.

The arr.toArray() returns Arrays.copyOf(elementData,size).

The PersistentArrayMap takes a Object array as its constructor argument without doing any operations on it; i.e

public PersistentArrayMap(Object[] init){
this.array = init;
this._meta = null;
}

The end result:

3.057527 µs of avg execution time i.e half of what I get when using transient maps.

Summary:

If you are parsing data into maps and you are sure that the keys are unique, the fastest way to do this is collect all the data as key val pairs in an ArrayList and then at the end pass the values to the PersistentArrayMap constructor.

Permalink

Transients not so fast

I’m writing my own little json parser and as with most parsers I’m trying to get the most performance out of it.

So I’ve decided to write it in java but with clojure datastructures, and got this surprise.

The java code in question does:

(see https://github.com/gerritjvv/pjson/blob/master/src/main/java/pjson/ValueContainer.java)

public final void append(Object val) {
   if(k != null) {
     m = m.assoc(k, val);
     k = null;
   }else
     k = val;
}

Now if m is created using PersistentArrayMap.EMPTY.asTransient() the code takes (as per criterium) 6.473563 µs and mean time.

if I create it using PersistentArrayMap.EMPTY the  code takes 4.542464 µs.

I ran the “-XX:+PrintInlining” and saw think that the culprit is 

"BitmapIndexedNode::assoc (552 bytes)   hot method too big",

but I’m not 100% sure. One thing is sure though, in this case the transient map is not working as fast as you would expect and is actually slower than its counterpart.

Permalink

2048 in ClojureScript by Ádám Peresztegi

Experiences of a ClojureScript rookie while building the 2048 game. The prezi: http://prezi.com/paumq5aq5zkc/2048-in-clojurescript/ The repo with the sources: https://github.com/flash42/adad The leiningen template mentioned: https://github.com/flash42/single-page-cljs-template

Permalink

Copyright © 2009, Planet Clojure. No rights reserved.
Planet Clojure is maintained by Baishamapayan Ghose.
Clojure and the Clojure logo are Copyright © 2008-2009, Rich Hickey.
Theme by Brajeshwar.