frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

The AI telling farmers when to harvest

https://www.bbc.com/news/articles/cgk53dkmyxko
1•rmason•1m ago•1 comments

Three AI agents, two countries, and one uneven world wide web

https://royapakzad.substack.com/p/multilingual-ai-agents
2•effects•1m ago•0 comments

Barcodes are about to go extinct

https://thehustle.co/originals/why-barcodes-are-about-to-go-extinct
2•rmason•3m ago•0 comments

Thumos

https://en.wikipedia.org/wiki/Thumos
1•bryanrasmussen•5m ago•0 comments

Show HN: FB Post Generator

https://gemini.google.com/share/1a34bce7137f
1•FDX2018•5m ago•0 comments

Apple will limit Mac disk access as AI agents 'substantially' increase risk

https://www.theverge.com/tech/1004295/apple-limit-mac-disk-access-ai-agents
2•qzervaas•7m ago•0 comments

How to save a life without knowing CPR

https://bookofjoe2.blogspot.com/2026/10/beyondthemedspeak-how-to-save-life.html
1•bookofjoe•7m ago•0 comments

Connections Museum Seattle

https://www.telcomhistory.org/ConnectionsSeattle.html
1•mooreds•9m ago•0 comments

Run over by the Future

https://dgwbirch.substack.com/p/run-over-by-the-future
1•mooreds•10m ago•0 comments

Human Baselines for Benchmarks: AI Now Outperforms Junior Accountants

https://www.mercor.com/blog/human-baselines-for-benchmarks-ai-now-outperforms-junior-accountants/
1•iphonecorridor•10m ago•0 comments

Microsandbox

https://microsandbox.dev
1•handfuloflight•12m ago•0 comments

A Warning for Frontier AI Model Governance

https://www.lawfaremedia.org/article/a-warning-for-frontier-ai-model-governance
1•EA-3167•13m ago•0 comments

A2A CLI: A tool to discover, message, and manage remote AI agents

https://github.com/a2aproject/a2a-cli
1•msampath•14m ago•0 comments

What's the Date?

https://www.lesswrong.com/posts/vzKWsEskYBEWTwpBP/what-s-the-date
2•ronfriedhaber•15m ago•0 comments

Out-of-Band Authorization Codes

https://justinsecurity.medium.com/out-of-band-authorization-codes-50a3563bb5af
1•mooreds•16m ago•0 comments

Six Charts That Show Just How Much We Need A.I

https://www.nytimes.com/2026/10/02/opinion/ai-tech-innovation.html
2•tysone•17m ago•0 comments

Advertising Is Shit Now

https://james.cridland.net/blog/2026/advertising-is-shit-now/
5•1317•22m ago•3 comments

Show HN: Ask the news – Find relevant news faster

https://news.svpn.com/chat
1•svpn•25m ago•0 comments

ASD-STE100: What It Is and What It Has to Do with LLMs

https://kgolubic.com/posts/asd-ste100-and-llms/
6•taubek•25m ago•0 comments

Muse Home Link

https://gadgets.muse.ai/home-link
2•big_toast•25m ago•2 comments

A BGP-Inspired Identity Network for Autonomous AI Agents

https://medium.com/@rodmontiel/uai-a-bgp-inspired-identity-network-for-autonomous-ai-agents-73b89...
1•rodmontiel•27m ago•0 comments

Zoho's ZeptoMail Is Now Cpaas to Incorporate WhatsApp, SMS and Voice

https://www.zoho.com/blog/cpaas/zeptomail-is-now-zoho-cpaas.html
1•rodolphoarruda•27m ago•0 comments

Everyone's Packing Up

https://widdershins.verja.net/everyones-packing-up/
2•speckx•27m ago•0 comments

Two US-bound vessels apparently compromised by hackers

https://www.reuters.com/world/two-us-bound-vessels-apparently-compromised-by-hackers-us-officials...
5•wslh•28m ago•0 comments

Looking for Work

https://github.com/Sovereign-Intel-Founder/sovereignintelfounder
1•Joshua445•29m ago•0 comments

BlueFerry – iPhone's Messages on Linux over Bluetooth

https://blueferry.weirdware.io/
1•smartmic•32m ago•0 comments

CA tech executive arrested for allegedly smuggling $300M in Nvidia chips to CN

https://qz.com/greg-lui-earthmade-nvidia-ai-chips-smuggling-china-100226
4•littlexsparkee•33m ago•1 comments

Show HN: Building a Better Story for Your Brand

1•jarieb•36m ago•1 comments

OpenStax-LLM: tools for OpenStax LLM access

https://github.com/michaelnavazhylau/openstax-llm
1•Mechasparrow•37m ago•0 comments

The Algorithm Still Running Your GPS: Edsger Dijkstra and His Impact on CS

https://nirmalutwani.substack.com/p/the-algorithm-still-running-your
1•nutwani91•38m ago•1 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.