Cover photo
Richard Wooding
Works at Double Eye
Lives in Cape Town, South Africa
32,041 followers|8,552,453 views


Richard Wooding

Shared publicly  - 
Guava APIs obsoleted by JDK7

While Guava doesn't require JDK7, there are a bunch of Guava APIs that have been obsoleted by JDK7. If you're using JDK7, you should prefer the built-in JDK7 APIs over the Guava APIs; at some point, we may remove these APIs from Guava. Here’s a list of obsoleted Guava APIs and their JDK replacements:

-instead of c.g.c.base.Charsets.UTF_8, prefer java.nio.charset.StandardCharsets.UTF_8 (same goes for the other constants in our Charsets class)
-instead of c.g.c.base.Objects.equal(), prefer java.util.Objects.equals()
-instead of c.g.c.base.Objects.hashCode(), prefer java.util.Objects.hash()
-instead of c.g.c.collect.Iterators.emptyIterator(), prefer java.util.Collections.emptyIterator()
-instead of, prefer (same goes for the other compare() methods in our primitive wrapper classes)
-instead of the static factory methods for creating collections (e.g. Lists.newArrayList()), prefer the constructors with the diamond operator (e.g., new ArrayList<>())

JDK8 obsoletes a ton of Guava APIs, so we’re hard at work figuring out what a JDK8-friendly version of Guava will look like!

-+Kurt Alfred Kluever , Guavian
Kevin Clarke's profile photo
Add a comment...

Richard Wooding

Shared publicly  - 
Neurological differences don't necessarily mean impairment
Add a comment...

Richard Wooding

Shared publicly  - 
Software developers increasingly recognize their clout in society
Add a comment...

Richard Wooding

Shared publicly  - 
Why Persistent LinkedHashMaps are cool and how to implement them.

After much (Lisp)ing I finally release my first library for Clojure. 
This is a functional data structure that behaves like a LinkedHasMap (or Set), only it's completely persistent. Great, right? And the performance is comparable to a highly-optimised Hash Array Mapped Tree such the one that Clojure implements in its standard library.

Ok, wait, I probably lost you already. Let's start again.

Step 1) LinkedHashMap:

If you're a Java developer you should know LinkedHashMap very well. 
Not because of what it does wrt HashMap (remembering the insertion order of the keys), but because standard HashMap has a major defect that LinkedHashMap solves with no penalties. In fact every time you iterate through a HashMap the order of the elements is non-deterministic. This means that if you have to reproduce a certain bug given the same data structure and state you can always get different output. This is not only bad, this is pure masochism for no apparent reason. Since LinkedHashMap remembers the insertion order its iteration is deterministic and you should always prefer this to the standard HashMap.

Leaving these defects aside, you probably want to use LinkedHashMap for things like code generation/manipulation, data transmission (if I send you something in a certain order I expect that in the same order), ordered subcribers/receivers and so forth. It uses so little more bytes and cpu cycles that using it is a no brainer.

Step 2) Persistent Data Structures:

Think if every time you do "foo" + "bar" instead of getting a new String "foobar" you were actually changing "foo" to become "foobar"
That would make all your programs much, much more complicated. 
Well the same applies for all data structures (after all Strings are just a Vector of Chars).
Every time you modify a collection you should get a new data structure reflecting the change you made, leaving the previous collection unchanged.
Persistent data structures allow you to do this with an efficient implementation (who wants copy on write these days?) so that you can freely share references of all your colections, knowing that nobody can mutate them.
If you're on Java you can try out persistent collections with this great port from Clojure:

Step 3) Implementation details:

LinkedHashMap remembers insertion order by adding two additional pointers to every node stored in the map: previous and next. 
Adding and removing an element it's just a matter of changing a couple of pointers in place because hey! it's all mutable state here. Ordering works just like LinkedList works.

If we want a persistent data structure we can't have mutability and we must create a node with updated pointers. But if the pointers are referring to other nodes when we create a new node all the nodes that were referring to it also need to be updated.
And that goes on and on until you basically implemented an inefficient copy on write structure.
What to do then?

There exist already a couple of implementations of a persistent sorted map:

- Clojure internally uses an array-map which is just an array of key-values that implements the Map interface. This is efficient for very small maps, but as soon as you try to modify it it turns into a standard has-map.
- Another implementation of ordered map uses a backing vector to redundantly store the key-value pairs. Every time you add a new element you grow the vector (which is efficient in Clojure) and save the index of the element inside the backing map. Every time you remove an element you fill the vector position with a nil. This is a reasonably fast implementation but has the potential of eating up all the space if you never remove all those nil references.

Step 4) Solution:

In literature you find plenty of functional data structures that may suggest you a smart implementation: zippers, finger-trees, functional graphs etc. But surprisingly there is a very simple and efficient solution to this problem.

You can do exactly what a LinkedHashMap does, only instead of storing references to other nodes, you store references to the keys of those nodes.
If your map entry looks like [key value left-key right-key] every time you remove an element in the list you just need to update the left an right node to point at each other's key, skipping the node in the middle.

So instead of a simple query + remove you're actually doing 3 queries, 1 remove and 2 adds. But since it's a map all those operations work on constant time.

There are other small optimisations such as promoting the head and the tail of the list as class members so you perform faster insertion and faster deletion at the extremities.

If code with lots of parens does not discourage you have a look at the Clojure implementation here:

All summed up this implementation has the same Big O complexity of a persistent hash map and an effective complexity of about 2.5 times slower, which is great.
I already see a potential application for a REPL as an immutable map where you can undo and redo evaluations effortlessly. But that's for another post.
Add a comment...

Richard Wooding

Shared publicly  - 
Ri Snyman's profile photo
Why, did Google buy shares in a big optometrist company? :-/
Add a comment...
In his circles
3,379 people
Have him in circles
32,041 people
At The Galileo
Open Air Cinema


Watching: The Big Lebowski
Paul Suprono Jr's profile photo
That time, that season has come for some valued exterior entertainment !
Add a comment...

Richard Wooding

Shared publicly  - 
Add a comment...
Today we’re launching Google Camera, a new app for your Android phone or tablet that makes it easy to take quick photos and videos. And being behind the lens just got more fun with new creative picture modes.

Sleek Design. The 100% viewfinder gets out of your way while capturing the maximum resolution of the scene (no dropped pixels). And the extra large capture button is easy to press so your eyes never lose sight of the subject.

Lens Blur. Emphasize the subject while blurring the background for an SLR-like shot with shallow depth-of-field (or bokeh). You can even change the subject in focus after taking the shot.

Improved Panorama. New higher resolution panoramas capture the full width and detail of a scene.

Photo Sphere. Immersive 360 degree photo spheres let you look up, down and all at up to 50 megapixels! For the first time available on non-Nexus devices.

Google Camera is now available on the Play store (, and works on all phones and tablets running Android 4.4+ KitKat. We’re just getting started, and in the months ahead we'll make Google Camera available to more devices, helping make photography easier, faster and more fun.

Check out our Research Blog to learn more (
Rantho Morule's profile photo
Add a comment...
This works nicely, justed tested.

Thanks for sharing +Kyle Salewski +JR Raphael 
Chrome Remote Desktop now in Google Play for Android. Sweet!
Securely access your computers from your Android device.• On each of your c...
Add a comment...
In his circles
3,379 people
Have him in circles
32,041 people
Lead Software Architect
  • Double Eye
    Lead Software Architect, present
  • Moonlight 42
    Senior Software Developer
  • Camara Consulting
    Senior Software Developer
Basic Information
Apps with Google+ Sign-in
Software Developer from Cape Town. Liberal.
I develop software. I tweet about technology, food, software development, mobile, android, ios, apple, cape town and much more. Liberal.
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Cape Town, South Africa
Plettenberg Bay, South Africa - Port Elizabeth, South Africa
Richard Wooding's +1's are the things they like, agree with, or want to recommend.
Masha du Toit - Google+ - Day One of #fivedayquest Reading a Georgette H...

Day One of #fivedayquest Reading a Georgette Heyer in a spot of Autumn sun, with my reading support team :) I'm supposed to tag somebody so.

Richard Wooding - Google+

Works at Double Eye as Lead Software Architect. Lives in Cape Town, South Africa. Software Developer from Cape Town. Liberal.

Plex for Android

Plex organizes all of your personal media, wherever you keep it, so you can enjoy it on any device. With Plex, you can easily stream your vi

GamingCast (for Chromecast)

The first mobile gaming console using ChromeCast!Play retro games on your TV screen with your mobile device as the controller.## This applic

Tables Data Dictionary Views

View, Description. DBA_TABLES. ALL_TABLES. USER_TABLES. DBA view describes all relational tables in the database. ALL view describes all tab

Save Plett | Stop the small boat harbour development in Plettenberg Bay

Say NO to the Boat Harbour development .An organisation called the Save Plett Alliance was formed to oppose this development. It was initiat

Francisco Perez

Works at Riba Smith. Lives in Panama. Attends umecit.

Friends of Felines Rescue Center kitty cam

Friends of Felines Rescue Center 24/7 Kitty Cam. @ Ustream.TV: The kittycam is a 24/7 view into the rescue center and the lives of the kitte

Booing and heckling of leaders appears to be ANC culture as recently hap...

Nelson Mandela’s passing has made many South Africans, including ANC members, realise that we deserve better than Jacob Zuma, says Cameron M

Plex for PlexPass

A preview release of the Plex app for PlexPass subscribers. See for more details. Please do not dow

Penis News

Your number one source for penis related news.

Dressing for the Holidays: Your 60 Second Guide

This post is brought to you by State Farm. For more help, visit State Farm Nation. Inspiration on what to wear this holiday season.

Google Voice Search Hotword (Beta)

This extension allows you to say ‘Ok Google’ and start speaking your search.

De Waal Park

De Waal Park hasn't shared anything on this page with you.

Plussers Against Child Exploitation

See Something, Say Something ~ Protect our children

Truth Coffee

We Roast Coffee. Properly


Chic and elegant range of beanbags available from Chillaxx

Boing Boing

A directory of wonderful things:

On Internet Trolls and Sifting Through the Vomit

What I’ve discovered over the past three months since I started Disco Pants is that there are two kinds of people who comment on your blog –

Amazingly well maintained public park. It is dog friendly and it's the place where everybody in the surrounding suburbs walks their dogs. It has picnic tables, children's play facilities, a Victorian fountain. Generally speaking a great place to visit. In Summer they have free music concerts every second Sunday.
Public - a month ago
reviewed a month ago
I enjoyed the Tapas.
Public - a year ago
reviewed a year ago
I really love Den Anker, one of the best places to have Belgium Beers in Cape Town.
Public - a year ago
reviewed a year ago
Fashionable, Faux Classy, Arrogant staff. You can do much better if you want sushi in Cape Town.
Public - a year ago
reviewed a year ago
7 reviews
I always enjoy my meals at Five Flies, but a bit over-priced.
Public - a year ago
reviewed a year ago
Marvelous fine dining.
Public - a year ago
reviewed a year ago
Very over priced, very poor service, they got our order wrong and then where rude about it. And I don't think it's open any more, after my last trip to Waterfront.
Public - a year ago
reviewed a year ago