Archive for the ‘Clojure’ Category

Clojure 1.9 Hits the Streets!

Saturday, December 9th, 2017

Clojure 1.9 by Alex Miller.

From the post:

Clojure 1.9 is now available!

Clojure 1.9 introduces two major new features: integration with spec and command line tools.

spec (rationale, guide) is a library for describing the structure of data and functions with support for:

  • Validation
  • Error reporting
  • Destructuring
  • Instrumentation
  • Test-data generation
  • Generative test generation
  • Documentation

Clojure integrates spec via two new libraries (still in alpha):

This modularization facilitates refinement of spec separate from the Clojure release cycle.

The command line tools (getting started, guide, reference) provide:

  • Quick and easy install
  • Clojure REPL and runner
  • Use of Maven and local dependencies
  • A functional API for classpath management (tools.deps.alpha)

The installer is available for Mac developers in brew, for Linux users in a script, and for more platforms in the future.

Being interested in documentation, I followed the link to spec rationale and found:


Map specs should be of keysets only

Most systems for specifying structures conflate the specification of the key set (e.g. of keys in a map, fields in an object) with the specification of the values designated by those keys. I.e. in such approaches the schema for a map might say :a-key’s type is x-type and :b-key’s type is y-type. This is a major source of rigidity and redundancy.

In Clojure we gain power by dynamically composing, merging and building up maps. We routinely deal with optional and partial data, data produced by unreliable external sources, dynamic queries etc. These maps represent various sets, subsets, intersections and unions of the same keys, and in general ought to have the same semantic for the same key wherever it is used. Defining specifications of every subset/union/intersection, and then redundantly stating the semantic of each key is both an antipattern and unworkable in the most dynamic cases.

Decomplect maps/keys/values

Keep map (keyset) specs separate from attribute (key→value) specs. Encourage and support attribute-granularity specs of namespaced keyword to value-spec. Combining keys into sets (to specify maps) becomes orthogonal, and checking becomes possible in the fully-dynamic case, i.e. even when no map spec is present, attributes (key-values) can be checked.

Sets (maps) are about membership, that’s it

As per above, maps defining the details of the values at their keys is a fundamental complecting of concerns that will not be supported. Map specs detail required/optional keys (i.e. set membership things) and keyword/attr/value semantics are independent. Map checking is two-phase, required key presence then key/value conformance. The latter can be done even when the (namespace-qualified) keys present at runtime are not in the map spec. This is vital for composition and dynamicity.

The idea of checking keys separate from their values strikes me as a valuable idea for processing of topic maps.

Keys not allowed in a topic or proxy, could signal an error, as in authoring, could be silently discarded depending upon your processing goals, or could be maintained while not considered or processed for merging purposes.

Thoughts?

Pattern Overloading

Tuesday, December 6th, 2016

Pattern Overloading by Ramsey Nasser.

From the post:

C-like languages have a problem of overloaded syntax that I noticed while teaching high school students. Consider the following snippets in such a language:

foo(45)

function foo(int x) {

for(int i=0;i < 10; i++) {

if(x > 10) {

case(x) {

A programmer experienced with this family would see

  1. Function invocation
  2. Function definition
  3. Control flow examples

In my experience, new programmers see these constructs as instances of the same idea: name(some-stuff) more-stuff. This is not an unreasonable conclusion to reach. The syntax for each construct is shockingly similar given that their semantics are wildly different.

You won’t be called upon to re-design C but Nasser’s advice:

Syntactic similarity should mirror semantic similarity

Or, to take a quote from the UX world

Similar things should look similar and dissimilar things should look dissimilar

is equally applicable to any syntax that you design.

Clojure/conj 2016 – Videos – Sorted

Monday, December 5th, 2016

Clojure/conf 2016 has posted videos of all presentations (thanks!) to YouTube, which displays them in no particular order.

To help with my viewing and perhaps yours, here are the videos in title order:

  1. Adventures in Understanding Documents – Scott Tuddenham
  2. Audyx.com 40k locs to build the first web – based sonogram – Asher Coren
  3. Barliman: trying the halting problem backwards, blindfolded – William Byrd, Greg Rosenblatt
  4. Becoming Omniscient with Sayid – Bill Piel
  5. Building a powerful Double Entry Accounting system – Lucas Cavalcanti
  6. Building composable abstractions – Eric Normand
  7. Charting the English Language…in pure Clojure – Alexander Mann
  8. Clarifying Rules Engines with Clara Rules – Mike Rodriguez
  9. Clojure at DataStax: The Long Road From Python to Clojure – Nick Bailey
  10. A Clojure DSL for defining CI/CD orchestrations at scale – Rohit Kumar, Viraj Purang
  11. Composing music with clojure.spec – Wojciech Franke
  12. In situ model-based learning in PAMELA – Paul Robertson, Tom Marble
  13. Juggling Patterns and Programs – Steve Miner
  14. Overcoming the Challenges of Mentoring – Kim Crayton
  15. A Peek Inside SAT Solvers – Jon Smock
  16. Powderkeg: teaching Clojure to Spark – Igor Ges, Christophe Grand
  17. Production Rules on Databases – Paula Gearon
  18. Programming What Cannot Be Programmed: Aesthetics and Narrative – D. Schmüdde
  19. Proto REPL, a New Clojure Development and Visualization Tool – Jason Gilman
  20. Simplifying ETL with Clojure and Datomic – Stuart Halloway
  21. Spec-ulation Keynote – Rich Hickey
  22. Spectrum, a library for statically "typing" clojure.spec – Allen Rohner
  23. Using Clojure with C APIs for crypto and more – lvh
  24. WormBase database migration to Datomic on AWS: A case Study – Adam Wright

Enjoy!

Rich Hickey and Brian Beckman – Inside Clojure (video)

Thursday, August 18th, 2016

From the description:

Clojure is a dynamic programming language created by Rich Hickey that targets both the Java Virtual Machine and the CLR. It is designed to be a general-purpose language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming. Clojure is a compiled language – it compiles directly to JVM bytecode, yet remains completely dynamic. Every feature supported by Clojure is supported at runtime. Clojure provides easy access to the Java frameworks, with optional type hints and type inference, to ensure that calls to Java can avoid reflection.

Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system. Clojure is predominantly a functional programming language, and features a rich set of immutable, persistent data structures. When mutable state is needed, Clojure offers a software transactional memory system and reactive Agent system that ensure clean, correct, multithreaded designs.

Astrophysicist and Software Architect Brian Beckman interviews Rich Hickey to dig into the details of this very interesting language. If you don’t know much about Clojure and the general problems it aims to solve, well, watch and listen carefully to this great conversation with plenty of whiteboarding and outstanding questions. Expert to Expert simply rocks! Thank you for spending time with us, Rich! Clojure is great!

From 2013 but what a nice find for a Thursday afternoon!

Do you know the origin of “conj” in Clojure? 😉

Enjoy!

strace’ing a Clojure process under lein

Tuesday, August 16th, 2016

strace’ing a Clojure process under lein by Tim McCormack.

From the post:

Today I wanted to strace a JVM process to see if it was making network calls, and I discovered a minor roadblock: It was a Clojure program being run using the Leiningen build tool. lein run spawns a JVM subprocess and then exits, and I only wanted to trace that subprocess.

The solution is simple, but worth a post: Tell lein to run a different “java” command that actually wraps a call to java with strace. Here’s how I did it:

For the “…you never do know file…” and because it’s better to know than to assume.

Clojure Gazette – New Format – Looking for New Readers

Monday, June 20th, 2016

Clojure Gazette by Eric Normand.

From the end of this essay:

Hi! The Clojure Gazette has recently changed from a list of curated links to an essay-style newsletter. I’ve gotten nothing but good comments about the change, but I’ve also noticed the first negative growth of readership since I started. I know these essays aren’t for everyone, but I’m sure there are people out there who would like the new format who don’t know about it. Would you do me a favor? Please share the Gazette with your friends!

The Biggest Waste in Our Industry is the title of the essay I link to above.

From the post:

I would like to talk about two nasty habits I have been party to working in software. Those two habits are 1) protecting programmer time and 2) measuring programmer productivity. I’m talking from my experience as a programmer to all the managers out there, or any programmer interested in process.

You can think of Eric’s essay as an update to Peopleware: Productive Projects and Teams by Tom DeMarco and Timothy Lister.

Peopleware was first published in 1987, second edition in 1999 (8 new chapters), third edition in 2013 (5 more pages than 1999 edition?).

Twenty-nine (29) years after the publication of Peopleware, managers still don’t “get” how to manage programmers (or other creative workers).

Disappointing, but not surprising.

It’s not uncommon to read position ads that describe going to lunch en masse, group activities, etc.

You would think they were hiring lemmings rather than technical staff.

If your startup founder is that lonely, check the local mission. Hire people for social activities, lunch, etc. Cheaper than hiring salaried staff. Greater variety as well. Ditto for managers with the need to “manage” someone.

ClojureBridge…beginner friendly alternative to the official Clojure docs

Tuesday, June 14th, 2016

Get into Clojure with ClojureBridge

Welcome to ClojureBridge CommunityDocs, the central location for material supporting and extending the core ClojureBridge curriculum (https://github.com/ClojureBridge/curriculum). Our goal is to provide additional labs and explanations from coaches to address the needs of attendees from a wide range of cultural and technical backgrounds.

Arne Brasseur ‏tweeted earlier today:

Little known fact, the ClojureBridge community docs are a beginner friendly alternative to the official Clojure docs

Pass this along and contribute to the “beginner friendly alternative” so this becomes a well known fact.

Enjoy!

Alda (Music Programming Language) Update

Monday, May 23rd, 2016

Alda: A Music Programming Language, Built in Clojure by David Yarwood.

Presentation by David at Clojure Remote.

From the description:

Inspired by other music/audio programming languages such as PPMCK, LilyPond and ChucK, Alda aims to be a powerful and flexible programming language for the musician who wants to easily compose and generate music on the fly, using only a text editor.

Clojure proved to be an ideal language for building a language like Alda, not only because of its wealth of excellent libraries like Instaparse and Overtone, but also because of its Lispy transparency and facility for crafting DSLs.

From the Github page:

Slack: Sign up to the universe of Clojure chat @ http://clojurians.net/, then join us on #alda

Reddit: Come join us in /r/alda, where you can discuss all things Alda and share your Alda scores!

Alda is looking for contributors! Step up!

Clojure/west 2016 – Videos! [+ Unix Sort Trick]

Monday, April 18th, 2016

I started seeing references to Clojure/west 2016 videos and to marginally increase your access to them, I have sorted them by author and with a Unix sort trick, by title.

Unix Sort Trick (truthfully, just a new switch to me)

Having the videos in author order is useful but other people may remember a title and not the author.

I want to sort the already created <li> elements with sort, but you can see the obvious problem.

By default, sort uses the entire line for sorting, which given the urls, isn’t going to give the order I want.

To the rescue, the -k switch for sort, which allows you to define which field and character offset in that field to use for sorting.

In this case, I used 1, the default field and then character offset 74, the first character following the > of the <a> element.

Resulted in:

In full: sort -k 1.74 sort-file.txt > sorted-file.txt

Brave Clojure: Become a Better Programmer

Wednesday, March 23rd, 2016

Brave Clojure: Become a Better Programmer by Daniel Higginbotham.

From the post:

Next week week I’m re-launching www.braveclojure.com as Brave Clojure. The site will continue featuring Clojure for the Brave and True, but I’m expanding its scope a bit. Instead of just housing the book, the purpose of the site will be to help you and the people you cherish become better programmers.

Like many other Clojurists, I fell in love with the language because learning it made me a better programmer. I started learning it because I was a bit bored and burnt out on the languages and tools I had been using. Ruby, Javascript, Objective-C weren’t radically different from each other, and after using them for many years I felt like I was stagnating.

But Clojure, with its radically different approach to computation (and those exotic parentheses) drew me out of my programming funk and made it fun to code again. It gave me new tools for thinking about software, and a concomitant feeling that I had an unfair advantage over my colleagues. So of course the subtitle of Clojure for the Brave and True is learn the ultimate language and become a better programmer.

And, four years since I first encountered Rich Hickey’s fractal hair, I still find Clojure to be an exceptional tool for becoming a better programmer. This is because Clojure is a fantastic tool for exploring programming concepts, and the talented community has created exceptional libraries for such diverse approaches as forward-chaining rules engines and constraint programming and logic programming, just to name a few.

Mark your calendar to help drive the stats for Daniel’s relaunch of www.braveclojure.com as Brave Clojure.

Email, tweet, blog, etc., to help others drive not only the relaunch stats but the stats for following weeks as well.

This could be one of those situations where your early participation and contributions will shape the scope and the nature of this effort.

Enjoy!

Open Source Clojure Projects

Monday, March 14th, 2016

Open Source Clojure Projects by Daniel Higginbotham.

Daniel Higginbotham of Clojure for the Brave and True, has posted this listing of open source Clojure projects with the blurb:

Looking to improve your skills and work with real code? These projects are under active development and welcome new contributors.

You can see the source at: https://github.com/braveclojure/open-source, where it says:

Pull requests welcome!

Do you know of any other open source Clojure projects that welcome new contributors?

Like yours?

Just by way of example, marked as “beginner friendly,” you will find:

alda – A general purpose music programming language

Avi – A lively vi (a spec & implementation of vim)

clj-rethinkdb – An idomatic RethinkDB client for Clojure

For the more sure-footed:

ClojureCL – Parallel computations on the GPU with OpenCL 2.0 in Clojure

Enjoy!

27 Reasons to Attend Clojure/West 2016 + Twitter List

Wednesday, February 17th, 2016

Clojure/West 2016 Speakers

I extracted the speaker list plus twitter accounts where available from the speakers list for Clojure/West 2016.

Now you have twenty-seven reasons to attend! Stack those up against any to not attend.

Register: April 15th-16th, Seattle Marriott Waterfront

April 15th is “tax day” in the United States.

Wouldn’t you rather be having fun with Clojure than grubbing around with smudged and/or lost receipts? I thought so. Register today!

Whether the government picks you pocket one day or the next makes little difference.

File early and attend while the tax hounds try to decide if Thai numerals printed in Braille are a legitimate tax return. 😉

  1. Matthias Felleisen Types are like the Weather, Type Systems are like Weathermen
  2. Alex Kehayias Functional Game Engine Design for the Web
  3. Allison Carter, From Fluxus to Functional: A Journey Through Interactive Art
  4. Amie Kuttruff, Deepen and Diversify the Clojure Community with Jr Engineers
  5. Aysylu Greenberg, (+ Loom (years 2))
  6. Bryce Covert, USE lisp WITH game – Making an Adventure Game with Clojure
  7. Christopher Small, Datalog all the way down
  8. Claire Alvis, Creating DSLs – a tale of spec-tacular success and failure
  9. Daniel Higginbotham, Parallel Programming, Fork/Join, and Reducers
  10. Devon Peticolas, One Million Clicks per Minute with Kafka and Clojure
  11. Donevan Dolby, Managing one of the world’s largest Clojure code bases
  12. Gerred Dillon, ClojureScript and Lambda: A Case Study
  13. Ghadi Shayban, Parsing Text with a Virtual Machine
  14. Jack Dubie, Fast full stack testing in om.next
  15. Jonathan Boston, Caleb Phillips, Building a Legal Data Service with Clojure
  16. Katherine Fellows, Anna Pawlicka, ClojureBridge in Practice
  17. Mario Aquino, The Age of Talkies
  18. Michael Drogalis, Inside Onyx
  19. Michał Marczyk, defrecord/deftype in Clojure and ClojureScript
  20. Mikaela Patella, Web Development is Distributed Systems Programming
  21. Nathan Marz, Specter: powerful and simple data structure manipulation
  22. Nathan Sorenson, Hybrid Automata and the Continuous Life
  23. Patrick O’Brien, Braid Chat: Reifying Online Group Conversations
  24. Paula Gearon, Production Rules in Datomic
  25. Peter Schuck Hash Maps: more room at the bottom
  26. Priyatam Mudivarti, Caching half a billion user transactions
  27. Stuart Sierra, The Joys and Perils of Interactive Development

PS: Be careful how you use the term “weathermen.” The professionally paranoid in government remember a different meaning that what you may intend. As do some of the rest of us.

Clojure for the Brave and True (Google Group)

Saturday, February 13th, 2016

Clojure for the Brave and True (Google Group) by Daniel Higginbotham.

First there was the website: Clojure for the Brave and True.

Then there was the book: Clojure for the Brave and True.

But before the book there was Daniel’s twitter account: @nonrecursive.

There’s no truth to the rumor of a free print trade publication with the title: Clojure for the Brave and True so please direct your questions and answers to:

Clojure for the Brave and True (Google Group)

Enjoy!

Designing with Data (Clojure)

Thursday, February 11th, 2016

Designing with Data by Michael Dorgalis.

Slides from keynote at Clojure Remote 2016.

Without the video of the presentation, the usual difficulties of using slides in isolation obtain.

On the plus side, you have to work harder for the information and that may enhance your retention/comprehension.

Enjoy!

Clojure for Data Science [Caution: Danger of Buyer’s Regret]

Saturday, February 6th, 2016

Clojure for Data Science by Mike Anderson.

From the webpage:

Presentation given at the Jan 2016 Singapore Clojure Users’ Group

You will have to work at the presentation because there is no accompanying video, but the effort will be well spent.

Before you review these slides or pass them onto others, take fair warning that you may experience “buyer’s regret” with regard to your current programming language/paradigm (if not already Clojure).

However powerful and shiny your present language seems now, its luster will be dimmed after scanning over this slides.

Don’t say you weren’t warned ahead of time!

BTW, if you search for “clojure for data science” (with the quotes) you will find among other things:

Clojure for Data Science Progressing by Henry Garner (Packt)

Repositories for the Clojure for Data Science Processing book.

@cljds Clojure Data Science twitter feed (Henry Garner). VG!

Clojure for Data Science Some 151 slides by Henry Garner.

Plus:

Planet Clojure, a metablog that collects posts from other Clojure blogs.

As a close friend says from time to time, “clojure for data science,”

G*****s well.” 😉

Enjoy!

LispNYC Videos

Wednesday, February 3rd, 2016

LispNYC Videos

Videos recorded at some LispNYC meetings have been posted online.

Not enough to get your through the 2016 election cycle but a good start!

Enjoy!

New Clojure website is up!

Thursday, January 14th, 2016

Clojure

From the website:

Clojure is a robust, practical, and fast programming language with a set of useful features that together form a simple, coherent, and powerful tool.

The Clojure Programming Language

Clojure is a dynamic, general-purpose programming language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming. Clojure is a compiled language, yet remains completely dynamic – every feature supported by Clojure is supported at runtime. Clojure provides easy access to the Java frameworks, with optional type hints and type inference, to ensure that calls to Java can avoid reflection.

Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system. Clojure is predominantly a functional programming language, and features a rich set of immutable, persistent data structures. When mutable state is needed, Clojure offers a software transactional memory system and reactive Agent system that ensure clean, correct, multithreaded designs.

I hope you find Clojure’s combination of facilities elegant, powerful, practical and fun to use.

Rich Hickey
author of Clojure and CTO Cognitect

I think the green color scheme in the header was intended to tie in with the download link for Clojure 1.7.0. 😉

If you haven’t downloaded Clojure 1.7.0, what are you waiting for?

Enjoy!

Clojure Distilled

Tuesday, January 5th, 2016

Clojure Distilled by Dmitri Sotnikov.

From the post:

The difficulty in learning Clojure does not stem from its syntax, which happens to be extremely simple, but from having to learn new methods for solving problems. As such, we’ll focus on understanding the core concepts and how they can be combined to solve problems the functional way.

All the mainstream languages belong to the same family. Once you learn one of these languages there is very little effort involved in learning another. Generally, all you have to do is learn some syntax sugar and the useful functions in the standard library to become productive. There might be a new concept here and there, but most of your existing skills are easily transferable.

This is not the case with Clojure. Being a Lisp dialect, it comes from a different family of languages and requires learning new concepts in order to use effectively. There is no reason to be discouraged if the code appears hard to read at first. I assure you that the syntax is not inherently difficult to understand, and that with a bit of practice you might find it to be quite the opposite.

The goal of this guide is to provide an overview of the core concepts necessary to become productive with Clojure. Let’s start by examining some of the key advantages of the functional style and why you would want to learn a functional language in the first place.

Dmitri says near the end, “…we only touched on only a small portion of the overall language…,” but it is an impressive “…small portion…” and is very likely to leave you wanting to hear more.

The potential for immutable data structures in collaborative environments is vast. I’ll have something longer to post on that next week.

Enjoy!

Encapsulation and Clojure – Part I

Monday, December 21st, 2015

Encapsulation and Clojure – Part I by James Reeves.

From the post:

Encapsulation is a mainstay of object orientated programming, but in Clojure it’s often avoided. Why does Clojure steer clear of a concept that many programming languages consider to be best practice?

Err, because “best practices” may be required to “fix” problems baked into a language?

That would be my best guess.

Clojure Design Patterns

Friday, December 18th, 2015

Clojure Design Patterns by Mykhailo Kozik (Misha).

From the webpage:

Quick overview of the classic Design Patterns in Clojure.

Disclaimer: Most patterns are easy to implement because we use dynamic typing, functional programming and, of course, Clojure. Some of them look wrong and ugly. It’s okay. All characters are fake, coincidences are accidental.

In many places this is the last weekend before Christmas, which means both men and women will have lots of down time waiting on others in shopping malls.

That is the one time when I could see a good-sized mobile device being useful, assuming the mall had good Wifi.

In case yours does and you have earplugs for the background music/noise, you may enjoy pulling this up to read.

I first saw this in a tweet by Atabey Kaygun.

Cursive 1.0, Gingerbread Cuneiform Tablets, XQuery

Thursday, December 10th, 2015

Cursive 1.0

From the webpage:

Cursive 1.0 is finally here! Here’s everything you need to know about the release.

One important thing first, we’ve had to move some things around. Our website is now at cursive-ide.com, we’re on Twitter at @CursiveIDE, and our Github handle is now cursive-ide. Hopefully everything should be redirected as much as possible, but let me know if you can’t find anything or if you find anything where it shouldn’t be. The main Cursive email address is now cursive@cursive-ide.com but the previous one will continue to work. The mailing lists will continue to use the previous domain for the moment.

Cursive 1.0 is considered a stable build, and is now in the JetBrains plugin repo (here). Going forward, we’ll have a stable release channel which will have new builds every 2-3 months, and an EAP channel which will have builds more or less as they have been during the EAP program. Stable builds will be published to the JetBrains repo, and EAP builds will continue to be published to our private repo. You’ll be prompted at startup which channel you’d like to use, and Cursive will set up the new URLs for the EAP channel automatically if required. Stable builds will be numbered x.y.0, and EAP builds will use x.y.z numbering.

From https://cursive-ide.com/:

Cursive is available as an IntelliJ plugin for use with the Community or Ultimate editions, and will be available in the future as a standalone Clojure-focused IDE. It is a commercial product, with a free non-commercial licence for open-source work, personal hacking, and student work.

I’m not brave enough to install software on someone’s computer as a “surprise” holiday present. Unless you are a sysadmin, I suggest you don’t either.

Of course, you could take the UPenn instructions for making gingerbread cuneiform tablets and make a “card” for the lucky recipient of a license for the full version of Cursive 1.0.

For that matter, you could inscribe smaller gingerbread pieces with bits of XQuery syntax and play holiday games with arbitrary XML documents. Timed trials for the most imaginative XQuery, shortest, etc.

PS: Suggestions on an XQuery corpus to determine the frequency of XQuery syntax representations? “For,” “(,” and, “)” are likely the most common ones, but that’s just guessing on my part.

Optimizing Hash-Array Mapped Tries…

Saturday, November 28th, 2015

Optimizing Hash-Array Mapped Tries for Fast and Lean Immutable JVM Collections by Adrian Colyer.

Adrian’s review of Optimizing Hash-Array Mapped Tries for Fast and Lean Immutable JVM Collections by Steinforder & Vinju, 2015, starts this way:

You’d think that the collection classes in modern JVM-based languages would be highly efficient at this point in time – and indeed they are. But the wonderful thing is that there always seems to be room for improvement. Today’s paper examines immutable collections on the JVM – in particular, in Scala and Clojure – and highlights a new CHAMPion data structure that offers 1.3-6.7x faster iteration, and 3-25.4x faster equality checking.

CHAMP stands for Compressed Hash-Array Mapped Prefix-tree.

The use of immutable collections is on the rise…

Immutable collections are a specific area most relevant to functional/object-oriented programming such as practiced by Scala and Clojure programmers. With the advance of functional language constructs in Java 8 and functional APIs such as the stream processing API, immutable collections become more relevant to Java as well. Immutability for collections has a number of benefits: it implies referential transparency without giving up on sharing data; it satisfies safety requirements for having co-variant sub-types; it allows to safely share data in presence of concurrency.

Both Scala and Clojure use a Hash-Array Mapped Trie (HAMT) data structure for immutable collections. The HAMT data structure was originally developed by Bagwell in C/C++. It becomes less efficient when ported to the JVM due to the lack of control over memory layout and the extra indirection caused by arrays also being objects. This paper is all about the quest for an efficient JVM-based derivative of HAMTs.

Fine-tuning data structures for cache locality usually improves their runtime performance. However, HAMTs inherently feature many memory indirections due to their tree-based nature, notably when compared to array-based data structures such as hashtables. Therefore HAMTs presents an optimization challenge on the JVM. Our goal is to optimize HAMT-based data structures such that they become a strong competitor of their optimized array-based counterparts in terms of speed and memory footprints.

Adrian had me at: “a new CHAMPion data structure that offers 1.3-6.7x faster iteration, and 3-25.4x faster equality checking.”

If you want experience with the proposed data structures, the authors have implemented them in the Rascal Metaprogramming Language.

I first saw this in a tweet by Atabey Kaygun

Debugging with the Scientific Method [Debugging Search Semantics]

Tuesday, November 17th, 2015

Debugging with the Scientific Method by Stuart Halloway.

This webpage points to a video of Stuart’s keynote address at Clojure/conj 2015 with the same title and has pointers to other resources on debugging.

Stuart summarizes the scientific method for debugging in his closing as:


know where you are going

make well-founded choices

write stuff down

Programmers, using Clojure or not, will profit from Stuart’s advice on debugging program code.

A group that Stuart does not mention, those of us interested in creating search interfaces for users will benefit as well.

We have all had a similar early library experience, we are facing (in my youth) what seems like an endless rack of card files with the desire to find information on a subject.

Of course the first problem, from Stuart’s summary, is that we don’t know where we are going. At best we have an ill-defined topic on which we are supposed to produce a report. Let’s say “George Washington, father of our country” for example. (Yes, U.S. specific but I wasn’t in elementary school outside of the U.S. Feel free to post or adapt this with other examples.)

The first step, with help from a librarian, is to learn the basic author, subject, title organization of the card catalog. And things like looking for “George Washington” starting with “George” isn’t likely to produce a useful result. Eliding over the other details that a librarian would convey, you are somewhat equipped to move to step two.

Understanding the basic organization and mechanics of a library card catalog, you can develop a plan to search for information on George Washington. Such a plan would include excluding works over the reading level of the searcher, for example.

The third step of course is to capture all the information that is found from the resources located by using the library card catalog.

I mention that scenario not just out of nostalgia for card catalogs but to illustrate the difference between a card catalog and its electronic counter-parts, which have an externally defined schema and search interfaces with no disclosed search semantics.

That is to say, if a user doesn’t find an expected result for their search, how do you debug that failure?

You could say the user should have used “term X” instead of “term Y” but that isn’t solving the search problem, that is fixing the user.

Fixing users, as any 12-step program can attest, is a very difficult and fraught with failure process.

Fixing search semantics, debugging search semantics as it were, can fix the search results for a large number of users with little or no effort on their part.

There are any number of examples of debugging or fixing search semantics but the most prominent one that comes to mine is spelling correction by search engines that result results with the “correct” spelling and offer the user an opportunity to pursue their “incorrect” spelling.

At one time search engines returned “no results” in the event of mis-spelled words.

The reason I mention this is you are likely to be debugging search semantics on a less than global search space scale but the same principle applies as does Stuart’s scientific method.

Treat complaints about search results as an opportunity to debug the search semantics of your application. Follow up with users and test your improved search semantics.

Recalling that is all events, some user signs your check, not your application.

Recreational Constraint Programmer

Monday, November 16th, 2015

https://youtu.be/AEhULv4ruL4 [Embedding of the video disabled at the source. Follow the link.]

From the description:

Many of us have hazy memories of finite state machines from computer science theory classes in college. But finite state machines (FSMs) have real, practical value, and it is useful to know how to build and apply them in Clojure. For example, FSMs have long been popular to model game AIs and workflow rules, and FSMs provide the behind-the-scenes magic that powers Java’s regexes and core.async’s go blocks. In this talk, we’ll look at two programming puzzles that, suprisingly, have very elegant solutions when looked at through the lens of FSMs, with code demonstrations using two different Clojure libraries for automata (automat and reduce-fsm), as well as loco, a Clojure constraint solver.

If you have never heard anyone describe themselves as a “recreational constraint programmer,” you really need to see this video!

If you think about having a single representative for a subject as a constraint on a set of topics, the question becomes what properties must each topic have to facilitate that constraint?

Some properties, such as family names, will lead to over-merging of topics and other properties, such as possession of one and only one social security number, will under-merge topics where a person has multiple social security numbers.

The best code demonstration in the video was the generation of a fairly complex cross-word puzzle, sans the clues for each word. I think the clues were left as an exercise for the reader. 😉

Code Repositories:

http://github.com/engelberg/automata

http://github.com/aengelberg/automata

Encouraging enough that you might want to revisit regular expressions.

Enjoy!

The 100 Most Used Clojure Expressions

Saturday, November 14th, 2015

The 100 Most Used Clojure Expressions by Eric Normand.

From the post:

Summary: Would you like to optimize your learning of Clojure? Would you like to focus on learning only the most useful parts of the language first? Take this lesson from second language learning: learn the expressions in order of frequency of use.

When I was learning Spanish, I liked to use Anki to drill new vocabulary. It’s a flashcard program. I found that someone had made a set of cards from an analysis of thousands of newspapers. They read in all of the words from the newspapers, counted them up, and figured out what the most common words were. The top 1000 made it into the deck.

It turns out that this is a very good strategy for learning words. Word frequency follows a hockey stick distribution. The most common words are used so much more than the less common words. For instance, the 100 most common English words make up more than 50% of text. If you’ve got limited time, you should learn those most common words first.

People who are trying to learn Clojure have been asking me “how do I learn all of this stuff? There’s so much!” It’s a valid question and I haven’t had a good answer. I remembered the Spanish newspaper analysis and I thought I’d try to do a similar analysis of Clojure expressions.

Is Eric seriously suggesting using lessons learned in another field? 😉

Of course, for a CS conference using the top 100 most common Clojure expressions would have a title similar to:

Use of High Frequency Terminology Repetition: A Small Group Study (maybe 12 participants)

You could, of course, skip waiting for a conference presentation with a title like that one, followed by peer reviewed paper(s), more conference presentations and its final appearance in a collection of potential ways to improve CS instruction.

Let me know if Eric’s suggestion works for you.

Enjoy!

PS: Thanks Eric!

Let’s Make Clojure.org Better! [Lurk No Longer!]

Tuesday, November 10th, 2015

Let’s Make Clojure.org Better! by Alex Miller.

From the post:

The Clojure community is full of talented writers and valuable experience, and together we can create great documentation for the language and the ecosystem. With that in mind, we are happy to announce a new initiative to replace the existing http://clojure.org site. The new site will contain most of the existing reference and information content but will also provide an opportunity for additional guides or tutorials about Clojure and its ecosystem.

The new site content is hosted in a GitHub repository and is open for contributions. All contributions require a signed Clojure Contributor Agreement. This repository will accept contributions via pull request and issues with GitHub issues. The contribution and review process is described in more detail on the site contribution page.

We are currently working on the design elements for the site but if you would like to suggest a new guide, tutorial, or other content to be included on the site, please file an issue for discussion or create a thread on the Clojure mailing list with [DOCS] in the subject. There will be an unsession at the Clojure/conj conference next week for additional discussion. This is the beginning of a process, and things will likely evolve in the future. In the meantime, we look forward to seeing your contributions!

You have been waiting to showcase your writing and/or Clojure talents for some time now. Here’s your chance to lurk no longer!

Don’t keep all that talent hidden under a bushel basket! Step up and make the Clojure community, not to mention Clojure.org the beneficiary of all that talent.

You never know what connections you will make or who will become aware of your talents.

You never will know if you don’t participate. Your call.

Clojure for the Brave and True Update!

Wednesday, October 21st, 2015

Clojure for the Brave and True by Daniel Higginbotham.

From the webpage:

Clojure for the Brave and True is now available in print! You can use the coupon code ZOMBIEHUGS to get 30% off at No Starch (plus you’ll get a free sticker), or buy it from Amazon.

The web site has been updated, too! (Don’t forget to force refresh.) One of the reasons I went with No Starch as a publisher was that they supported the idea of keeping the entire book available for free online. It makes me super happy to release the professionally-edited, even better book for free. I hope it makes you laugh, cry, and give up on object-oriented programming forever.

Writing this book was one of the most ambitious projects of my life, and I appreciate all the support I’ve gotten from friends, family, and readers like you. Thank you from the bottom of my crusty heart!

[Update] I got asked for a list of the major differences. Here they are:

  • Illustrations!
  • Almost every chapter now has exercises
  • The first macro chapter, Read and Eval, is massively improved. I’m hoping this will gives readers an excellent conceptual foundation for working with macros
  • There’s now a joke about melting faces
  • There used to be two Emacs chapters (basic emacs and using Emacs for Clojure dev), now there’s just one
  • The concurrency chapter got split into two chapters
  • Appendices on Leiningen and Boot were added
  • The “Do Things” chapter is much friendlier
  • I spend a lot more time explaining some of the more obscure topics, like lazy sequences.
  • Many of the chapters got massive overhauls. The functional programming chapter, for example, was turned completely inside out, and the result is that it’s much, much clearer
  • Overall, everything should be clearer

Daniel has taken the plunge and quit his job to have more time for writing. If you can, buy a print copy and recommend Clojure for the Brave and True to a friend!

We need to encourage people like Daniel and publishers like No Starch. Vote with your feet and your pocket books.

Follow Daniel on twitter @nonrecursive

Clojure Remote February 11-12, 2016 — Online

Thursday, October 15th, 2015

Clojure Remote February 11-12, 2016 — Online

Important Dates:

  • Oct. 15 — Early-bird admission starts.
  • Oct. 30 — CFP opens, Regular admission rate begins
  • Dec. 31 — CFP closes
  • Jan. 15 — Schedule released
  • Feb. 11, 12 — The Conference!

From the webpage:

This Winter, Homegrown Labs presents Clojure Remote—Clojure’s first exclusively Remote conference. Join us anywhere; from your home, your office, or the coffee shop.

Over two days, you’ll join hundreds of other Clojurists online via crowdcast.io to enjoy up to two tracks of beginner to intermediate Clojure talks.

Clojure Remote will be held February 11th and 12th, 2016 from 2:00 PM UTC – 9:00 pm UTC.

The conference will be broadcast via crowdcast.io, where attendees can:

  • View talks live
  • Ask & up-vote questions
  • And chat with fellow attendees.

Clojure Remote attendees will miss:

  • Delays and frustrations of airport security and missed connections
  • Wedging themselves into grade school size airline seats
  • Taxi transportation where drivers speak every language but yours
  • Disease producing dry air in hotels
  • Expenses that could have gone towards new hardware or books

but, for virtual conferences to make progress, sacrifices have to be made. 😉

True, virtual conferences do lack some of the randomness and “press the flesh” opportunities of physical conferences but CS has been slow to take up the advantages of more frequent but shorter virtual or online conferences.

SICP Distilled Now Public

Thursday, October 8th, 2015

SICP Distilled Now Public by Tom Hall.

From the post:

I have made the SICP Distilled site public.

It is now a year since the SICP Distilled Kickstarter was funded, I originally thought it would take 5 months to complete and had a slightly different vision for what it would look like, massive thanks to all of the supporters for their patience and understanding.

I originally thought an accompaniment to the original book but it has wound up being more like a rewrite, fortunately the original text is under a Creative Commons Attribution-ShareAlike 4.0 License so I can ‘remix’ it without getting into copyright issues if I have the same licence.

It is not complete yet, but I think I now have good explanations of:

Which really are (for me at least) the highlights of the book.

As a very minor supporter in the Kickstarter campaign I deeply appreciate all the effort that Tom has devoted to this effort.

Comment early and often!

Computational Literary Analysis

Wednesday, October 7th, 2015

Computational Literary Analysis by Atabey Kaygun.

From the post:

Description of the problem

One of the brilliant ideas that Kurt Vonnegut came up with was that one can track the plot of a literary work using graphical methods. He did that intuitively. Today’s question is “Can we track the plot changes in a text using computational or algorithmic methods?”

Overlaps between units of texts

The basic idea is to split a text into fundamental units (whether this is a sentence, or a paragraph depends on the document) and then convert each unit into a hash table where the keys are stemmed words within the unit, and the values are the number of times these (stemmed) words appear in each unit.

My hypothesis is (and I will test that in this experiment below) that the amount of overlap (the number of common words) between two consecutive units tells us how the plot is advancing.

I will take the fundamental unit as a sentence below.

Clojure, Lisp, computational literary analysis, what’s there not to like? 😉

Given the hypothesis:

the amount of overlap (the number of common words) between two consecutive units tells us how the plot is advancing

Atabey doesn’t say what his criteria is for “the plot advancing.” I mention that because both of the plots he offers trail off from their highs.

If there is a plot advance, shouldn’t the respective speeches build until they peak at the end?

Or is there some more complex “plot advancement” at play?

One of the things that makes this and similar analyses useful, particularly of well known speeches/works, is that we all “know” the high points. We have been conditioned to hear those as distinct, when the original hearers/readers were encountering it for the first time.

Such tools can pry us out of the rut of prior analysis. Sometimes.