frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

FreeBSD Pkgbase Minor Upgrades

https://vermaden.wordpress.com/2026/05/10/freebsd-pkgbase-minor-upgrades/
1•vermaden•1m ago•0 comments

A Framework of Modular Structure – Made Visible Through Representations

https://github.com/A19dammer91/Linear-Diophantine-Representation-Systems-p-1-mod-q-
1•A19dammer91•2m ago•0 comments

Kryptor – Simple, modern, secure file encryption and signing tool

https://www.kryptor.co.uk
2•rickcarlino•8m ago•0 comments

Why Apple Is Launching a Touchscreen MacBook [video]

https://www.youtube.com/watch?v=8zGNeT8fU9Y
1•mgh2•9m ago•0 comments

VBM – a VTT that feels like Saturday night at the game table

https://vbm.games/
2•burtonmiller•19m ago•0 comments

Endo: JavaScript plugin framework with built-in supply chain attack resistance

https://github.com/endojs/endo
2•ignoramous•21m ago•0 comments

In CRHQ, agents don't just reply with text. They ship live HTML artifacts

https://andrej.crhq.ai/artifact/Us0QJs48JGh3dK3uoEDQLw
2•taubek•22m ago•0 comments

Swift bricks to be installed on all new buildings in Scotland

https://www.theguardian.com/environment/2026/jan/28/swift-bricks-to-be-installed-in-all-new-build...
1•bookofjoe•26m ago•0 comments

React-AI-stream – back end-agnostic SSE streaming hook for React

https://github.com/trimooo/react-ai-stream
1•devleoo•37m ago•0 comments

Reducing TTFT by CPUMaxxing Tokenization

https://www.crusoe.ai/resources/blog/reducing-ttft-by-cpumaxxing-tokenization
1•intrepidsoldier•41m ago•0 comments

Kit that converts film to digital

https://www.digitalcameraworld.com/cameras/film-cameras/the-trending-kit-that-converts-film-to-di...
2•Alupis•42m ago•0 comments

Implementation Details of Codex /Goal

https://gist.github.com/patleeman/b1b5768393f9bf2f60865b1defeeb819
1•dnw•42m ago•0 comments

Nocturne Is the Latest Music Player for Gnome to Hit v1.0

https://www.phoronix.com/news/Nocturne-1.0-GNOME-Music
1•Bender•43m ago•0 comments

Canvas Breach Disrupts Schools and Colleges Nationwide

https://krebsonsecurity.com/2026/05/canvas-breach-disrupts-schools-colleges-nationwide/
2•Bender•44m ago•1 comments

Build native desktop and mobile apps with web UI and Zig

https://github.com/vercel-labs/zero-native
1•kindkang2024•47m ago•0 comments

The Las Vegas Sphere Looked Like a Disaster. It's Become a Huge Hit Instead.

https://www.wsj.com/business/media/sphere-vegas-dolan-disaster-hit-fa0e6b17
1•bookofjoe•48m ago•1 comments

Ask HN: Before Open Source took over the server, what was the discourse like?

2•mbgerring•49m ago•0 comments

Trump reportedly plans to fire FDA Commissioner Marty Makary

https://arstechnica.com/health/2026/05/trump-reportedly-plans-to-fire-fda-commissioner-marty-makary/
1•Bender•50m ago•0 comments

Show HN: Countries where you can leave your MacBook at a random coffee shop

https://vouchatlas.com
2•canergl•50m ago•0 comments

Koide Formula for the Down Quarks

https://doi.org/10.1016/j.physletb.2026.140510
1•arivero•53m ago•1 comments

I built an AI to stress-test my thinking

https://mindmilker.com
1•afxuh•58m ago•0 comments

Ryan Cohen, the rebel CEO who disdains corporate America

https://www.ft.com/content/c0023a3e-08ec-44e8-80a6-f9abb343c52e
2•petethomas•1h ago•0 comments

Data center drains 30M gals of water — until residents complained of pressure

https://www.politico.com/news/2026/05/08/georgia-data-centers-water-00909988
11•thehoff•1h ago•5 comments

Hasan Piker Media Tracker

https://hasanabi.m44.cl/
1•abdelhousni•1h ago•1 comments

ToolOps: One Decorator Away from Production-Ready AI Agents

https://github.com/hedimanai-pro/toolops
2•hedimanai•1h ago•1 comments

Instagram DMs Lose End-to-End Encryption Starting Today

https://www.macrumors.com/2026/05/08/instagram-end-to-end-encryption/
4•0in•1h ago•1 comments

After USDA request, Indiana plant biologist locked out of lab by school

https://www.science.org/content/article/after-usda-request-indiana-plant-biologist-locked-out-lab...
3•petethomas•1h ago•0 comments

macOS 26 adoption rate lower than prior macOS versions

https://forums.macrumors.com/threads/tahoe-adoption-rate.2474641/page-2
2•seam_carver•1h ago•0 comments

The Real Story of Troy

https://storica.club/blog/troy-was-real/
1•cemsakarya•1h ago•0 comments

McDonald's is taking away your fountain machine. Burger King not so much.

https://finance.yahoo.com/markets/article/mcdonalds-is-taking-away-your-fountain-machine-burger-k...
2•phyzix5761•1h ago•2 comments
Open in hackernews

Ask HN: Java why put string in a constant?

1•ramsicandra•11mo ago
I'm relatively new to Java. I often notice a pattern where there is a list of constant which value are equal to the name.

  class Constant {
    public static final String ALBUM = "album";
    public static final String NAME = "_name";
    public static final String DISPLAY_NAME = "display-name";
    public static final String SERVICE_NAME_METRIC_NAME_PREFIX = "service_name.metric_name";
  }

Here is a public example of this practice I could find: https://developer.android.com/reference/android/provider/MediaStore.MediaColumns

I could understand that this might help in 2 ways refactoring and typo. This reduces chance of typo because you'll get compile error instead of run-time error if you typo a constant. This might also help in refactoring if you ever wants to change the value. but if may use this android public API example, I don't think it's wise to change a field name ever. If it's decommissioned, it's good to keep it so we don't re-use the field. If it's a new better field available, I think it should have a different name. I maybe making a straw man argument here. Let me know. If it's an internal API where such refactoring might make sense -- I still kind of think internal API should also be backward compatible, replacing a string are not a complicated operation in my opinion.

I see that this practice has a cost. One being that in every class that use this API. You need to add an import. It's also often the const is only used once from my experience.

  import static com.example.MediaFields.NAME;
  import static com.example.MediaFields.DISPLAY_NAME;

  String value = json.getString(NAME);
  String value2 = json.getString(DISPLAY_NAME);
vs

  String value = json.getString("name");
  String value2 = json.getString("display_name");
You write 1 line for declaration plus 2 lines for each class using this API. This is not a big deal in terms of LoC and I'm not an LoC police. However, my sense is the cost outweigh the benefit.

What do you think?

Comments

lanna•11mo ago
You just made TWO typos: "display-name" vs "display_name" and "_name" vs "name", automatically counter-argumenting your point.

It is also for documentation. With the declared constants, we know all possible values. With plain strings, how am I supposed to know which values to use?

The benefits far outweigh the marginal cost.

ramsicandra•11mo ago
The -, _, and leading _ are just variations of white space / separator I have encountered. I think it's possible to document all the allowable values in the Javadoc section of the function that takes in string as their argument.

In the specific android example, I would put it here. Under projection params where it takes in all the Images.Media.* string consts.

https://developer.android.com/reference/android/content/Cont...

Though, if it's a practice of Java Engineer to document allowable enum like string as a constant, then I can say that's a valid argument.