frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

SlimTide Review: Is Slim Tide Safe for Weight Loss?

https://finance.yahoo.com/sectors/healthcare/articles/slimtide-capsules-updated-warning-2026-1921...
1•haumnary•1m ago•0 comments

Neovim Plugin for Blazingjj

https://opencommit.eu/sejo/blazingjj.nvim
2•sejo•10m ago•1 comments

Valve will stop selling Steam gift cards at retailers over scam concerns

https://www.pcgamer.com/gaming-industry/valve-will-stop-selling-steam-gift-cards-at-retailers-ove...
3•josephcsible•22m ago•0 comments

Just me feeling that Mythos/Fabel just 1% there?

1•punnerud•22m ago•0 comments

Validation, Docs, tests, and database schemas from one source of truth

https://github.com/justhamade/triadjs
1•justhamade•25m ago•1 comments

Humans ask, computers propose, humans decide

https://jakemccrary.com/blog/2020/11/14/speeding-up-magit/
2•signa11•27m ago•0 comments

"Trust Us" Is Not a Control Surface: Anthropic and the Case for Open Weights

https://trust-us.vercel.app
1•tonydavis•28m ago•0 comments

Smartphones Broke British Politics

https://www.politico.eu/article/keir-starmer-uk-prime-minister-resignation-brexit-whatsapp-westmi...
2•giuliomagnifico•29m ago•0 comments

Canada introduces legislation to ban social media for children under 16

https://www.reuters.com/legal/litigation/canada-introduces-legislation-ban-social-media-children-...
3•thm•35m ago•0 comments

Allegro

https://liballeg.org/
1•tosh•38m ago•0 comments

Ask HN: What internal tool did you build that became a product?

2•nehpets•39m ago•1 comments

CopenPay returns and Copenhagen now rewards tourists who arrive by train

https://www.denmarklifestyledaily.com/article/812071964-copenpay-returns-3-times-bigger-copenhage...
1•slu•42m ago•0 comments

The dispute over what caused Air India flight 171 to crash

https://www.bbc.com/news/articles/cwyk9exxp2qo
2•1659447091•43m ago•0 comments

OpenAI mulls slashing prices as it competes with Anthropic for users

https://www.cnbc.com/2026/06/11/openai-mulls-slashing-prices-ahead-of-competition-from-anthropic-...
30•agentifysh•43m ago•20 comments

Show HN: I built a Red Flag Warning zone-check tool for the East Bay in 48h

https://redflag-check.info
2•vedant28t•44m ago•0 comments

Show HN: Vaportrail – flight recorder for Claude Code, Codex, and OpenCode

https://github.com/B33BMO/vaportrail
2•b33bmo•44m ago•1 comments

Tesla robotaxis stall as Musk's self-driving hype hits real-world traffic

https://www.latimes.com/business/story/2026-06-10/tesla-robotaxis-stall-as-musks-self-driving-hyp...
3•1vuio0pswjnm7•46m ago•0 comments

YouTube terms of service allow AI music training, Google says

https://www.billboard.com/pro/google-youtube-terms-of-service-ai-music-training-lawsuit/
1•sdoering•47m ago•1 comments

Feds move to formally allow sports "trading" on prediction markets

https://www.axios.com/2026/06/10/cftc-prediction-markets-sports-event-contract-rules
1•1vuio0pswjnm7•53m ago•0 comments

Nearly Everyone, Everywhere, Veers Left When Walking

https://www.nytimes.com/2026/06/10/science/humans-walking-veer-left-counterclockwise.html
4•bryanrasmussen•54m ago•2 comments

Agentic Frameworks

https://astledsa.substack.com/p/agentic-frameworks
1•astledsa•56m ago•0 comments

Adafruit files suit against Flux.ai over legal threats [pdf]

https://storage.courtlistener.com/recap/gov.uscourts.cand.471648/gov.uscourts.cand.471648.1.0.pdf
4•russdill•58m ago•2 comments

TokenPulse – Live token and rate limit tracker for Claude and ChatGPT

https://chromewebstore.google.com/detail/tokenpulse-—-chatgpt-clau/oimclhdbljodjkankcnalklchfce...
1•Anoop69_•1h ago•0 comments

TikTok

https://tiktok-guahdfjhshrk.com
1•DARKNNESSANKC•1h ago•0 comments

Grit by GitButler: A from-scratch reimplementation of Git in idiomatic Rust

https://github.com/gitbutlerapp/grit
2•maxloh•1h ago•0 comments

It blocked us at 'hello ' Anthropic Fable 5 refusing innocuous prompts

https://www.theregister.com/ai-and-ml/2026/06/10/anthropic-claude-fable-5-refuses-innocuous-promp...
10•abliterationai•1h ago•1 comments

I built a tool that reads code and lists features with file:line refs

https://www.verifiablyai.com/projects/requests
1•arvvind•1h ago•0 comments

Join-Calculus

https://en.wikipedia.org/wiki/Join-calculus
1•tosh•1h ago•0 comments

See what your AI coding agent is doing with Datadog Lapdog

https://chrisebert.net/see-what-your-ai-coding-agent-is-doing-with-datadog-lapdog/
1•cebert•1h ago•0 comments

Terms of Service Ban AI Agents from Using Stack Overflow for Agents

https://meta.stackoverflow.com/questions/438910/introducing-stack-overflow-for-agents
3•nomilk•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.