frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

No Gas, No Chips: Mapping the Choke Points Behind Chip Manufacturing

https://www.aei.org/research-products/report/no-gas-no-chips-mapping-the-choke-points-behind-chip...
1•voxleone•1m ago•0 comments

Ratwires – The Graffiti Wall of the Internet

https://ratwire.space/
1•fdgsdfsdf•1m ago•0 comments

The End of the No-Brainer AI Trade

https://www.wsj.com/finance/stocks/the-month-that-rocked-the-ai-trade-and-rewired-wall-street-f33...
1•thm•1m ago•0 comments

Waves that clear waste from the brain during sleep are impaired in older adults

https://news.mit.edu/2026/waste-clearing-waves-in-brain-during-sleep-are-impaired-in-older-adults...
1•gmays•1m ago•0 comments

Lemon Squeezy is winding down

https://docs.lemonsqueezy.com/migration
1•martin-adams•2m ago•0 comments

Show HN: Grapim, open-source AI code review that runs on your own model key

https://github.com/grapim/grapim
1•alexanderko104•3m ago•0 comments

New Unblocked Games Site

https://poly2.benlaunches.icu
1•notam•3m ago•0 comments

Quark: Our whole training stack, end to end, for $4,200

https://empero.org/writing/quark
2•gmays•5m ago•0 comments

Linktwos finds who you need every day and who to meet at conferences

https://linktwos.com/
2•tomhartleymills•5m ago•0 comments

Remote Access to American Super Intelligence Technology

https://media.bis.gov/press-release/bis-issues-rule-addressing-remote-access-american-super-intel...
1•sharpshadow•6m ago•0 comments

Robert Pattinson confirmed as new James Bond

https://news.sky.com/story/robert-pattinson-confirmed-as-new-james-bond-13612738
1•austinallegro•7m ago•0 comments

Janet Reno was talking about my friend Coolio (computer criminal)

https://michael.bacarella.com/2026/11/16/janet-reno-vs-my-friend-coolio/
1•mbac32768•7m ago•0 comments

Entropy Hunters: Random Numbers and Chaos Machines

https://pod.link/1879625858/episode/QnV6enNwcm91dC0xOTUyNDE0MA
1•dbouquin•7m ago•0 comments

Show HN: Make a custom deck of playing cards with your family and friend's faces

https://facevaluepress.com/
1•mitenko•8m ago•1 comments

Substantial number of fund managers have failed to outperform the market (2025)

https://www.ajbell.co.uk/news/shocking-number-fund-managers-have-failed-outperform-market
1•toomuchtodo•9m ago•0 comments

Some places have banned AI glasses, and the list just keeps growing

https://www.engadget.com/2313707/ai-glasses-banned-places-list-keeps-growing/
1•drodio•9m ago•0 comments

Looking for a remote CTO for my micro SaaS ($600K ARR, $250k Profit)

1•smurf9852•9m ago•1 comments

Cursor: An update on our recent security incident

https://cursor.com/blog/security-incident-update
1•drodio•10m ago•0 comments

Gootloader Malware Using SEO Poisoning and Compromised Websites to Gain Access [pdf]

https://www.ic3.gov/CSA/2026/261116.pdf
1•saikatsg•11m ago•0 comments

Rosalind Workbench: Empowering every scientist to be their own research team

https://developers.openai.com/blog/rosalind-workbench
1•gmays•11m ago•0 comments

Threat Overview of Artex Autonomous Penetration Testing Framework [pdf]

https://www.ic3.gov/CSA/2026/261113.pdf
1•saikatsg•12m ago•0 comments

Artex – AI autonomous penetration testing system

https://github.com/BaaRai/ARTEX
1•saikatsg•14m ago•0 comments

Psychic: Like fzf but learns from your actions

https://klauria.tech/psychic/
2•articulatepang•14m ago•0 comments

In Search of the Deep Life

https://calnewport.com/in-search-of-the-deep-life/
1•samizdis•15m ago•0 comments

Suspicious Traffic Claiming Referral from Aocr.org

https://vale.rocks/micros/20261110-1531
2•OuterVale•15m ago•0 comments

Robert Pattinson is the new James Bond

https://www.aboutamazon.com/news/entertainment/james-bond-robert-pattinson-cast-amazon-mgm-film
1•HelloUsername•16m ago•0 comments

Cgo's pointer check is all over the place

https://theconsensus.dev/p/2026/11/15/cgos-pointer-check.html
1•shraddhaag•16m ago•0 comments

My 17 Heroes – My PhD Students (Bill Wadge)

https://billwadge.com/2026/11/15/my-17-heroes-my-phd-students/
1•herodotus•16m ago•0 comments

Robert Pattinson is the new James Bond

https://www.bbc.co.uk/news/live/ckg5j69ndv2vt
2•mrroryflint•16m ago•0 comments

Italian or British? Writer solves riddle of spaghetti bolognese (2016)

https://www.theguardian.com/world/2016/nov/24/italian-or-british-writer-solves-riddle-of-spaghett...
1•tosh•17m 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.