What is Hackers' Pub?

Hackers' Pub is a place for software engineers to share their knowledge and experience with each other. It's also an ActivityPub-enabled social network, so you can follow your favorite hackers in the fediverse and get their latest posts in your feed.

Dangerzone: Convert potentially dangerous documents into safe PDFs

Take potentially dangerous PDFs, office documents, or images and convert them to safe PDFs.

⚠️ dangerzone.rocks
:mastodon: @dangerzone

0
0
0
0
0

The obsession with 'overdiagnosis' is a much bigger problem than overdiagnosis itself

open.substack.com/pub/theneuro

The discourse around the 'problem' of 'overdiagnosis' doesn't hold up at all when you consider the actual evidence. Pushing it anyway risks harming so many

0
0
0
0
0
0
0

@tirr티르 저도 서브타이핑 기반인 TS에 상대적으로 쉽게 도입할 기능이 https://github.com/microsoft/TypeScript/issues/13219 이렇게 오랫동안 진행안되는게 불만입니다. 막상 TS 이펙트 라이브러리들은 |로 흉내내서 잘 쓰고 있더라고요. Haskell처럼 대수적 이펙트는 구현할수있지만 서브타이핑 기반은 아닌 언어에선, 서브타이핑 흉내낸다고 타입레벨 차력쇼하고 있는데 맞는 방향인지 모르겠습니다.

0
0
0
0
0
0
0
0

Und nun die Frage an die Politik:

Wenn wir doch alle so mündig sind, warum dürfen wir dann nicht selbst entscheiden, wieviel und welche Art von Werbung wir im täglichen Leben konsumieren wollen?

Wenn die Politik das mit dem "mündigen Bürger" in Hinsicht auf Werbung ernst nehmen würde, dann müsste sie unseren konsequenterweise begrüßen und nicht behindern! 😜

Ansonsten ist es reichlich unlogisch, die "Mündigkeit" zu bemühen.

Denn: wir verbieten niemanden, trotzdem Unmengen von zu sehen. Aber even freiwillig. Die Situation ist ja nicht symmetrisch!

Wir stehen für Entscheidungsfreiheit statt Zwang ...

0

🔥윤석열 즉각 퇴진! 사회대개혁! 범시민대행진(16차)🔥(3/22,토) ✊100만을 넘어 이제 200만이다! ⚡️윤석열 파면을 위한 전국 동시다발 총궐기! 📌일시,장소: 2025년 3월 22일(토) 오후 5시, 광화문 동십자각 📌공식 시민후원: 카카오뱅크 7942-09-53862 심규협(윤석열즉각퇴진•사회대개혁 비상행동) 🎤시민발언신청: yoonout.short.gy/voice ▶️자원봉사자모집신청: yoonout.short.gy/volunteer 🚚많은 시민이 몰릴 것으로 예상되어 푸드트럭 운영이 어렵습니다. 양해부탁드립니다.

[시민발언신청]🎤 윤석열 즉각퇴진·사회대개혁 비상행동(2025)

✅ 별도의 표기가 없는 경우, 시민발언 사전신청은 행사일 전날 오후 12시까지 받습니다. (긴급집회는 당일 낮 12시) ✅ 발언 신청자가 많을 경우 주최측에서 추첨 등의 방식으로 발언자를 선정해 직접 연락드립니다. ‼️ 안내사항 집회 시간이 한정되어 있습니다. 발언은 3분 내(공백 제외 800자 이내)로 미리 준비해주시기 바랍니다. 발언 시 반말 및 비속어를 사용하지 않으며, 여성, 성소수자, 장애인, 청소년, 이주민 등 사회적 소수자와 비인간동물을 차별하거나 배제하는 말을 하지 않습니다. * 예시 (참고하여 발언 내용에서 제외해주세요!) - 장애를 빗대어 ‘눈 먼 장님’, ‘정신적 불구 상태’, 윤석열을 비판하며 ‘정신병자’, ‘지랄’, ‘망상장애 환자’ 등. - 여성에게 '마음도 얼굴만큼 예쁘다', 김건희를 비판하며 'ㅇㅇ년' 등. - 청소년/20대 청년에게 ‘기특하다’, ‘우리 아이’ 등, 윤석열을 비판하며 ‘5살 아이에게 총을 쥐어준 것과 같다’ 등. - 동물을 비하하며 '멧돼지를 쳐죽이자', '미친 돼지 윤석열' 등. - 빈곤을 차별하고 혐오하는 발언 '거지같다' 등. 특정 정당 또는 정치인을 옹호하거나 반복적으로 연호하는 등의 발언과 행위를 삼가주십시오. 발언이 선정되지 않을 수도 있습니다. 발언 선정이 되지 않은 경우 별도의 안내 연락을 드리지는 않고 있습니다. 양해 부탁드립니다. 당일 발언은 @윤석열퇴진행동 유튜브 계정으로 라이브 송출되며, 집회 이후에도 위 계정을 통해 확인할 수 있습니다. 📣 발언 내용, 이렇게 준비해주세요! 윤석열 파면, 내란동조 세력 처벌 등 퇴진 관련 내용이 들어갈 수 있도록 해주세요! 발언자님의 삶과 현 정치 상황이 맞닿은, 생생한 이야기를 환영합니다! (ex. 계엄 이후 일상의 변화, 윤석열 정권에서의 삶의 후퇴 등) 사회대개혁 열망을 담은 발언을 환영합니다. 다만, 시간 제약(3분 내)으로 인해 다양한 주제를 담기보다는 1가지의 주된 주제를 준비해주시면 좋습니다

docs.google.com · Google Docs

0
0

刺客教條暗影者真的是災難級遊戲…
雖然看餐哥精華說刺客教條幻象更慘
但個人感覺幻象>暗影者(目前感受

至於人中之龍6有沒有比這兩個好
我就不知道了XD

人中之龍6還有機會會買來看
那兩個刺客教條是慘到完全不會買😌

0
0
0
0

Britain issues travel warning for US: I have been checking the France Diplomatie pages lately expecting France to do the same but.. nothing so far? Meanwhile people are getting detained at the border randomly.

newsweek.com/britain-issues-tr

0
0
0
0
0
0

If you are in tech, then it is time to unionize.fyi

> The tech industry is a runaway train, and if we don’t do something soon, we’re going to get run over. [..] it’s all going to keep getting worse unless we take a stand. isn’t just a nice idea - it’s a necessity.

> So let’s do what hackers do best: let’s disrupt. [..] Let’s take back our industry, take back our jobs, and take back our futures.

news.ycombinator.com/item?id=4

0

If his daughter can maintain this attitude about Elon, so can you.

“He's a pathetic man-child. Why would I feel scared of him? Ohhh, he has so much power. Nah, nah, nah. I don't give a f**k. Why should I be scared of this man? Because he's rich? Oh, no, I'm trembling. Ooh, shivering in my boots here. I don't give a f**k how much money anyone has. I don't. I really don't. He owns Twitter. Okay. Congratulations.”

teenvogue.com/story/vivian-jen

0
0
0
0
0
0

いいかい若いおじさんおばさん
江戸っ子なら、若いうちに、愛宕神社の石段を降りてみるんだ
出世の石段を昇るだけじゃない、降りるんだ
昇るときも、ひっくり返りそうになって大変だが、降りるときはもっと怖いんだ

0

ときどき日本語チャンネルの「相棒」はもう何度も再放送してるんだけど僕はほとんどプロットを意識的には覚えてないので、たまに無意識に、次にこの証拠が明らかになる!って超能力者気分を味わえる

0

Emelia 👸🏻 shared the below article:

Revisiting Java's Checked Exceptions: An Underappreciated Type Safety Feature

洪 民憙 (Hong Minhee) @hongminhee@hackers.pub

Despite their bad reputation in the Java community, checked exceptions provide superior type safety comparable to Rust's Result<T, E> or Haskell's Either a b—we've been dismissing one of Java's best features all along.

Introduction

Few features in Java have been as consistently criticized as checked exceptions. Modern Java libraries and frameworks often go to great lengths to avoid them. Newer JVM languages like Kotlin have abandoned them entirely. Many experienced Java developers consider them a design mistake.

But what if this conventional wisdom is wrong? What if checked exceptions represent one of Java's most forward-thinking features?

In this post, I'll argue that Java's checked exceptions were ahead of their time, offering many of the same type safety benefits that are now celebrated in languages like Rust and Haskell. Rather than abandoning this feature, we should consider how to improve it to work better with modern Java's features.

Understanding Java's Exception Handling Model

To set the stage, let's review how Java's exception system works:

  • Unchecked exceptions (subclasses of RuntimeException or Error): These don't need to be declared or caught. They typically represent programming errors (NullPointerException, IndexOutOfBoundsException) or unrecoverable conditions (OutOfMemoryError).

  • Checked exceptions (subclasses of Exception but not RuntimeException): These must either be caught with try/catch blocks or declared in the method signature with throws. They represent recoverable conditions that are outside the normal flow of execution (IOException, SQLException).

Here's how this works in practice:

// Checked exception - compiler forces you to handle or declare it
public void readFile(String path) throws IOException {
    Files.readAllLines(Path.of(path));
}

// Unchecked exception - no compiler enforcement
public void processArray(int[] array) {
    int value = array[array.length + 1]; // May throw ArrayIndexOutOfBoundsException
}

The Type Safety Argument for Checked Exceptions

At their core, checked exceptions are a way of encoding potential failure modes into the type system via method signatures. This makes certain failure cases part of the API contract, forcing client code to explicitly handle these cases.

Consider this method signature:

public byte[] readFileContents(String filePath) throws IOException

The throws IOException clause tells us something critical: this method might fail in ways related to IO operations. The compiler ensures you can't simply ignore this fact. You must either:

  1. Handle the exception with a try-catch block
  2. Propagate it by declaring it in your own method signature

This type-level representation of potential failures aligns perfectly with principles of modern type-safe programming.

Automatic Propagation: A Hidden Advantage

One often overlooked advantage of Java's checked exceptions is their automatic propagation. Once you declare a method as throws IOException, any exception that occurs is automatically propagated to the caller without additional syntax.

Compare this with Rust, where you must use the ? operator every time you call a function that returns a Result:

// Rust requires explicit propagation with ? for each call
fn read_and_process(path: &str) -> Result<(), std::io::Error> {
    let content = std::fs::read_to_string(path)?;
    process_content(&content)?;
    Ok(())
}

// Java automatically propagates exceptions once declared
void readAndProcess(String path) throws IOException {
    String content = Files.readString(Path.of(path));
    processContent(content); // If this throws IOException, it's automatically propagated
}

In complex methods with many potential failure points, Java's approach leads to cleaner code by eliminating the need for repetitive error propagation markers.

Modern Parallels: Result Types in Rust and Haskell

The approach of encoding failure possibilities in the type system has been adopted by many modern languages, most notably Rust with its Result<T, E> type and Haskell with its Either a b type.

In Rust:

fn read_file_contents(file_path: &str) -> Result<Vec<u8>, std::io::Error> {
    std::fs::read(file_path)
}

When calling this function, you can't just ignore the potential for errors—you need to handle both the success case and the error case, often using the ? operator or pattern matching.

In Haskell:

readFileContents :: FilePath -> IO (Either IOException ByteString)
readFileContents path = try $ BS.readFile path

Again, the caller must explicitly deal with both possible outcomes.

This is fundamentally the same insight that motivated Java's checked exceptions: make failure handling explicit in the type system.

Valid Criticisms of Checked Exceptions

If checked exceptions are conceptually similar to these widely-praised error handling mechanisms, why have they fallen out of favor? There are several legitimate criticisms:

1. Excessive Boilerplate in the Call Chain

The most common complaint is the boilerplate required when propagating exceptions up the call stack:

void methodA() throws IOException {
    methodB();
}

void methodB() throws IOException {
    methodC();
}

void methodC() throws IOException {
    // Actual code that might throw IOException
}

Every method in the chain must declare the same exception, creating repetitive code. While automatic propagation works well within a method, the explicit declaration in method signatures creates overhead.

2. Poor Integration with Functional Programming

Java 8 introduced lambdas and streams, but checked exceptions don't play well with them:

// Won't compile because map doesn't expect functions that throw checked exceptions
List<String> fileContents = filePaths.stream()
    .map(path -> Files.readString(Path.of(path))) // Throws IOException
    .collect(Collectors.toList());

This forces developers to use awkward workarounds:

List<String> fileContents = filePaths.stream()
    .map(path -> {
        try {
            return Files.readString(Path.of(path));
        } catch (IOException e) {
            throw new UncheckedIOException(e); // Wrap in an unchecked exception
        }
    })
    .collect(Collectors.toList());

3. Interface Evolution Problems

Adding a checked exception to an existing method breaks all implementing classes and calling code. This makes evolving interfaces over time difficult, especially for widely-used libraries and frameworks.

4. Catch-and-Ignore Anti-Pattern

The strictness of checked exceptions can lead to the worst possible outcome—developers simply catching and ignoring exceptions to make the compiler happy:

try {
    // Code that might throw
} catch (Exception e) {
    // Do nothing or just log
}

This is worse than having no exception checking at all because it provides a false sense of security.

Improving Checked Exceptions Without Abandoning Them

Rather than abandoning checked exceptions entirely, Java could enhance the existing system to address these legitimate concerns. Here are some potential improvements that preserve the type safety benefits while addressing the practical problems:

1. Allow lambdas to declare checked exceptions

One of the biggest pain points with checked exceptions today is their incompatibility with functional interfaces. Consider how much cleaner this would be:

// Current approach - forced to handle or wrap exceptions inline
List<String> contents = filePaths.stream()
    .map(path -> {
        try {
            return Files.readString(Path.of(path));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    })
    .collect(Collectors.toList());

// Potential future approach - lambdas can declare exceptions
List<String> contents = filePaths.stream()
    .map((String path) throws IOException -> Files.readString(Path.of(path)))
    .collect(Collectors.toList());

This would require updating functional interfaces to support exception declarations:

@FunctionalInterface
public interface Function<T, R, E extends Exception> {
    R apply(T t) throws E;
}

2. Generic exception types in throws clauses

Another powerful enhancement would be allowing generic type parameters in throws clauses:

public <E extends Exception> void processWithException(Supplier<Void, E> supplier) throws E {
    supplier.get();
}

This would enable much more flexible composition of methods that work with different exception types, bringing some of the flexibility of Rust's Result<T, E> to Java's existing exception system.

3. Better support for exception handling in functional contexts

Unlike Rust which requires the ? operator for error propagation, Java already automatically propagates checked exceptions when declared in the method signature. What Java needs instead is better support for checked exceptions in functional contexts:

// Current approach for handling exceptions in streams
List<String> contents = filePaths.stream()
    .map(path -> {
        try {
            return Files.readString(Path.of(path));
        } catch (IOException e) {
            throw new RuntimeException(e); // Lose type information
        }
    })
    .collect(Collectors.toList());

// Hypothetical improved API
List<String> contents = filePaths.stream()
    .mapThrowing(path -> Files.readString(Path.of(path))) // Preserves checked exception
    .onException(IOException.class, e -> logError(e))
    .collect(Collectors.toList());

4. Integration with Optional<T> and Stream<T> APIs

The standard library could be enhanced to better support operations that might throw checked exceptions:

// Hypothetical API
Optional<String> content = Optional.ofThrowable(() -> Files.readString(Path.of("file.txt")));
content.ifPresentOrElse(
    this::processContent,
    exception -> log.error("Failed to read file", exception)
);

Comparison with Other Languages' Approaches

It's worth examining how other languages have addressed the error handling problem:

Rust's Result<T, E> and ? operator

Rust's approach using Result<T, E> and the ? operator shows how propagation can be made concise while keeping the type safety benefits. The ? operator automatically unwraps a successful result or returns the error to the caller, making propagation more elegant.

However, Rust's approach requires explicit propagation at each step, which can be more verbose than Java's automatic propagation in certain scenarios.

Kotlin's Approach

Kotlin made all exceptions unchecked but provides functional constructs like runCatching that bring back some type safety in a more modern way:

val result = runCatching {
    Files.readString(Path.of("file.txt"))
}

result.fold(
    onSuccess = { content -> processContent(content) },
    onFailure = { exception -> log.error("Failed to read file", exception) }
)

This approach works well with Kotlin's functional programming paradigm but lacks compile-time enforcement.

Scala's Try[T], Either[A, B], and Effect Systems

Scala offers Try[T], Either[A, B], and various effect systems that encode errors in the type system while integrating well with functional programming:

import scala.util.Try

val fileContent: Try[String] = Try {
  Source.fromFile("file.txt").mkString
}

fileContent match {
  case Success(content) => processContent(content)
  case Failure(exception) => log.error("Failed to read file", exception)
}

This approach preserves type safety while fitting well with Scala's functional paradigm.

Conclusion

Java's checked exceptions were a pioneering attempt to bring type safety to error handling. While the implementation has shortcomings, the core concept aligns with modern type-safe approaches to error handling in languages like Rust and Haskell.

Copying Rust's Result<T, E> might seem like the obvious solution, but it would represent a radical departure from Java's established paradigms. Instead, targeted enhancements to the existing checked exceptions system—like allowing lambdas to declare exceptions and supporting generic exception types—could preserve Java's unique approach while addressing its practical limitations.

The beauty of such improvements is that they'd maintain backward compatibility while making checked exceptions work seamlessly with modern Java features like lambdas and streams. They would acknowledge that the core concept of checked exceptions was sound—the problem was in the implementation details and their interaction with newer language features.

So rather than abandoning checked exceptions entirely, perhaps we should recognize them as a forward-thinking feature that was implemented before its time. As Java continues to evolve, we have an opportunity to refine this system rather than replace it.

In the meantime, next time you're tempted to disparage checked exceptions, remember: they're not just an annoying Java quirk—they're an early attempt at the same type safety paradigm that newer languages now implement with much celebration.

What do you think? Could these improvements make checked exceptions viable for modern Java development? Or is it too late to salvage this controversial feature? I'm interested in hearing your thoughts in the comments.

Read more →
0
0
3

転売は権利侵害──日本初の司法判断受け、NFTチケットのチケミーが声明

CoinDesk JAPAN(コインデスク・ジャパン) @coindeskjapan.com@web.brid.gy

転売は権利侵害──日本初の司法判断受け、NFTチケットのチケミーが声明

東京地方裁判所は3月10日、コンサートチケットの転売出品が主催者の営業権を侵害するとの司法判断を下した。 旧ジャニーズ事務所のタレントを引き継いだ「STARTO ...

The post 転売は権利侵害──日本初の司法判断受け、NFTチケットのチケミーが声明 first appeared on CoinDesk JAPAN(コインデスク・ジャパン).

Read more →
0
0
0
0
0
0
0
0

テザー社、2024年の米国債純購入額上位だと発表

CoinDesk JAPAN(コインデスク・ジャパン) @coindeskjapan.com@web.brid.gy

テザー社、2024年の米国債純購入額上位だと発表

最大のステーブルコインであるテザー(USDT)を発行する暗号資産(仮想通貨)企業テザー(Tether)は、2024年の国別の米国債純購入額において7位に位置する ...

The post テザー社、2024年の米国債純購入額上位だと発表 first appeared on CoinDesk JAPAN(コインデスク・ジャパン).

Read more →
0
0
0
0
0
0
0
0
0
0
0
0
0

快新聞/中國監視器改標MIT 安控大廠涉「洗產地」董座百萬交保

股票上市安控大廠「昇銳電子」自中國進口監視器主機及零件,組裝後「洗產地」改標「台灣製」標籤對外販售,涉嫌違反《刑法》商品虛偽標記罪及詐欺取財罪。士林地檢署昨(19)日指揮法務部調查局資安工作站展開搜索,查扣相關證物,江姓董事長複訊後100萬交保。

ftvnews.com.tw/news/detail/202

0
0