[VV75] blocking vs non-blocking,  Spring AI, IntelliJ, dev future, exceptions, clean code, OpenTelemetry, GenAI, Jakarta EE 10
[VV75] The Java Fullstack Newsletter, special Java champions

[VV75] blocking vs non-blocking, Spring AI, IntelliJ, dev future, exceptions, clean code, OpenTelemetry, GenAI, Jakarta EE 10

This week, Thursday and Friday was the first week of the Java Champions conference. I assisted in several talks, and here are my notes on some of them.


?? blocking vs non-blocking

https://www.youtube.com/watch?v=Uhba0Aib00M

In this talk, Bazlur Rahman gives intel on virtual threads that empower thread concurrency (you can run millions on thread now).

virtual threads diagram

virtual threads and platform threads

banking teller analogy

  • A teller ?? is like a platform thread ?? because they can only process one customer ?? at a time.
  • A customer ?? is like a task ? that the thread needs to perform.
  • Sometimes, a customer ?? or a task may need some external information or resources ?? before it can be completed. This is called a blocking operation ?? because it blocks the teller ?? [or the platform thread ??] from doing anything else until it is resolved.
  • The teller ?? [or the platform thread ??] can park the customer ?? or the task that is blocked, and move on to the next one in line. This means that the customer ?? or the task is temporarily suspended ??, and will resume ?? when the blocking operation is resolved. This is called a parked virtual thread because it is a virtual thread that is parked by the platform thread ??.
  • By parking the customer ?? or the task, the teller ?? [or the platform thread ??] can process more customers or tasks at the same time, and increase the concurrency. Concurrency is the ability to run multiple tasks at the same time or in parallel.




???? Spring AI

https://www.youtube.com/watch?v=TPY1WYHDNho

In this talk, Craig Walls explains how to use the Spring AI starter to interact with AI (like Open AI) from Spring Boot. Below is a sample of the code to dial with Open AI.

Simplest way:

import org.springframework.ai.chat.ChatClient;

//...

 private final ChatClient chatClient;

 public JokeController(ChatClient chatClient) {
        this.chatClient = chatClient;
}

@GetMapping("/joke")
public JokeResponse tellJoke(@RequestParam("subject") String subject) {
    return chatClient.call("Tell me a joke about "+ subject);
}        

Final version: https://github.com/habuma/spring-ai-essential-examples/blob/main/prompts-and-output-parsers/src/main/java/habuma/springaiessentialexample/JokeController.java




???? IntelliJ

https://www.youtube.com/watch?v=wsCNCMZ6kRQ

In this talk, Anton Arhipov gives tips to strengthen your IntelliJ productivity: for example, postfix completion, and code folding...

  • postfix completion

https://www.vojtechruzicka.com/intellij-idea-tips-tricks-postfix-code-completion/

  • folding with CTRL dot




?? future of dev

https://www.youtube.com/watch?v=xzf-P9UcO8g

In this talk, Holly Cummins presents the evolution of programming and how to feel towards AI in the next years...

1) garbage collection users were more likely to complete the task in the time available, and those who did so required only about a third as much time (4 hours vs. 12 hours)

2) the risk of error is lower as we get low on the stack

3) will AI take our job: NO

?? we switch each time to new ways: transistor networks??machine codes??assembler??high-level languages??librairies??framewroks??ai

and the developer population grew each time??

4) the productivity will be higher




???expect the unexpected

https://www.youtube.com/watch?v=77VE17KrekY

In this talk, Kito Mann guide us in the way to handle exceptions.

1) don't eat your exception; catch it, log it, and tell the user

2) if you can't recover it, don't catch it

3) Throw meaningful exceptions: set a message, use a relevant exception type

4) SpringBoot: ErrorController to centralize exception handling




???? Clean code, really worth it?

https://www.youtube.com/watch?v=GhOWy7x0sp8

In his talk, Jonathan Vila tells us the story of Kleen (a clean developer) who fights Poorqe (the dirty code monster), and how to weaponize us to fight such monsters in our daily work.

1) cost of poor quality code: 2 trillion dollars in the US, 4 days a month by developer on fixing errors

2) fixing bugs is 607Billion dollars,

3) clean code principles:

  • consistency: formatted, conventional, identifiable
  • adaptability: focused, distinct, modular, tested
  • intentionality: clear, logical, complete, efficient
  • responsibility: lawful, trustworthy, respectful

4) most detected issues:

  • high cognitive complexity
  • unused code not removed
  • remainings TODO
  • raw types
  • use of generic exceptions
  • null handling
  • security issues

5)security: https://cheatsheetseries.owasp.org

https://rules.sonarsource.com

6) Tools: PMD, sonarlint, checkstyle, sonarqube, findbugs

SonarLint and a pre-commit git hook ftw

Code is going to die, after 5 years only 37% of old code remains, so do not remove all today but clean as you walk!



?? Observability with OpenTelemetry

https://www.youtube.com/watch?v=LcmMZ8PX_y0

In this talk, Christopher Judd shows us how observability is done with Opentelemetry and how to face the challenge of distributed tracing.

1) short name: o11y

2) idea: like a doctor checking external signals to understand internal issues

3) Twitter pillars: monitoring, alerting/Visualization, Distributed Systems Tracing Infrastructure, Log Aggregation/Analytics

4) telemetry definition: get remotely information from equipment

5) opentelemetry

  • is not a replacement ??? for your monitoring tools
  • is 100% free ?? and open source ??
  • provides you with metrics, distributed traces, and logs
  • is kind of JDBC as it connects to observability collectors

6) Distributed tracing is done with a correlation id

7) In the demo, I saw the outputs in the spring boot logs, then in a GUI done by Zipkin (which looks like the network tab of the chrome dev console with the horizontal bars)




?? Gen AI

https://www.youtube.com/watch?v=bn9kYb_0Cm8

In her talk, Mary Grygleski explains the history of AI and details how to try out vector search: an efficient manner to make AI.

1) GPT means Generative Pre-Training, it takes prompts and then does pattern matching to output an answer to questions for the prompt

2) Vector search is a way to find related objects that have similar characteristics using machine learning models that detect semantic relationships between objects in an index.

https://www.algolia.com/blog/ai/what-is-vector-search/




? Jakarta EE 10

https://www.youtube.com/watch?v=ak_g7BBZg4g

Josh Juneau shows us the last features of Jakarta EE 10 and how to migrate to this fresh new version.

1) Java SE 17 support, support for Java SE 21 will be in the next version

2) JsonPointer

// change a value
JsonPointer namePointer = Json.createPointer("/name");
JsonString name = Json.createValue("Bill Nye");
jsonStructure = namePointer.replace(jsonStructure, name);
System.out.println(jsonStructure);        

https://blog.devgenius.io/an-intro-to-json-pointer-c83b8a68430e




?? Java champion jokes

?? I asked a Java champion how he became a Java champion, and he said he gave a few classes.

? I asked a Java champion how she was so fast at coding, and she said she had a lot of coffee.

?? I asked a Java champion how tough is it to reach that level, and the champion said it requires to code every day without exceptions.


要查看或添加评论,请登录

Vincent Vauban的更多文章

  • [VV113] The Java 21 Newsletter

    [VV113] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

  • ?? Broken Function Level Authorization – API5:2023 ??

    ?? Broken Function Level Authorization – API5:2023 ??

    I'm kicking off a series of articles on API Security ?? to help us—developers ????????—better understand and implement…

  • [VV112] The Java 21 Newsletter

    [VV112] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

  • FR Les mots sans les maux. ???

    FR Les mots sans les maux. ???

    FR Hier, j’ai eu la chance d’assister à un atelier sur la Communication Non Violente (CNV) avec les superbes people de…

  • ?? Unrestricted Resource Consumption – API4:2023 ??

    ?? Unrestricted Resource Consumption – API4:2023 ??

    I'm kicking off a series of articles on API Security ?? to help us—developers ????????—better understand and implement…

  • ?? Broken Object Property Level Authorization – API3:2023 ??

    ?? Broken Object Property Level Authorization – API3:2023 ??

    I'm kicking off a series of articles on API Security ?? to help us—developers ????????—better understand and implement…

  • [VV111] The Java 21 Newsletter

    [VV111] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

    18 条评论
  • ?? Broken Authentication – API2:2023 ??

    ?? Broken Authentication – API2:2023 ??

    I'm kicking off a series of articles on API Security ?? to help us—developers ????????—better understand and implement…

  • ?? BOLA – The #1 API Security Threat (API1:2023)

    ?? BOLA – The #1 API Security Threat (API1:2023)

    I'm kicking off a series of articles on API Security ?? to help us—developers ??????????—better understand and…

  • [VV110] The Java 21 Newsletter

    [VV110] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

社区洞察

其他会员也浏览了