frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

The Camden Fourteen – Identifying America's First Veterans

https://fhdforensics.com/camden-burials-identifications/
1•rmason•6m ago•1 comments

Wp2shell: Pre Authentication RCE in WordPress Core

https://slcyber.io/research-center/wp2shell-pre-authentication-rce-in-wordpress-core/
1•tjwds•9m ago•0 comments

Intel Starts Shipping High-NA EUV Silicon

https://morethanmoore.substack.com/p/intel-starts-shipping-high-na-euv
1•zdw•12m ago•0 comments

Give Agents Homeplace via SSH

https://www.xshellz.com/
2•stfnon•12m ago•1 comments

Why huge pages matter for Postgres?

https://clickhouse.com/blog/huge-pages-clickhouse-managed-postgres
1•saisrirampur•12m ago•0 comments

IBM CEO Arvind Krishna Has Nowhere to Hide from AI

https://www.wsj.com/tech/ibm-ceo-arvind-krishna-has-nowhere-to-hide-from-ai-c9ff290f
2•johnbarron•18m ago•0 comments

Sync.md – keep AGENTS.md, Claude.md, .cursorrules in sync by meaning, not diff

https://marketplace.visualstudio.com/items?itemName=sync-md.sync-md
1•anzilzedex•19m ago•0 comments

Against Mind-Blindness: Recognizing and Communicating with Diverse Intelligences [video]

https://www.youtube.com/watch?v=RHkFmUwW0kM
2•lioeters•20m ago•0 comments

Things I Won't Work With: Dioxygen Difluoride (2010)

https://www.science.org/content/blog-post/things-i-won-t-work-dioxygen-difluoride
2•downbad_•23m ago•0 comments

Show HN: Waylou / a multi-provider CLI coding agent / fork of Gemini CLI

https://github.com/helis-d/waylou
1•Emirhan123•23m ago•1 comments

Tool to benchmark AGENTS.md file on swe tasks

https://github.com/emiliolugo/clawmark
1•emiliolugo•23m ago•0 comments

Apple dethrones Nvidia to regain title of world's most valuable company

https://www.theguardian.com/technology/2026/jul/17/apple-nvidia-most-valuable-company
4•Brajeshwar•25m ago•0 comments

Tutorial: Introduction to Formal Verification with Lean (Part 1)

https://hashcloak.com/blog/tutorial-introduction-to-formal-verification-with-lean-(part-1)
2•birdculture•28m ago•0 comments

No President Has Embarrassed This Country the Way Trump Did Last Night

https://newrepublic.com/post/213195/trump-primetime-speech-no-embarrassed-country
11•petethomas•28m ago•0 comments

Valve's 14-Year Journey to Make the Steam Machine

https://www.bloomberg.com/news/newsletters/2026-07-17/valve-s-14-year-journey-to-make-the-steam-m...
1•HelloUsername•29m ago•0 comments

World Models

https://twitter.com/selimonder/status/2078540842822733993
1•selimonder•29m ago•0 comments

Typing Speed Test, but for Developers

https://haxxorwpm.0s.is/
6•hronecviktor•30m ago•3 comments

Kimi K3 Might Have Just Started a Crash of the US Economy

https://danielmiessler.com/blog/kimi-k3-us-economy
6•zelmetennani•32m ago•1 comments

Taylor Farms Recall. 27 States and the List Includes Bags Sold in Grocery Stores

https://www.marlerblog.com/case-news/taylor-farms-posted-its-own-recall-it-went-to-27-states-not-...
4•speckx•34m ago•0 comments

Jack Conte: Why I'm (sort of) not worried about AI [video]

https://www.youtube.com/watch?v=17_HcR95YBc
1•magistr4te•35m ago•0 comments

Is there any need for low cost LinkedIn followup reminder solution

1•vinayrsbalhara•35m ago•0 comments

Show HN: Medows – an AI clinical workspace for doctors on ward rounds

https://www.medows.ai/demo
1•alapanx•37m ago•2 comments

Meta's new AI chips will begin production in September

https://techcrunch.com/2026/07/09/metas-new-ai-chips-will-begin-production-in-september/
1•gmays•37m ago•0 comments

Amazon invents the Attachment Economy bait-and-switch

https://www.machinesociety.ai/p/amazon-invents-the-attachment-economy
1•mikelgan•38m ago•1 comments

I indexed 15,000 company hiring boards to search every (most) live tech jobs

https://www.padmi.ai/
2•anirudra•41m ago•1 comments

/dev/tcp to do fast and light TCP health checks

https://www.linuxjournal.com/content/more-using-bashs-built-devtcp-file-tcpip
1•arberx•41m ago•0 comments

Real-Time LuaTeX: Recompiling Large Documents in 1 ms [video]

https://www.youtube.com/watch?v=It9BMNGtjao
2•amichail•42m ago•1 comments

Show HN: Firedeck – Firebase Console for iPhone and iPad

https://firedeck.net/
1•adamgelatka•45m ago•0 comments

The Java Story, the Official Documentary

https://www.youtube.com/watch?v=ZqGSg4b_cZA
1•Dr_Emann•45m ago•0 comments

Spotify Deleted 75M AI-Generated Tracks – and It's Not Done Yet

https://www.gadgetreview.com/spotify-deleted-75-million-ai-generated-tracks-and-its-not-done-yet
1•CharlesW•45m 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.