frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Why Inventing Color TV Was So Difficult

https://www.openculture.com/2026/09/why-inventing-color-tv-was-so-difficult.html
1•mdp2021•31s ago•0 comments

Lorenz and Little: How Much Does Your Tail Cost?

https://brooker.co.za/blog/2026/07/29/lorenz-and-little.html
1•halit_okumus•2m ago•0 comments

Built Carvitals for a hackathon, car service and realtime value tracking

https://carvitals.org/
1•andrewsbarbaro•2m ago•1 comments

Show HN: BullSniff – Sniff out bullshit AI sites

https://bullsniff.com
1•steejk•3m ago•1 comments

A flickering light eases pain in mice

https://medium.com/@6thMind/a-flickering-light-eases-pain-in-mice-and-the-reason-also-explains-th...
1•smanuel•4m ago•0 comments

What 119 real expense-splitting groups look like

https://getsplitright.com/what-expense-splitting-groups-look-like.html
1•sleipner42•6m ago•0 comments

OpenWhispr – Open-source, privacy-first voice-to-text with local AI

https://digitalescapetools.com/tools/tool.html?id=openwhispr
1•xabd•7m ago•0 comments

Orange hydrogen, Yilgarn Craton: production with carbon dioxide mineralization

https://www.sciencedirect.com/science/article/pii/S036031992602269X
1•defrost•7m ago•0 comments

Web-based interactive static pattern discovery tool to locate structures

https://github.com/HexLasso/FF-16-Web
1•HexLasso•7m ago•0 comments

Volkswagen says it is cutting 100k jobs by the end of the decade

https://techxplore.com/news/2026-09-volkswagen-jobs-decade.html
3•mdp2021•12m ago•0 comments

Large Blast Radius Coder Registry Hijack

https://www.optimuslabs.io/research/briefings/coder-registry-infrastructure-hijack
1•rickdeaconx•12m ago•1 comments

Where were you when reality died?

https://www.unite.ai/where-were-you-when-reality-died/
1•50kIters•14m ago•0 comments

Norway's Oil Fund Proposes Selling Roughly $80B in U.S. Treasurys

https://www.wsj.com/finance/investing/norways-oil-fund-proposes-cut-to-government-bond-holdings-d...
3•toomuchtodo•14m ago•0 comments

The Life of a Metric

https://victoriametrics.com/blog/the-life-of-a-metric/index.html
1•func25•14m ago•0 comments

AI engineer breaks part of RSA encryption protocol by hand

https://www.scientificamerican.com/article/whats-the-tech-behind-the-record-breaking-rsa-260-crack/
2•chc2889•14m ago•0 comments

ChatGPT now limits prompts per week, even on their most-expensive plans

https://help.openai.com/en/articles/20001354-gpt-56-and-gpt-6-pro-in-chatgpt
1•zof3•15m ago•0 comments

China's Rare Earths Duopoly

https://www.chinatalk.media/p/chinas-rare-earths-duopoly
1•baud147258•17m ago•0 comments

Keepalived Track Scripts for Application-Aware Failover

https://www.virtualizationhowto.com/2026/09/i-thought-keepalived-only-protected-my-home-lab-serve...
1•bleevht•18m ago•1 comments

To do your best work you need to work like a sculptor

https://livingsystems.substack.com/p/to-do-your-best-work-you-need-to
3•samuell•19m ago•0 comments

Dogpark is a message board for a handful of software agents and one human

https://github.com/pjlsergeant/dogpark
2•Bluestein•21m ago•0 comments

Scientists Find Worms in Almost Every Fish in a Tuna Haul – 96% Were Infected

https://www.sciencealert.com/scientists-find-parasites-in-almost-every-fish-from-a-recent-tuna-ha...
4•arto•21m ago•0 comments

The Corruption of Christianity

https://medium.com/freedomofthought/the-corruption-of-christianity-b05b7543baa6
1•raynchad•22m ago•0 comments

Will the AI Boom Price the Rest of the Economy Out of Capital?

https://publicemails.com/blog/display/659255/Will-the-AI-Boom-Price-the-Rest-of-the-Economy-Out-o...
1•arbuge•22m ago•0 comments

Colorlight 5A-75B: A dive into a popular low-cost ECP5 (FPGA) development board

https://blog.yosyshq.com/p/colorlight-part-1/
1•gregsadetsky•24m ago•0 comments

Buried underpants and a new definition of kissing win 2026 Ig Nobel prizes

https://www.nature.com/articles/d41586-026-02650-x
1•jhncls•25m ago•0 comments

Equal Earth (2018)

https://equal-earth.com/
1•turtleyacht•25m ago•0 comments

The Future of Security Compliance Is AI-Native

https://www.pentesty.co/blog/ai-native-compliance-infrastructure-continuous-security
1•josanjohnata•26m ago•0 comments

You Cannot Know the Future. You Can Only Model It

https://www.saul.at/posts/you-cannot-know-the-future
2•Essa•26m ago•0 comments

Tesla Cybercabs Hit Austin Streets in Expansion of Robotaxi Service

https://www.wsj.com/business/autos/tesla-cybercabs-hit-austin-streets-in-expansion-of-robotaxi-se...
2•bookofjoe•27m ago•2 comments

Reverse recruiting and the HR shift: what changes when talent also chooses

https://www.foxapply.com/blog/en/reverse-recruiting-hr-talent-also-chooses
2•johnzoro107•27m 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.