frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Will We All Go Together When We Go?

https://quillette.com/2026/11/23/will-we-all-go-together-when-we-go-ai-alignment-scott-alexander-...
1•Anon84•2m ago•0 comments

Google DeepMind uses Gemini 4 agents to speed up quantum algorithm by up to 290x

https://deepmind.google/blog/finding-faster-quantum-algorithms-with-agents-and-formal-verification/
1•ComputedCamp995•2m ago•0 comments

Cryptography Incident Review Group

https://cirg.org/
1•heavensteeth•4m ago•0 comments

What Happened to Shareware?

https://deadparrotbbs.com/what-happened-to-shareware/
1•linuxkernal•5m ago•1 comments

Nvdriver: a Rust Nvidia driver with unlocked V100 memory clocks

https://github.com/QuixiAI/nvdriver
1•khalidkhair•7m ago•0 comments

Show HN: Compunity – Local LLM with Monitoring

https://compunity.ai/
1•MasihMinawal•7m ago•0 comments

Usage Is the Bottleneck Now

https://klio.org/vibe-code-usage/
1•mkozlows•11m ago•0 comments

Aschenbrenner's Situational Awareness Tells Investors It Lost 65% in 3rd Quarter

https://www.wsj.com/finance/investing/aschenbrenners-situational-awareness-tells-investors-it-los...
9•vismit2000•18m ago•0 comments

Find files anywhere, updated for 2026

https://amitp.blogspot.com/2026/11/find-files-anywhere-updated-for-2026.html
2•ibobev•21m ago•0 comments

The Cabinet of Keyboard Curiosities

https://www.datagubbe.se/keycurcab/
2•ibobev•23m ago•0 comments

Understanding HTTP Status Codes

https://www.youtube.com/watch?v=xPie3BrQvGw
2•spookily4136•25m ago•0 comments

Buttle Draw

https://neal.fun/battle-draw/
4•lpeancovschi•30m ago•2 comments

Engineers Designed a Mission to One of Jupiter's Icy Moons

https://spectrum.ieee.org/jupiter-europa-clipper-mission-jpl
1•pseudolus•31m ago•0 comments

Flight of the Bug Bots

https://www.science.org/content/article/when-will-insect-size-robots-be-able-fly-beyond-lab
1•gmays•34m ago•0 comments

A printable one-page ladder for chasing unpaid invoices

https://4600859971805.gumroad.com/l/gicui
1•lateinvoice•34m ago•0 comments

Indoor Geolocator – Locate Indoor Photos via OCR, DINOv2, OSM/Wikidata

https://github.com/Ezharjan/indoor-geolocator
1•hekikaf591•35m ago•0 comments

Magi-2: A 480B Frontier Video Generation Model

https://sand.ai/blog/magi-2/
2•gmays•47m ago•0 comments

Verified Garbage: An experimental formally verified cryptography library

https://verified-garbage.dev/posts/announcing-verified-garbage/
2•mkeeter•47m ago•0 comments

Systemd 263-rc1 ships initial Rust code

https://www.phoronix.com/news/systemd-263-rc1
2•Skyfall106•50m ago•1 comments

OpenCode (Rune) desktop client

https://github.com/anomalyco/opencode-rune
1•qainsights•51m ago•0 comments

Just Pick the Smarter Model

https://www.seangoedecke.com/just-pick-the-smarter-model/
2•U1F984•54m ago•1 comments

Show HN: I made Horizontal News, a column-based Hacker News reader

https://hzn.jero.zone
4•jer0me•57m ago•1 comments

Armed neighbor of school tests limits of Montana's lenient gun laws

https://www.washingtonpost.com/nation/2026/11/28/armed-man-patrolling-next-elementary-school-test...
1•mikhael•1h ago•1 comments

Newsavista (news aggregator) now deeply integrates with HN

https://newsavista.com/invite/ASAD68923E
3•cbeach•1h ago•2 comments

Lua as a Query Language

https://remy.wang/blog/lua-ql.html
8•remywang•1h ago•3 comments

Redact Docs: A Tunable, Local PII Scrubber

https://www.rickmanelius.com/p/redact-docs-a-tunable-local-pii-scrubber
2•mooreds•1h ago•0 comments

A World Without Youth: The Economics of a Shrinking World [video]

https://www.youtube.com/watch?v=BVtxv566UCQ
2•mooreds•1h ago•0 comments

The Camera Caps Kenyans Are Paid to Wear While Going About Daily Lives

https://www.tuko.co.ke/people/family/647605-nairobi-mysterious-camera-caps-kenyans-paid-wear-dail...
12•gnabgib•1h ago•2 comments

Hackers are exploiting Africa's digital identities

https://www.economist.com/middle-east-and-africa/2026/11/03/hackers-are-exploiting-africas-digita...
1•mooreds•1h ago•0 comments

ChatGPT plugin: Podcast Search and Transcription

https://chatgpt.com/plugins/plugin_asdk_app_6aecd9304b88819193ae95e7f9bcd92b
2•wenbin•1h ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

1•ramsicandra•1y 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•1y 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•1y 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.