Discover and read the best of Twitter Threads about #Java

Most recents (24)

Learning #Java is a never-ending story for me: I just learned about " double-brace initialization", which creates an anonymous class derived from the specified class (the outer braces), and provides an initialiser block within that class (the inner braces). e.g. 👇
For example, this code:
List<Integer> l = new ArrayList<>();
l.add(1);
l.add(2);

May look like:
new ArrayList<Integer>() {{
add(1);
add(2);
}};
Or it may look like constructor with named parameters:

public class User {
String name;
String surname;
String email;
}

User user = new User() {{
name = "John";
surname = "Doe";
}};
Read 6 tweets
#Java performance comparison.

Today I decided to check the performance of different ways of converting an int variable to a String object in Java. 🧵👇
I searched on Stackoverflow:
📍Integer.toString(i)
📍"" +i
📍String.valueOf(i)
📍new StringBuilder().append(i).toString() - a bit strange way, but it was one of the suggestions😄

I have implemented 4 benchmarks using the JMH framework (see pictures).

Results 👇
✅Integer.toString(i) - 43.424 29.721 ns/op
✅"" +i - 27.870 ns/op
✅String.valueOf(i) - 28.371 ns/op
❌new StringBuilder().append(i).toString() - ns/op

Just don't use StringBuilder approach. Other approaches are for your taste. but I personally prefer: String.valurOf(i).
Read 4 tweets
⚠️#Java performance comparison⚠️

I decided to compare the performance of different collection iteration options. In particular:
📍 for loop
📍enhanced for loop
📍for loop with an Iterator
📍stream

Details🧵👇
To test it, I have implemented 4 Benchmark methods, each iterating through list of positive integers and checking them for equality to -1. And at the end of the method, it returns 0 since non was found. In short: Just iterating through the entire collection.
Results:
✅for (Integer i : list) 781 ns/op
✅for (int i = 0; i < listSize; i++) 785 ns/op
✅while (iterator.hasNext()) 788 ns/op
list.stream() ns/op 3256 ns/op 4x slower 😱👀
Read 6 tweets
⚠️#Java performance tip⚠️
Use primitive types instead of wrappers.

Java primitive types:
📍byte
📍short
📍int
📍long
📍float
📍double
📍char
📍boolean

More details and explanation in 🧵👇
To show the difference in performance between primitive and wrapper objects I have created a benchmark which just creates an array of "int" and "Integer" and fills them with an index. Sizes of array: "10", "100", "1000", "10000"

Results: 👇
Array of size 10:
❌ arrayOfWrappers 26.131 ns/op - 2.7x slower
✅ arrayOfPrimitives 9.462 ns/op
Read 8 tweets
#ApacheKafka has integrations with most of the languages used these days.

@alexsotob covers its integration with #Java and discusses how to provision, configure & secure an Apache Kafka cluster on a #Kubernetes cluster: bit.ly/3HN0Tqw

#InfoQ

Series Contents 👇
2/6 ➡️ Apache Kafka is a stream-processing platform for storing, consuming, and processing data streams in real-time. Learn how to produce and consume data using Kafka and Quarkus: bit.ly/3HGby6x

#ApacheKafka #Quarkus #Java
3/6 ➡️ The Kafka Streams project consumes real-time streams of events as they are produced, apply transformations, join streams, etc. Learn how to use Kafka Streams and Quarkus: bit.ly/3RGUbqy

#KafkaStreams #Quarkus #Java
Read 6 tweets
#programming with a fellow #dev can be more productive than you can envision!
medium.com/p/528d555f7846
#Containers provide an unparallel lift for #AI and #MachineLearning
medium.com/p/37675980b4d
Read 12 tweets
⚠️#Java performance tip⚠️

Don't use "+" for string concatenation. Use StringBuilder or StringBuffer instead.
I have created a benchmark to compare the speed of StringBuilder, StringBuffer and "+" concatenation for 2, 3, 5, 10, 50, and 100 strings.
Details in 🧵👇
The scenario is simple:
s/sb = ""/new StringBuffer/Builder();
for (int i = 0; i < size; i++) {
s+=i;/sb.append(i);
}
return sb.toString();

size = 2, 3, 5, 10, 50, and 100

Size hundred produced super strange result, which I can't explain yet. 😕
Concat 2 strings:
❎ s+= i; 25.528 ns/op ~15% slower
✅ stringBuilder.append(i); 21.265 ns/op
✅ stringBuffer.append(i); 21.251 ns/op

The difference is slight, so it is up to you to decide what to use. However, if you want the lowest latency, go with StringBuilder.
Read 11 tweets
#Java performance Tip: `parallelStream()` is way slower than regular `stream()` on small amount of data. I have created a simple benchmark and run it on my 8-CPU laptop. The difference is 160x for some cases. 😲

Details 🧵 👇
👷The setup is to run the same code for streams of 10, 1000, 10_000, 100_000, and 1000_000 items long in standard and parallel modes:
list.stream()
.filter(i -> i == -1)
.findAny()
.orElse(0);
10 items stream:
✅stream()
❌parallelStream() 161x SLOWER ‼️
Read 10 tweets
#Java performance Tip: When need to copy items from one array to anoyther one, don't use loops. Use the more efficient Arrays.copyOf or System.arraycopy method instead.

Performance test details in 🧵👇
Given:
☕ int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};

❌ int[] arr2 = new int[30];
for (int i = 0; i < arr.length; i++) {
arr2[i] = arr[i];
}
✅ int[] arr2 = new int[30];
System.arraycopy(arr, 0, arr2, 0, arr.length);

~25% faster ⚡
Read 6 tweets
Cuando eres #programador #junior, una de las cosas más difíciles a superar de un proceso de selección son las #pruebastecnicas 💻En este HILO 🧵te voy a dejar 5⃣ recursos GRATIS 🔝🔝 para que puedas superar las pruebas técnicas de nivel junior con más facilidad ⬇️⬇️⬇️ #it
En este vídeo de @powerhdeleon de 2⃣0⃣ minutos tienes 5⃣ de las pruebas técnicas más comunes planteadas para #programadores #junior resueltas 🔥🔥 #informatica #software #it
En este vídeo de 1⃣5⃣ minutos del gran @MoureDev tienes 6⃣ pruebas técnicas de las más comunes planteadas para #programadores #junior resueltas 🔥🔥 #informatica #software #it
Read 7 tweets
#Videos de #ejercicios para aprender #POO con #Java.

🧵
Libro

Un vídeo algo antiguo pero efectivo para empezar con POO.

Ecuación 2 grado

Un vídeo mas completo que el anterior.

Read 9 tweets
🧵Everything you might have missed in #Java in 2022

⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️
1. The unclear licensing model has been the most significant barrier to GraalVM adoption for years. However, at @JavaOne 2022, it was announced that @Oracle will make the GraalVM CE a part of the OpenJDK. Project Galahad has been set up to carry out the process - ❤️ that name.
2. @Google announced that it was joining the @adoptium working group as a Strategic Member. Google didn't just limit itself to throwing piles of 💰 at JDK, but together with @AlibabaGroup began working on Java Class Pre-Initialization to accelerate the cold start of applications.
Read 22 tweets
cool was my job 10 years ago.
#nosql? we used the largest transactional database on planet: @objectivitydb CAP: #ACID or #BASE ? BOTH!
#Java? #Microservices, SaaS, PaaS, for German and European EDIfact, FTAM, ATLAS,#NCTS, #AES,... Toll/ Duane before #RodJohnson, #GavinKing...
... invented @springframework and #ORM and #EricEvans #DDD ... new names for the same Things?
No! #DevOps are more than just #SysAdmins who develop with a script language hopefully #python and
... and #PlatformEngineers are more than magic PowerPoint2Java Compiler or SoftwareDevs who are Application Managers for a handfull hours per week or the 2nd Level Firepissung Support Unit.
Read 6 tweets
Here are 3 programs training 100 ppl to become a Software Engineers, Quality Assurance Testers & Data Analysts in the next 14-16 weeks. + offering roles paying avg salaries upwards of $100K+ 🧵
Shipt is giving 20, $13K Scholarships for a Software Engineering bootcamp!🎉hackbrightacademy.com/shipt/
🎉Mentors
➡ US citizens/Perm
💻Remote
📆Apply by Jan 23, Starts Feb 27
🐍Gain #SoftwareEngineering skills in 14 weeks
💰Job Interviews

#womenwhocode #blacktechtwitter #codenewbie
Perficient is giving 40+, $13K Scholarships for Software Engineering, Quality Assurance & Data Analyst bootcamps!🎉hackbrightacademy.com/perficient/

🎉Mentors
➡ US citizens/Perm resident
💻Remote
📆Apply by Feb 27, Starts Apr 3
💰Job Interview

#womenwhocode #blacktechtwitter #codenewbie
Read 8 tweets
Summary of #Java 8,9,10,11,12,13,14,15,16,17,18,19 features.
All features in a single tweet. #retweet #share #like #follow #bookmark Good know.
Thread 👇
#Java 19 Features:
- Record Patterns
- Linux/RISC-V Port
- Foreign Function & Memory API
- Virtual Threads
- Vector API (Fourth Incubator)
- Pattern Matching for the switch
- Structured Concurrency (Incubator)
#Java 18 Features:
- UTF-8 by Default
- Simple Web Server
- Code Snippets in Java API Doc
- Reimplement Core Reflection with Method Handles
- Vector API
- Internet-Address Resolution SPI
- Foreign Function & Memory API
- Pattern Matching for switch
Read 13 tweets
What is Java 8 lambdas and functional programming?
A thread 🧵👇
Java 8 introduced a number of new features to the language, including lambda expressions, which enable functional programming in Java. But what exactly are lambda expressions and how do they work?
A lambda expression is a short block of code that can be passed around as an argument or returned as a value. It's essentially a function without a name that can be used wherever a function interface is expected.
Read 10 tweets
🧵 Everyone’s chatting about 🤖#ChatGPT. Here are 11 things it can do for #malware analysts, #security researchers, and #reverse engineers. A thread >>👇 🧵
1/13
🙋🏻‍♀️ Learn how to use reverse engineering tools more effectively. Use #openAI chat bot to get rapid interactive help on your reversing tools.
2/13
👾 Teach yourself #assembly language. Ask #ChatGPT to convert high-level code into assembly. #arm #intel little endian big endian #nasm #masm. It knows them all.

3/13
Read 13 tweets
We moved our projects from #Java 11 to #Java 17 almost right after the LTS release. Here is a list of the Top 5 features that I have used and enjoyed for more than a year that may convince you to upgrade your projects. 🧵👇
`
record Point(int x, int y) {}
`

- this all you need to create POJO. No, constructors, getters, setters, etc. Just removed verbosity, which was disliked and criticized by many community members. 📓
Text blocks:
`String text = """
Long
formated
text.
""";
`
My SQL queries and JSON blocks in tests don't look like graveyards with all those `+.` ➕❌
Read 8 tweets
QuPath v0.4.0 is now available!

Download it at qupath.github.io

#opensource #bioimageanalysis #digitalpathology #java #javafx QuPath homepage
There are so many new things that it'll take some days to describe even just the main ones.

For now, I'll start by mentioning a few of the user interface improvements.

QuPath v0.4.0 is more welcoming than previous versions... and a bit more stylish.
In fact, you can even style it in your own unique way if you really want to, thanks to #javafx & css (ideally in a nicer way than in my screenshots).

qupath.readthedocs.io/en/0.4/docs/re… ImageImage
Read 31 tweets
Top 6 #Java testing libraries every Java developer should know about and use 👇
JUnit 5 - unit testing framework for the Java programming language.

junit.org/junit5/
AssertJ by @JoCosti - fluent chaining assertions java library. One of the most powerful and convenient ways to write assertions. It's also included in the @springboot test framework.

assertj.github.io/doc/
Read 12 tweets
1. Math and Statistics
Intro to Statistics - Udacity
🌐 bit.ly/3GMZe5n

Statistics - Udacity
🌐 bit.ly/3VKKzfB

Statistical Learning - Stanford University
🌐 bit.ly/3VqA5Sj
2. Excel
Introduction to MS Excel - Simplilearn
🌐 bit.ly/3u1h1OJ

Microsoft Excel: Online Tutorial for Beginners - Chandoo
🌐 bit.ly/3XzUHJO

Microsoft Excel Tutorial for Beginners - Free Code Camp
🌐 bit.ly/3Vax74G
Read 7 tweets
Vamos con una selección de #ofertas laborales para developers, de la mano de nuestra plataforma de empleo @JobRun_Dev.

¿Será alguno el trabajo de vuestros sueños? 👀 Image
📲 Desarrollador #Android 📲
· Empresa: @Hiberus.
· Rango salarial: 22.000€ - 60.000€.
· Modalidad: Remoto.
jobrun.dev/empresas/hiber…
🍏 Desarrollador #iOS 🍏
· Empresa: @Hiberus.
· Rango salarial: 22.000€ - 60.000€.
· Modalidad: Remoto.
jobrun.dev/empresas/hiber…
Read 6 tweets
ROADMAP para ser BACKEND Developer

¿Queréis un roadmap con RECURSOS GRATUITOS para ser un gran desarrollador BACKEND?

Os dejo 7 recursos totalmente GRATIS para aprender las BASES que cualquier desarrollador BACKEND debe conocer

🧵👇

#backend #code #coding #programming #coding
1️⃣Aprende las BASES DE INTERNET

Antes de empezar a programar, entiende qué es Internet, qué es el protocolo HTTP y cómo funciona un navegador

Aquí tenéis un artículo muy interesante

vox.com/2014/6/16/1807…
2️⃣Frontend básico (HTML y CSS)

⚠️Opcional pero RECOMENDABLE⚠️

Aunque quieras ser desarrollador backend, es importante que conozcas las bases del frontend, es decir: #HTML y #CSS

Tienes el curso de @freeCodeCamp para aprender HTML, CSS y Responsive Web

freecodecamp.org/learn/2022/res…
Read 10 tweets

Related hashtags

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!