frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Ways to Encrypt Data on Servers

https://lwn.net/Articles/1092553/
1•qrobit•33s ago•0 comments

Ask Mike

https://mikedashhistory.com/ask-mike/
1•Eridanus2•1m ago•0 comments

Old hearts age backwards: transplanted organs adjust to host's biological age

https://www.nature.com/articles/d41586-026-03043-w
3•bookofjoe•2m ago•0 comments

Claude Sonnet 5.5

https://www.anthropic.com/claude-sonnet-5-5
3•D2OQZG8l5BI1S06•2m ago•1 comments

Ask HN: React Native or Flutter when the back end is Node?

1•rearview•3m ago•0 comments

Play Nintendo Switch games on a jailbroken PS5

https://www.tomshardware.com/video-games/console-gaming/you-can-now-play-nintendo-switch-games-on...
1•yboris•4m ago•0 comments

AI godfathers warn of runaway 'intelligence explosion'

https://www.theguardian.com/technology/2026/sep/28/ai-godfathers-warn-of-runaway-intelligence-exp...
3•pseudolus•5m ago•1 comments

Update: 2run.tools – Privacy first, no-upload, no-server, image-pdf tools

https://2run.tools/
1•2rundev•5m ago•0 comments

RRSI: Regularized Recursive Self-Improvement of Agent Harnesses

https://github.com/google-research/rrsi
2•simonpure•6m ago•0 comments

I made a visual workspace for AI Automations

https://www.biom.dev/
3•jduhking•7m ago•1 comments

The Revise SDK

https://revise.io/blog/09-28-2026/introducing-the-revise-sdk
2•artursapek•7m ago•0 comments

Karpenter Troubleshooting: Pending Pods, Failed Launches, Nodes That Never Join

https://radarhq.io/blog/karpenter-troubleshooting
2•royLsky•8m ago•0 comments

Definitely not Windows (Win 11 parody)

https://definitelynotwindows.com/
2•jjbinx007•9m ago•0 comments

IOP group therapy locations in the USA

https://iop.groupicorn.com/
2•cs1996•9m ago•0 comments

Gemini app replacing Gems with skills in November

https://9to5google.com/2026/09/27/gemini-gems-skills/
1•mikelgan•12m ago•0 comments

Protest Against European Parliament Chat Control 1.0 Legislation in Warsaw

https://www.reutersconnect.com/item/protest-against-european-parliament-chat-control-10-legislati...
3•latexr•12m ago•1 comments

Thyssenkrupp steel unit aims to triple core profit in turnaround push

https://www.reuters.com/business/thyssenkrupp-steel-unit-aims-triple-core-profit-turnaround-push-...
2•frank_clover•13m ago•0 comments

Who Wrote Elizabeth I's Most Scathing Letters?

https://www.smithsonianmag.com/history/who-wrote-elizabeth-is-most-scathing-letters-new-research-...
2•benbreen•13m ago•0 comments

Slovenia's .si domain grows more than 15% in wake of Trump's UN speech

https://domainnamewire.com/2026/09/28/slovenia-si-domains/
2•speckx•15m ago•0 comments

I got tired of never knowing what ports are running, so I built WhatThePort

https://whattheport.dev
2•tomjohndesign•18m ago•1 comments

The Teen Portraits That Captivated Sofia Coppola

https://www.newyorker.com/culture/photo-booth/the-teen-portraits-that-captivated-sofia-coppola
2•prismatic•19m ago•0 comments

Sober: We Ported Roblox to Linux

https://sober.vinegarhq.org/
3•poly2it•20m ago•0 comments

The UN votes for Equal Earth and so can you

https://www.earthlingmaps.com/updates/un-votes-equal-earth-earthling-v2
1•tvdvd•21m ago•0 comments

Automated Evidence Extraction for Veterans

https://369scan.com
1•kristianmartel•21m ago•0 comments

GenRec: An LLM-Backed Recommendation Ranker at NetflixConference

https://arxiv.org/abs/2608.10257
3•throwthrowrow•23m ago•0 comments

We swapped our LLMs for Jev. It's 39% cheaper

https://polylane.com/blog/we-swapped-our-llms-for-jev/
6•gczh•23m ago•3 comments

Doing the Hard Stuff

https://iaziz786.com/blog/doing-the-hard-stuff/
1•speckx•23m ago•0 comments

A $20 AI subscription is one hour of minimum-wage work in US, 50 in Nigeria

https://www.intelligence-hours.org/
3•haebom•25m ago•0 comments

Machine's Search for Meaning

https://magzimof.com/machines-search-for-meaning/
1•shaimagz•25m ago•0 comments

NoRoles – run a company of people and AI agents on permissions

https://github.com/noroles/noroles
2•ilyacherepanov•26m 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.