frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Claude-Pod

https://github.com/trekhleb/claude-pod
1•trekhleb•1m ago•0 comments

What are your thoughts on this technology that the American government has?

1•whiteangel1984•3m ago•0 comments

A local AI recording summarizer developed by Google

https://developers.google.com/edge/foresight
2•haebom•5m ago•0 comments

Sightline – In-browser verification for CV dataset labels (No cloud uploads)

https://ais-pre-uqacxswl4dlj3azrt3kfxb-932959859977.europe-west2.run.app
1•joshuageoschool•5m ago•0 comments

One Minute Park

https://oneminutepark.tv/?minute=16:04&view=map&map=1.00/0.0000/-55.0175
2•cookingoils•7m ago•0 comments

Show HN: Homebutler – my server report printed 7 lines for 2 changes, now 2

https://github.com/Higangssh/homebutler
1•swq115•7m ago•0 comments

AI coding agents generate more code, but not more software

https://arstechnica.com/ai/2026/10/ai-coding-agents-generate-more-code-but-not-more-software/
3•jonbaer•10m ago•0 comments

Ledger wallet tampering suspected after reports of crypto thefts

https://www.theverge.com/tech/1009294/ledger-wallet-tampering-suspected-after-reports-of-crypto-t...
1•sbulaev•13m ago•0 comments

Free YouTube Transcript Generator

https://videotranscriber.ai/youtube-transcript-generator
3•Lemarie•18m ago•0 comments

Show HN: Foretype: type on remote machines at local speed

https://github.com/itsfabioroma/foretype
2•ofabioroma•21m ago•0 comments

Agentic journal of higher categorical semantics

https://higher-categorical-semantics.pages.dev/announcements/call-for-papers
2•measurablefunc•22m ago•0 comments

An open-source, clean-room reimplementation of Microsoft Word in pure Rust

https://github.com/storytold/wordcraft
2•espeed•23m ago•0 comments

Linus Torvalds Working on a Hefty Linux Kernel Improvement with Claude Code

https://www.phoronix.com/news/Linus-Torvalds-Claude-Code
7•mdp2021•23m ago•0 comments

American Academy of Pediatrics renews call for ban on raw milk

https://www.cspi.org/cspi-news/american-academy-pediatrics-renews-call-ban-raw-milk
2•geox•31m ago•0 comments

Eye Cells May Have Been Rejuvenated for the First Time in People

https://time.com/article/2026/10/08/eye-cells-rejuvenated-for-the-first-time-in-people/
4•pseudolus•33m ago•0 comments

Iran's threat to cut undersea cables in Strait of Hormuz poses a threat to Gulf

https://theconversation.com/irans-threat-to-cut-undersea-cables-in-strait-of-hormuz-poses-a-serio...
6•snarky-comments•35m ago•0 comments

Show HN: SwapBackdrop – reuse one cutout across video backgrounds and frames

https://swapbackdrop.com/
3•robot1996•48m ago•0 comments

USGS Tsunami Warning System

https://www.tsunami.gov/
3•hmnxrne•53m ago•0 comments

Why is bun so disliked?

https://www.reddit.com/r/webdev/comments/1wx1y2u/why_is_bun_so_disliked/
2•lr0•53m ago•0 comments

Codesmith's flagship open source project compromised, thousands at risk

https://www.deepwoodssec.com/research/reactime
4•michaelnovati•54m ago•0 comments

Elon Musk's PAC is spreading inaccurate voting info, election officials say

https://www.cnn.com/2026/10/10/politics/elon-musk-pac-inaccurate-voting-information
14•MilnerRoute•54m ago•0 comments

Thoughts on the Current State (Especially Quality Issues) and Future of Bun

https://github.com/oven-sh/bun/issues/27664
2•lr0•55m ago•0 comments

Wildfire xPrize Winners

https://robotsandstartups.substack.com/p/wildfire-xprize-winners-women-in
5•robotlaunch•56m ago•1 comments

Ask HN: Curious, who can afford to buy in SF?

4•rubicon33•1h ago•2 comments

Show HN: I made an agent can self-improving while working

https://yehuitang0316.github.io/gear-site/
5•yt1998•1h ago•2 comments

AI is changing how Lawyers work – and putting the billable hour under pressure

https://www.cnbc.com/2026/10/10/ai-lawyers-billable-hour-legal-careers.html
9•peter_d_sherman•1h ago•0 comments

Ask HN: Can we discourage Show HNs that "ship the first draft"

3•cadamsdotcom•1h ago•1 comments

Show HN: Drune – Personalize your AI and use it anywhere

https://drune.ai/
1•vskalyan•1h ago•0 comments

Fall To One (Math Song) [video]

https://www.youtube.com/watch?v=9juhm97co1U
4•metadat•1h ago•0 comments

The Sysco Situation Just Got Worse [video]

https://www.youtube.com/shorts/SVm9M7Ag3lk
3•mikhael•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.