Elektrine lite

← Feed

Cay Horstmann

cayhorstmann@foojay.social

<p>In my copious spare time I write books and develop online courses for beginning and professional programmers.</p>

Posts

  • View post

    Who would have thought—a documentary about Java. Pretty cool. Watch it at https://www.youtube.com/watch?v=ZqGSg4b_cZA

  • View post

    Valhalla has arrived in mainline Java (build 28-ea+10-569): https://jdk.java.net/28/ $ cat Points.java value record Point(double x, double y) { public Point moveBy(double dx, double dy) { return new Point(x + dx, y + dy); } } void main() { var p = new Point(0, 0); for (int i = 0; i &amp;lt; 100_000_000; i++) { p = p.moveBy(Math.random() - 0.5, Math.random() - 0.5); } IO.println(p); } $ java --enable-preview Points.java

  • View post

    1/2 Now that Valhalla is in mainline (https://jdk.java.net/28/), let&amp;#39;s see what it can do: $ cat Ids.java value record Id(int value) {} public class Ids { void main() throws Exception { var ids = new Id[100_000_000]; for (int i = 0; i &amp;lt; ids.length; i++) ids[i] = new Id(i); IO.println(ids); Thread.sleep(10000); } } $ javac --enable-preview --source 28 Ids.java $ java --enable-preview Ids &amp;amp;&amp;amp; (jcmd Ids GC.class_histogram | he...

  • View post

    2/2 Here the histogram: num #instances #bytes class name (module) ------------------------------------------------------- 1: 1 800000016 [LId; 2: 8841 356272 [B (java.base@28-ea) 3: 1732 229232 java.lang.Class (java.base@28-ea) * No individual Id objects * A flat array of Id objects * Why 8 bytes per element? * Each Id is 4 bytes * Another byte for a nullness indicator * And 3 bytes padding Valhalla has arrived

  • View post

    My trip report from JCrete: https://horstmann.com/unblog/2026-08-10/index.html

  • View post

    At Basel One, I will present a workshop on Java for small coding tasks on October 14 and a deep dive into Java streams internals on October 15. This is one of my favorite conferences for networking. Hope to see you there! More at https://baselone.org

  • View post

    Interesting issue about Java Valhalla performance: https://mail.openjdk.org/archives/list/valhalla-dev@openjdk.org/thread/3P5463B2OWURWM4LIMYIQMQOMZCOR6LN, details at this nice blog: https://johan-sjolen.github.io/post/compiler-sympathy/compiler-sympathy

  • View post

    I just got back from the JavaZone conference in Oslo. It was a lot of fun--highly recommended. All videos: https://vimeo.com/javazone My video: https://vimeo.com/1223388783 My slides: https://horstmann.com/presentations/2026/javazone/

  • View post

    After a day of interacting with German web sites, I am reminded of Hanlon&amp;#39;s razor (https://en.wikipedia.org/wiki/Hanlon%27s_razor): &amp;quot;Never attribute to malice that which is adequately explained by stupidity.&amp;quot; Or it&amp;#39;s corollary, Grey&amp;#39;s law: &amp;quot;Any sufficiently advanced incompetence is indistinguishable from malice.&amp;quot;

  • View post

    Why my chagrin with German web sites? In a contact form, I tried to explain a problem with another form of the provider. And typed in their URL. Oh noes. Special characters are not allowed! So I had to spell out https Doppelpunkt Schrägstrich Schrägstrich etc. And I tried to attach the PDF they sent me. It was not to be. File name (their choice, Leuchtenberger Kirchweg47B_20260908_Unser\ Angebot_VK20102356538.pdf) more than 50 characters.

  • View post

    Why not allow special characters and longish file names in a contact form? Making it difficult to do something easy is a German specialty. We call it the Korinthenkacker (raisin shitters). And apparently the IT outsourcing providers support it as a service when bidding on German jobs.

  • View post

    One of my posts in this sequence did not succeed on BlueSky: Invalid app.bsky.feed.post record: grapheme too big (maximum 300, got 443). Raisin shitting is not limited to Germany...

  • View post

    Are you using Anki flashcards? Do you ❤️ its open source awesomeness? If so, consider donating through the app right now. Google is apparently making them remove the donation link in the next update. https://github.com/ankidroid/Anki-Android/issues/21656

  • View post

    On Wednesday October 14 I will present a workshop on using Java for small programming tasks at Basel One (https://baselone.org/#programm). I invite you bring your own tasks, or learn from some of mine. Hope to see some of you there!

  • View post

    On Wednesday 10:20 am I will present &amp;quot;Observing Project Valhalla&amp;quot; at BED-CON in Berlin. The organizers assembled a really interesting program this year: https://bed-con.org/2026/programm. Hope to see some of you there!

  • View post

    My article &amp;quot;Effective Pattern Matching 2026 Edition&amp;quot; is now live at https://javapro.io/2026/03/24/effective-pattern-matching-2026-edition/

  • View post

    Is there any AI software that can watch a boring compliance video (emergency procedures, nondiscrimination, hazard communication, etc.) and answer the multiple choice questions that check for comprehension? Asking for a friend...

  • View post

    I never thought much about hash codes of Java enumeration constants, but https://4comprehension.com/enum-map-serialization/ set me straight. Turns out enum hash codes are not stable, so serializing them as map keys will not work. Remedy: EnumMap!

  • View post

    I just finished my talk at JCON—When Greed is Good: Understanding Java Stream Performance. The title attracted a good crowd. Slides at https://horstmann.com/presentations/2026/jcon/

  • View post

    At JCON, a speaker&amp;#39;s slides had a mysterious reference to &amp;quot;danger to the herd&amp;quot;. My preferred search engine (Kagi) led me to https://www.reddit.com/r/ProgrammerHumor/comments/azubgl/kantega_the_mysterious_life_of_developers/ I had a good laugh at the &amp;quot;cliché developer with a conference t-shirt&amp;quot;. Guilty as charged.

  • View post

    PSA about white space in modern Java. Character::isWhitespace and String::strip are aligned. Stay away from legacy Character::isSpace and String::trim. But the regex &amp;quot;(?U)\\s&amp;quot; differs in eight code points: 28, 29, 30, 31, (Information separator 4...1) pass isWhiteSpace and not \s. Conversely, 133 (Next line), 160 (No-break space ⚠), 8199 (Figure space), 8239 (Narrow no-break space) don&amp;#39;t pass isWhiteSpace but match \s.

  • View post

    I&amp;#39;ve been paying #Kagi for search since it&amp;#39;s worth my time to get results instead of ads and slop. Added benefit: their translate service is fantastic for language learners. Where Google Translate gives the minimum, Kagi goes all out.

  • View post

    Github gives you until April 24 to opt out of using your Copilot interactions for model training. The setting is at the bottom of https://github.com/settings/copilot/features: Allow GitHub to use my data for AI model training.