frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

.gitignore Generator by Codra

https://codra.run/free-tools/gitignore-generator
1•devarshishimpi•1m ago•0 comments

Homelab deployments: a tutorial made of prompts

https://tomjohnell.com/homelab-deployments-a-tutorial-made-of-prompts/
2•tjohnell•2m ago•0 comments

Ask HN: How to prepare for coding/system design interviews on a mobile phone

1•k_dev•4m ago•0 comments

AI Is Making Us Less Human

https://www.theatlantic.com/ideas/2026/09/open-ai-consciousness-morality/688535/
2•paulpauper•5m ago•0 comments

Alzheimer's trial to test drug on people without symptoms to test prevention

https://www.theguardian.com/society/2026/sep/05/alzheimers-trial-drug-dementia
2•borski•6m ago•0 comments

Ask HN: What are your predictions for the rest of 2026?

3•roschdal•8m ago•1 comments

An Alien Mind

https://openai.com/index/an-alien-mind/
2•tosh•8m ago•0 comments

TreasuryDirect is launching a controversial login system

https://tipswatch.com/2026/08/17/treasurydirect-is-launching-a-controversial-login-system/
1•clcaev•8m ago•0 comments

A complex train and logistics simulator running straight in your terminal? Yep

https://avaraujo.itch.io/letrain-procedural-tycoon
2•avaraujo•11m ago•0 comments

Pro Se Litigants in the U.S. Supreme Court: How Do They Fare? (2024) [pdf]

https://prod-i.a.dj.com/public/resources/documents/KylePersaud.pdf
2•Tomte•15m ago•0 comments

I Check the Weather

https://sarah-robin.com/blog/how-i-actually-check-the-weather
3•sarah-robiin•15m ago•0 comments

Hot Chips 2026: Irrational Recap

https://irrationalanalysis.substack.com/p/hot-chips-2026-irrational-recap
1•zdw•15m ago•0 comments

Distribution of Household Wealth in the U.S. since 1989

https://www.federalreserve.gov/releases/z1/dataviz/dfa/distribute/chart/#quarter:146;series:Net%2...
2•loughnane•17m ago•0 comments

AI agents aren't safe from prompt injection, and spreadsheets prove it

https://shiftmag.dev/ai-agents-arent-safe-from-prompt-injection-and-spreadsheets-prove-it-11609/
3•taubek•17m ago•0 comments

IBM_phoenix

https://quantum.cloud.ibm.com/computers?system=ibm_phoenix
2•Bluestein•18m ago•0 comments

'Twilight of the Dons' Review: The Prestige of the Professors

https://www.wsj.com/arts-culture/books/twilight-of-the-dons-review-the-prestige-of-the-professors...
1•pepys•19m ago•0 comments

The AI Account Reseller Ecosystem

https://vectoral.com/blog/ai-account-reseller-ecosystem
2•mlenhard•20m ago•0 comments

Research carried out using NetBSD

https://www.netbsd.org/gallery/research.html
5•Bluestein•25m ago•0 comments

The Tokens That Made Me Rethink Everything

https://cacm.acm.org/blogcacm/the-tokens-that-made-me-rethink-everything/
2•visha1v•27m ago•0 comments

When did French fries become the standard side to serve with a hamburger?

https://www.reddit.com/r/AskHistorians/comments/39v00a/comment/cs72af6/
6•thunderbong•27m ago•0 comments

Leverage Code Review for Sustainable AI Coding Development

https://cacm.acm.org/news/leverage-code-review-for-sustainable-ai-coding-development/
1•visha1v•28m ago•0 comments

Tumbler Ridge Shooting Survivors File 30 Lawsuits Against OpenAI

https://www.nytimes.com/2026/09/04/world/canada/openai-lawsuits-tumbler-ridge-shooting.html
2•sbulaev•28m ago•0 comments

Cash or Comfort? How LLMs Value Your Inconvenience

https://cacm.acm.org/research/cash-or-comfort-how-llms-value-your-inconvenience/
2•visha1v•28m ago•0 comments

The Coming Merging of Mind and Machine (2001)

https://www.thekurzweillibrary.com/the-coming-merging-of-mind-and-machine
2•vinhnx•30m ago•0 comments

Mdmanager.ai – Manage your Claude.md and AGENTS.md across machines and runtimes

https://github.com/manuelschipper/mdmanager
3•schipperai•31m ago•2 comments

Cultivating Trust

https://kaeruct.github.io/posts/2026/09/06/conquering-entropy-cultivating-trust/
3•kaeruct•32m ago•1 comments

Two party systems and the quartile voters

https://jslandy.com/two-party-systems-quartile-voters/
3•efavdb•34m ago•0 comments

Industry Standard Tools

https://industrystandard.tools/pending
1•bookofjoe•34m ago•1 comments

Linux support for Apple T1 hardware

https://github.com/standardagents/t1bridge
1•TiredOfLife•37m ago•0 comments

An actual music theory framework with note-for-note voice-leading resolutions

https://www.reddit.com/r/Learnmusic/comments/1vktxsj/the_layout_of_modeschord_swings_in_cmam_w_all/
2•RockofStrength•39m 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.