frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

The Terraform.applying Symbol

https://developer.hashicorp.com/terraform/language/functions/terraform-applying
1•mooreds•20s ago•0 comments

Show HN: Which public repos are friendliest to an AI coding agent?

https://www.agentfriendlycode.com/
1•hsnice16•7m ago•0 comments

Tech layoffs skyrocketed in Q1 2026

https://twitter.com/KobeissiLetter/status/2050630474129719568
1•enraged_camel•9m ago•0 comments

Does Calvin still hurt in practice if you only use it for cross-shard writes?

https://github.com/nodedb-lab/nodedb
1•fs90•9m ago•0 comments

Italian Competition Authority Launches Investigation into Vorwerk (Neato)

https://en.agcm.it/en/media/press-releases/2026/4/PS13069
1•rettichschnidi•14m ago•0 comments

Kids promised 'forever homes' instead confined in for-profit institutions

https://www.ap.org/news-highlights/spotlights/2026/adopted-and-locked-away-kids-promised-forever-...
1•mnky9800n•14m ago•1 comments

Study: AI models that consider user's feeling are more likely to make errors

https://arstechnica.com/ai/2026/05/study-ai-models-that-consider-users-feeling-are-more-likely-to...
1•Brajeshwar•15m ago•0 comments

Canonical Under Attack

https://status.canonical.com
5•ta988•17m ago•0 comments

Linter for data science and statistical experiments

https://github.com/zgornel/DataLinter
1•zg0rnel•21m ago•1 comments

The best AI dictation apps, tested and ranked

https://techcrunch.com/2026/05/02/the-best-ai-powered-dictation-apps-of-2025/
1•oguzhaneksi•24m ago•0 comments

Ask HN: How long do you commute by car each day?

2•roschdal•25m ago•3 comments

LLMs can hide text in other text of the same length

https://arxiv.org/abs/2510.20075
2•m-hodges•27m ago•0 comments

Pitney Bowes Data Breach (April 2026)

https://haveibeenpwned.com/Breach/PitneyBowes
1•gnabgib•28m ago•0 comments

A Note on TurboQuant and the Earlier Eden Work

https://arxiv.org/abs/2604.18555
2•amitport•28m ago•0 comments

Outline of Thought

https://en.wikipedia.org/wiki/Outline_of_thought
1•cainxinth•29m ago•0 comments

The Dunning-Kruger effect is probably just from bimodal skill distributions

https://bosoncutter.substack.com/p/the-dunning-kruger-effect-is-probably
4•the_tyger•35m ago•4 comments

So, About That AI Bubble

https://www.theatlantic.com/economy/2026/05/ai-bubble-revenue-anthropic/687022/
3•saikatsg•35m ago•0 comments

Show HN: A Universal Stability Criterion for Symbolic Complex Systems

https://zenodo.org/records/18883274
1•M_Samir333•37m ago•1 comments

From toroids to helical tubules: Kirigami-inspired programmable assembly

https://www.pnas.org/doi/10.1073/pnas.2516695122
3•bryanrasmussen•39m ago•1 comments

Show HN: Rust library for Undo/Redo using deltas, snapshots or commands

https://github.com/mikwielgus/undoredo
2•mikolajw•39m ago•1 comments

Privacy Dependencies (2020)

https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3447384
1•wslh•40m ago•0 comments

Show HN: Sentient OS – On-device intelligence layer for your entire digital life

https://sentient-os.ai
2•TechExpert2910•40m ago•2 comments

Unsigned Sizes: A Five Year Mistake

https://c3-lang.org/blog/unsigned-sizes-a-five-year-mistake/
14•lerno•41m ago•5 comments

Forgiving can improve well-being

https://news.harvard.edu/gazette/story/2026/04/how-forgiving-can-improve-well-being/
1•gnabgib•43m ago•0 comments

Show HN: Native agent runtime for Conductor OSS

https://github.com/agentspan-ai/agentspan
1•opiniateddev•43m ago•0 comments

Ask HN: Where can I go to ask for help?

6•downbad_•44m ago•1 comments

Oscars says AI actors and writing cannot win awards

https://www.bbc.com/news/articles/cx21dl3v7d3o
3•Brajeshwar•46m ago•0 comments

Simplebanking: German open-source banking in your Mac menu bar (with CLI/MCP)

https://www.simplebanking.de
1•klotzbrocken•47m ago•0 comments

Tenacity: Cross-platform multi-track audio editor

https://codeberg.org/tenacityteam/tenacity
1•saikatsg•49m ago•0 comments

Show HN: Vim and centaur chess inspired app, where you choose from top moves

https://chess-cheaters.vercel.app/
1•lackoftactics•52m ago•0 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.