Posts

Exercise to understand double.

Many developers fell like double' rounding and representation errors and random errors which are wild and uncontrollable.   This exercise is intended to help understand what double is really doing. Write a method to convert double into text in a direct ByteBuffer which starts public static void append(ByteBuffer bb, double d) {     long val = Double.doubleToRawLongBits(d);     int sign = (int) (val >>> 63);     int exp = (int) ((val >>> 52) & 2047);     long mantissa = val & ((1L << 52) - 1); The goal is to write +/- 0.0001 to 100000.0 using no objects or double, just integer arithmetic.  Values outside this range can use BigDecimal or Double as a fall back. Implement this to convert to text the actual representation of the double, just as new BigDecimal(double) does. (Write a test which compares the values) e.g. 0.1d prints as  0.100000000000000005551115123125782702...

Presentation on; Using BigDecimal and double

There will be a presentation for the Performance Java User's Group given at two times in June.  Both are about using BigDecimal and double together, comparing accuracy and performance.  A focus will be on use in trading systems. The first presentation will be early in Europe and late in Asia on  Saturday June 1st The second one will be late in Europe and early on the west cost of the US. Sunday June 9th Presentations I have given on-line are available at PerformanceJUG/Presentations

First talk posted online

This talk was given a Skills Matter in London and the first talk I have given which I felt happy with.  Practice is a good thing. ;) http://skillsmatter.com/podcast/home/lightning-talks-4195/mh7167 I have giving a talk with similar content on Sat 18th virtually. https://plus.google.com/u/1/events/ca3md83ss9u6injfau00qv879n8 Bring your questions or you can post them on the Chronicle User's Group https://groups.google.com/forum/?fromgroups#!forum/java-chronicle

Is it better to use immutable or mutable values in multi-threaded systems

@martypitt asked an interesting question which I think deserved it's own post. Most of the articles I've read of yours focus on concurrency and/or high performance. Most books I've read on concurrency espouse the benefits of immutability. If you have data shared between threads, it is a lot easier to write and debug if the data uses immutable values. i.e. you might have a mutable collection, or queue, but the data you hold in it is immutable. This is where Date could be a problem as it is mutable though it is rarely used this way. It can be treated as immutable, not by good design but by the fact most people don't use the setTime() method. Mutliple Actors My preference is to use the actor pattern and have a series of single threaded "engines" which send messages to each other via systems such as Chronicle. In this model, each thread has most data local to a thread and mutable. The benefit of using mutable state is the code is simpler (you are effect...

A very interesting expert panel

This expert panel on the Future of the JVM includes Cliff Click, Charlie Hunt and Doug Lea. A number of interesting questions are asked and while I agree the points raised, I am reminded of something I state often; usually simplicity and maintainability is more important than performance. Q: struct , do we need them? The general discussion is broadly in favour of them but Cliff Click raises the point that the performance issue may be solved in the next five to seven years. My point of view:  The real value of structs is the ability to define types efficiently. e.g. instead of using String for a "name", an long for an "account id", a BigDecimal for a "price", you can define structs of those types and use those types in methods and classes without worrying about performance or overhead. Instead of  Map > map = ... public Double update(String name, long accountId, double price) you can write Map > map = ... public Pric...

Performance Java User's Group (redo)

The first Performance Java User's Group was a good start, but there were some technical issues and suggestions on how it could be done better. For those who couldn't make it, especially those in Asian time zones, a revised presentation will be given on Saturday the 18th at 12:00 GMT which is 8 AM in New York, 1 PM in London and 10 PM in Sydney/Melbourne. The first meeting was originally titled an "Introduction to Memory Regions in Java" however all but one question was about Chronicle, so this presentation will focus more on Java Chronicle, where it came from and it's uses. The event details; Performance Java User's Group The presentation can be downloaded here Introduction to Chronicle (:  BTW: The Vanilla Java blog, is now getting 120K page views per month (including mirrors)  :)

First Performance Java User's Group meeting

This meeting will be online on Saturday May 4th at 7 PM (GMT+1) For more details https://plus.google.com/u/1/events/cb9kh2vpk4tpvsqfcqj9oq80nec I considered using Google hangout, but it has a limit of 9. GoToMeeting has a limit of 200. There will be a short lightening talk and an open question session. There is a longer meeting planned for Saturday June 1st, 7 PM (GMT+1) however I received a lot of feedback wanting a meeting sooner rather than later.