6 ms·
Java Code Challenge: Shortest Code and Lowest Latency
- norswap 8y agoDoes the winning solution read from a database? Otherwise this is an apple-to-oranges comparison. If it does, the connection code certainly isn't shown.
- minborg 8y agoIt reads from memory, not the database. It is true that querying a database vs. using in-JVM-memory snapshots are not the same. They both have different properties. The case at hand was to analyze immutable data where working with snapshots makes sense. If, on the other hand, the case was to work with data in a highly transactional application, then snapshots make little or no sense.
- tralarpa 8y agoThere is something I don't understand. They say that the winner used Speedment. If I understood the example on github correctly, Speedment also uses SQL internally. So, why is the same query over JDBC so much slower than with Speedment? Could it be that Speedment avoids the nested select and does the calculations of the statistics by itself? Would that mean that I should use Speedment only when the result set is very small? How would the performance look like if the task were to calculate the average film length of 10000 films from a table of 100,000 films?
- minborg 8y agoSpeedment uses in-JVM-memory technology so, once the tables are moved into the JVM, streams are served using content and indexes directly from off-heap RAM.
- ynniv 8y agoI like the idea, but when the winner is calling a 3rd party library it becomes meaningless marketing.
- deleted 8y ago[deleted]
- sk5t 8y agoThis article is probably not worth reading. There's little point in comparing an in-memory Java stream-based approach against JDBC--without even the intellectual honesty to use something like in-memory SQLite.
- fiddlerwoaroof 8y agoI thought this too, but it turns out that the Speedment thing he’s talking about is a ORM
- minborg 8y agoIt would be interesting to do a benchmark between Speedment and in-memory SQLite. I will put that on my list. Thanks for the tip.
- stevoo 8y agoI was trying to understand how this was so much efficient and how did he manage to generate this will so little code. Where was his query retrievals ? Where did those classes magically appear. How did he retrieve the data so fast. Then i read the first line, he is the CTO of Speedment. So he had to add maven dependency to his project generate ton of code, to create his objects, retrieve all them and do the computation in the Speedment optimized functions. So with his goal to use as less code as possible, he had to add third party library that added tons of code that he did not count in the lines of code that was written. Seems a bit like self promotion and unfair to be honest.
- joshstrange 8y agoWow the CTO of Speedment posted a challenge and the "winner" used Speedment? Who would have thought... Also when it comes to code golfing this is a BS experiment. If you don't count the library LOC then I can just create SpeedmentSucksLib that literally just uses the code that "won" and now my solution is 1 line: SpeedmentSucksLib.doTheThing() Also we just are going to ignore import/main class LOC's? Really this is a terrible article and it leaves a bad taste in my mouth re: speedment.
- holtalanm 8y agoyou voiced exactly what I was thinking while reading this article.
- minborg 8y agoYour proposed "solution" is hardly a general solution. The winner used a java.util.stream.Stream class which is a standard Java class. The rules (https://www.speedment.com/code-one/ https://www.speedment.com/code-one/) stated that import/main class rows were not counted. But even if they did, they would impact any solution about the same.
- minborg 8y agoHi all! Nice to see your engagement. I understand your concern about self-promotion but the contest was open and contestants were free to choose any tool, not just Speedment. I have contributed to open-source speedment stream ORM for many years and have now added in-JVM-memory acceleration. I am still curious to see if your guys can come up with something better. Give it a real shoot using whatever you can think of. If you can beat it, I promise to write another article about it. Sounds fair? NB: Setup code adds about 5 extra lines, similar to other tools.