Posts

Showing posts with the label Training

Next-Level Development: Harnessing AI with AIDE

If it’s worth doing by hand, it’s worth automating. Just because not everyone is (yet) a world-class developer; that doesn’t mean we can’t step closer to that expert-level space. In this post, I will introduce AIDE (Artifical Intelligence Development Environment), a powerful workflow that merges AI-driven code generation with a sharp focus on documentation-driven development. With AIDE, I tap into the best of artificial intelligence (AI) while respecting the real human insight needed for domain-specific logic. The result? An environment that streamlines repetitive coding, synchronises requirements, code, and tests, and elevates your engineering game. Here is a practical example of an AIDE on GitHub developed using it’s own AIDE. Introducing AIDE: Merging AI and Documentation-Driven Development AIDE transforms development by combining: Prompt Engineering with AsciiDoc : Clear, structured prompts guide AI to produce accurate, contex...

Unveiling Floating-Point Modulus Surprises in Java

When working with double in Java, floating-point representation errors can accumulate, leading to unexpected behaviour—especially when using the modulus operator. In this article, we'll explore how these errors manifest and why they can cause loops to terminate earlier than anticipated. The Unexpected Loop Termination Consider the following loop: Set<Double> set = new HashSet<>(); for (int i = 0; set.size() < 1000; i++) { double d = i / 10.0; double mod = d % 0.1; if (set.add(mod)) { System.out.printf("i: %,d / 10.0 = %s, with %% 0.1 = %s%n", i, new BigDecimal(d), new BigDecimal(mod)); } } At first glance, this loop should run indefinitely. After all, the modulus of d % 0.1 for multiples of 0.1 should always be zero, right? Surprisingly, this loop completes after 2,243 iterations, having collected 1,000 unique modulus values. How is this possible? The full code is available on GitHub. Understanding Flo...

Exceptional Exception, StackTrace extends Throwable

Exploring Surprising Properties of Extending Throwable in Java In Java, most developers are familiar with extending Exception or Error to create custom exceptions. However, directly extending Throwable can lead to surprising and potentially useful behaviours. In this article, we'll delve into the nuances of extending Throwable and explore practical applications that can enhance debugging and monitoring in Java applications. The example code is available here Extending Throwable At first glance, extending Throwable might seem unusual. Unlike Exception , which is checked, or Error , which is unchecked, Throwable itself can be extended to create a new checked throwable that is neither an exception nor an error. public class MyThrowable extends Throwable { } public static void main(String... args) throws MyThrowable { throw new MyThrowable(); // Must be declared or caught } In this example, MyThrowable is a checked throwable, and the compiler enforces that it mu...

Microservices are about applying a group of Best Practices

Microservices Denial A number of times clients have said; they can’t imagine their organisation using Microservices. I found this surprising as I know those people are using many of the principles of Microservices already. I can understand that they feel no need to join the hype around microservices, but the reality is, like it or not, you are most likely using some of the best practices Microservices advocates. Stages of denial It all seems like hype, we don’t go in for that. Perhaps not all hype, but does it really mean anything. It all sounds pretty familiar. It sounds like what we are doing already. Formally or informally, most likely you have been following some best practices already. Adopting Best Practices. Perhaps you don’t like the name Microservices, and perhaps not all the different things people associate with Microservices are right for your team, your projects. Instead lets consider how do you formalise what you are trying to achi...

StackOverflow Q&A you should read if you program in Java

Overview There are common questions which come up repeatedly in Java.  Even if you know the answer it is worth getting a more thorough understanding of what is happening in these cases. How do I compare Strings? The more general questions is how do I compare the contents of an Object.  What is surprising when you use Java for the first time is that if you have a variable like String str this is a reference to an object, not the object itself.  This means when you use == you are only comparing references. Java has no syntactic sugar to hide this fact so == only compares references, not the contents of references. If you are in any doubt, Java only has primitives and references for data types up to Java 9 (in Java 10 it might value value types) The only other type is void which is only used as a return type. Is Java Pass by Reference or Pass by Value? How do I compare Strings? Why does 128 == 128 return false but 127 == 127 return true? How do I a...

My Bio

I often get asked for my Bio, so in case anyone is too shy to ask, here it is. My Bio - Most answers for Java and JVM on StackOverflow.com (11K+) - "Vanilla Java" blog with four million views and around 300 posts. - Founder of the  Performance Java User's Group , a virtual JUG with 1700+ members. - Architect of Chronicle Software , open source project for high performance, low latency libraries in Java. - Java Champion My LinkedIn page is  https://www.linkedin.com/in/peterlawrey Initial Services Over the last year, the most common way we engage a new client to conduct a one week workshop, even if you have been using Chronicle Software for a while this will be of benefit to you. Over the week the team develops the skeleton of a project of their choice and we look at how Chronicle Software products can help, and how to develop high performance code in Java in general. I am usually booked two months in advance, however we have other staff which can conduct t...

What does Chronicle Software do?

Image
Overview Chronicle Software is about simplifying fast data.  It is a suite of libraries to make it easier to write, monitor and tune data processing systems where performance and scalability are concerned. But its free, how do you make money, through support? We offer premium support . However, we often hear from users for the first time about a year after they have it in production.  Most users find they can support the software themselves.  It is only after a year or so, they have questions or concerns about where to take the product next.  In many cases, it is to a problem we have already solved and they just need to upgrade their software or use a new module we have added. As we don't know who is using most of our software, we can't advise them on how best to use our software and what updates or enhancements they would benefit from. We need users to contact us and ask questions.  We have a free forum , and we respond to 50% of questions in 2 hours...

Team training in Expert Core Java

Overview We have new course material for the second half of this year.  Core Java Training We provide tailored team training for advanced and expert Java Developers at a low cost per head.  Select from the topics below.  We can provide training on site for your organization, world wide. For more details, see the  Core Java Training  web page. Expert Java Development (2-3 days) Working with primitives to save memory and reduce garbage. How to use  double  and  long  safely instead of BigDecimal. How to use collections like Map, Set, ConcurrentMap, NavigableMap, List, Queue, BlockingQueue and Deque effectively. How to use thread pools and fork join. Asynchronous processing and exception handling. How to use Lambdas in Java 8 for lazy evaluation and parallel coding. How to use Plain IO and NIO, files, TCP and UDP. volatile , read/write memory barriers and when you need them. default  methods in Java 8. Using  enum...

Common Java Myths

These are questions which are likely to be too advanced to ask in any interview as they may just put candidates off.  Never the less, they may be work practising in your own time. Myth 1) System.exit(0) prevents finally being called Why does this code     System.setSecurityManager(new SecurityManager() {         @Override         public void checkExit(int status) {             throw new ThreadDeath();         }     });     try {         System.exit(0);     } finally {         System.out.println("In the finally block");     } print In the finally block and why doesn't it print a stack trace? Myth 2) String str = "Hello"; In this code, str is a String object. Unlike C++, all variables are either primitives or references.  variables cannot be objects.  This means ...

Computing units don't have to be confusing

Overview Often programmers will use units in a non standard way and usually you can work out what they meant by context.  Many developers never realise there is inconsistencies is technical material as the difference is small to the amount of error and the difficult of reproducing benchmarks reported. There are times when the difference is so large it does matter and the writer has confused themselves by a lack of understanding which makes your job of trying to work out what they done harder. An array of measures b  = bit. B = byte or 8 bits or 8b g = gram kb = kilobit or 1000 bits. kilo being the scientific prefix for 1000 like kilometer. kB = kilobyte or 1000 bytes, sometimes used for storage kg = kilogram Kb = Kibit =  kibib it or 1024 bytes. KB = KiB =  kibibyte  or 1024 bytes, sometimes used for memory Mb = megabit  = 1000^2 bits or 125 kB. Mb/s is used for network bandwidth. MB = megabyte = 1000^2 bytes, MB/s is u...

Interning in High Frequency Trading systems

I am interested in providing intern-ships developing open source code which can be using in high frequency trading systems as well as systems which need near real time processing.  These libraries should also be useful for applications without strict latency requirements. What I would like to know is how to go about doing this.  I don't have the answer, but if you can provide feed back please let me know. I have created a forum for the OpenHFT project in general.   OpenHFT forum  with a topic for Advice on conducting Intern-ships  , Advice on conducting grants and another for Interest in Joining . If you are interested in seeing what has been done already OpenHFT on GitHub The project includes already Direct access to large (>> 2 GB) off heap memory with thread safe constructs. Low latency (sub micro-second) serialization, persistence and IPC. Thread affinity to minimise jitter. Simple library for compiling and loading generated Java code at...

Update on Writing and Monitoring HFT systems

I gave a presentation to JAX Frankfurt on Thursday which went well with about 50 attending. My public presentations are available on GitHub PerfromanceJUG/Presentations I plan to update my content for JavaOne 2013 as the presentation is very dense,. I plan to cut some of the topics and focus on the aspects which got the audience's interest most. ;) The OpenHFT project is getting closer to its first releases and I will be including mention of these in my presentation.  Chronicle 2.0 in this project appears to be about 3x faster than Chronicle 1.7.  The initial release will be have cut down functionality and you may not be able to switch immediately. My hands on Tutorial on writing and monitoring low latency, high throughput systems in Java.  (3 hours) at JAX London has been split into an afternoon and morning session as the morning session is already full. I hope to be speaking at Devoxx Belgium and W-Jax in Munich.  If so, I might see you there.

Tutorial on writing and monitoring low latency, high throughput systems in Java.

Image
I am providing a three hour tutorial at JAX London this year. In a short presentation similar to the one I will be giving at JavaOne 2013, I will be covering such topics as GC free, lockless coding Low latency coding (less than 10 microseconds ) High throughput (Over 100K request/responses per second on a laptop) Using Chronicle for low latency persistence Using sun.misc.Unsafe Using System.nanoTime() between machines Use cases in finance All using Apache 2.0 open source software. i.e. nothing to buy. About 80% of the time will be hands on examining a demonstration program which you can run on a laptop, lifting the bonnet and learning how to extend it for your purposes. What you should get out of this is to see how being able to log everything you could want changes your architecture and the way you test and monitor your applications in production (in particular its performance) If you are going to JAX London and you want to attend, sign up quick because this sessio...

Simplifying low latency services

Overview Java Chronicle   is a persisted, inter process messaging system which is   very fast  when used in a low level way.  However, if you don't need this extreme speed, there is a couple of simpler ways to use this open source library.  One of these to use Chronicle's distributed collections.  This is very simple to use but rather slower.  This post explores an intermediate solution.  It is fast (sub 10 microsecond 99.9% of the time), ultra low GC, and performs well even if you have burst of data larger than the main memory size. This post continues from Low latency services  and the demo is an implementation of the gateways and processing engine in the diagram. Service by Contract A way to model the service is to have an interface for the methods/requests/events you want to support and another interface for events out of the processing engine.  A demo has been added to demonstrate this approach. Processing E...