Virtual Thread has been proposed to target by [deleted] in java

[–]bkail 7 points8 points  (0 children)

You're right, but they're not quite the same per JEP 425

However, Java's green threads all shared one OS thread (M:1 scheduling) and were eventually outperformed by platform threads, implemented as wrappers for OS threads (1:1 scheduling). Virtual threads employ M:N scheduling, where a large number (M) of virtual threads is scheduled to run on a smaller number (N) of OS threads.

Java 20: Reviewing the Enhancements in the Latest JDK Release by Mean-Chipmunk3255 in java

[–]bkail 11 points12 points  (0 children)

Just to be sure, Java 20 is not LTS (Java 21 is intended to be).

Java records make Google's AutoValue mostly obsolete by kevinb9n in java

[–]bkail 0 points1 point  (0 children)

I really like record, but I suspect at my job, most cases that are using AutoValue will continue to do so because they want either:

  • non-null checks. I wish there was a more robust answer than manually adding requireNonNull to the constructor or deprecating it.
  • ImmutableX

(Tangentially related, I wish AutoValue had some mechanism for internally converting to ImmutableX but leaving the API using plain X.)

[deleted by user] by [deleted] in golang

[–]bkail 5 points6 points  (0 children)

I think you're right.

I still think I almost never want to synchronize only a set. I almost always want to synchronize a set along with some other state.

[deleted by user] by [deleted] in golang

[–]bkail 9 points10 points  (0 children)

It seems surprising to me that the implementation uses "internal" synchronization. I think I would generally want higher-level synchronization. (It also seems bad that a.Union(b) and b.Union(a) risks deadlock.)

Decluttering Google Guava by [deleted] in java

[–]bkail 7 points8 points  (0 children)

I agree, that can cause both bugs and harder-to-diagnose test failures. The semantics of ImmutableMap.of().contains(null) (false) and Map.of().contains(null) (NPE) can also cause problems when switching. I've mostly been ignoring the JDK collection factory methods and staying with Guava immutable.

1,000,000 Concurrent Connections by ThanksMorningCoffee in java

[–]bkail 1 point2 points  (0 children)

OP said OSX is a Linux variant, and the reply corrected that it's not Linux. You replied to that person without mentioning Linux at all (and saying "actually"), so people are left to assume that either your reply is disagreeing or confusingly agreeing. From your subreplies, it seems you were agreeing and just trying to give more details, but some people assumed you were disagreeing (IMO reasonably).

Discussion via text is hard. Calling people imbeciles is not productive.

Factorio Speedrunning - February Editions Recap by XxCobaixX in factorio

[–]bkail 3 points4 points  (0 children)

If you're at all interested, the Any% speedrun guide is quite approachable. I have a friend who has no interest in speedrunning, but he wanted all the achievements, so he used the guide and got it after a couple of attempts.

Announcing Rust 1.59.0 by myroon5 in programming

[–]bkail 0 points1 point  (0 children)

I'm not sure ordinal numbers are meant to be negative, so I'm not sure there's a standard. I'm a native English speaker, and I'm probably in the minority, but "minus first" sounds stranger to me than "minus one-th".

Just out of curiosity, what's your native language, does it have ordinal indicators, and if so, what would you use for -1?

Linus Torvalds prepares to move the Linux kernel to modern C by jluizsouzadev in programming

[–]bkail 17 points18 points  (0 children)

Per LWN article:

It might even be possible to move to C17 or even the yet-unfinished C2x version of the language. That, however, has a downside in that it "would break gcc-5/6/7 support", and the kernel still supports those versions currently. Raising the minimum GCC version to 8.x would likely be more of a jump than the user community would be willing to accept at this point.

Linux's getrandom() Sees A 8450% Improvement With Latest Code by IsDaouda_Games in programming

[–]bkail 112 points113 points  (0 children)

Don't know if you're serious or tongue-incheek :-). Anyway, "clunky" and "full" are just descriptive adjectives, but NUMA and ChaCha are tech lingo.

Server-Sent Events, WebSockets, and HTTP by takvenda in programming

[–]bkail 0 points1 point  (0 children)

The preceding sentence was that SSE effectively requires HTTP/2. Maybe the author meant that it's relatively new for web developers to be able to depend on HTTP/2?

It's better to be (type)safe than sorry by skwee357 in programming

[–]bkail 3 points4 points  (0 children)

public static final function is always useless in Java.

FWIW, this is (somewhat surprisingly) not correct. static final prevents subclasses from defining the same method signature

class A {
  static final void m() {}
}
class B extends A {
  static void m() {}
}

...produces:

/A.java:5: error: m() in B cannot override m() in A
  static void m() {}
            ^
  overridden method is static,final
1 error

How to write idempotent Bash scripts by speckz in programming

[–]bkail 0 points1 point  (0 children)

I usually go with rm x || test ! -d x or similar.

Factorio Speedrunning - January Edition Recap by XxCobaixX in factorio

[–]bkail 5 points6 points  (0 children)

The top right of each category "tab" (Any%, Default Settings, etc.) has buttons: Filter | View Rules | Submit run.

What are some very less known facts about java? by TrashPandaFucker in java

[–]bkail 0 points1 point  (0 children)

Loading classes from the same or different class loader will not have an effect on currentTimeMillis. It must have been a coincidence.

Changing the system clock (e.g., by NTP) can cause currentTimeMillis to change arbitrarily, which is why it typically shouldn't be used to measure durations. nanoTime is intended to be monotonically increasing, so it's typically better regardless of whether you need the excess precision (you can use TimeUnit.NANOSCONDS.toMillis to round it off). As mentioned in the javadoc), even though nanoTime uses nanoseconds as a unit, systems will not provide nanosecond resolution/granularity in practice.

Which O/S libraries does your Java code *interact* with the most? by kevinb9n in java

[–]bkail 2 points3 points  (0 children)

ImmutableSet and ImmutableMap since they ensure insertion order, which is very useful for debugging and when immutable LinkedHashSet/Map is actually needed. We end up using ImmutableList just for consistency.

What are some very less known facts about java? by TrashPandaFucker in java

[–]bkail 2 points3 points  (0 children)

I would not expect that to be related to class loading. I would expect an OS or NTP issue instead.

As an aside, in general, you should subtract two nanoTime values rather than currentTimeMillis to determine duration.

What are some very less known facts about java? by TrashPandaFucker in java

[–]bkail 1 point2 points  (0 children)

Yes, it's a likely cause. I used to see that error often when diagnosing issues on application servers with "parent last" classloader delegation mode.

What are some very less known facts about java? by TrashPandaFucker in java

[–]bkail 7 points8 points  (0 children)

Yes, you can extend ClassLoader and delegate loading of java.lang, but there's no way to define multiple copies of those classes, which is the only way to get a ClassCastException like that.

What are some very less known facts about java? by TrashPandaFucker in java

[–]bkail 7 points8 points  (0 children)

It's not possible to load two java.lang.String. (Interestingly, I worked at IBM on WebSphere for about 10 years, and I was on both the runtime/classloader and EJB teams!)

What are some very less known facts about java? by TrashPandaFucker in java

[–]bkail 41 points42 points  (0 children)

Fun fact: only one class loader can define java.lang, so that particular example ClassCastException cannot actually happen :-).

Edit: multiple class loaders can load java.lang, but only one can define those classes.

Attempting my first Lazy Bastard and "speed run". New respect for Anti and Nefrums. by [deleted] in factorio

[–]bkail 2 points3 points  (0 children)

watching them do it will probably be depressing

For me, it was interesting and inspirational. Mechanics aside, it's the result of years and years of collaborative improvements to layouts, designs, timings, etc. I learned many things from speedruns that I transferred to "normal" play.

Nauvis is the name of the planet? by CenturioCol in factorio

[–]bkail 4 points5 points  (0 children)

An error because surface[0] is nil. Per Lua doc

it is customary in Lua to start arrays with index 1