frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

One pull of a string is all it takes to deploy these complex structures

https://news.mit.edu/2025/one-string-pull-deploys-complex-structures-1223
1•fleahunter•21s ago•0 comments

Last Call for Mass Market Paperbacks

https://www.publishersweekly.com/pw/by-topic/industry-news/publisher-news/article/99293-last-call...
1•petethomas•1m ago•0 comments

Building an I-beam building in Far West, Nepal

https://niteshpant.com/essays/beams-of-steel-dhangadhi
1•niteshpant•6m ago•1 comments

Spiked '60 Minutes' Segment Spreads Online

https://www.hollywoodreporter.com/tv/tv-news/spiked-60-minutes-segment-posted-online-airs-canada-...
2•dweinus•6m ago•1 comments

Personalized "For You" Feed for Preprints

https://www.researchhub.com/popular
1•Tardigrade10•11m ago•0 comments

Amazon blocks 1,800 job applications from suspected North Korean agents

https://www.bbc.com/news/articles/c3e0kw80wwzo
2•dabinat•15m ago•0 comments

America Has to Feel Fair

https://substack.com/app-link/post
1•barry-cotter•15m ago•0 comments

Is Data Curation the New Feature Engineering?

https://www.elicited.blog/posts/is-data-curation-new-feature-engineering/
1•justanotheratom•16m ago•1 comments

Show HN: Efpix – A flood protocol with E2EE and metadata protection

https://arxiv.org/abs/2509.08248
1•shinymonitor•17m ago•0 comments

Data centres coming for what's left of Australia's green export superpower dream

https://www.crikey.com.au/2025/12/23/data-centres-renewable-energy-projects-sun-cable/
1•defrost•18m ago•0 comments

Olaf: Bringing an Animated Character to Life in the Physical World [video]

https://www.youtube.com/watch?v=-L8OFMTteOo
1•gmays•20m ago•0 comments

Anna's Archive Backed Up Spotify, Plans to Release 300TB Music Archive

https://torrentfreak.com/annas-archive-backed-up-spotify-plans-to-release-300tb-music-archive/
3•gslin•20m ago•0 comments

In a surprise announcement, Tory Bruno is out as CEO of United Launch Alliance

https://arstechnica.com/space/2025/12/in-a-surprise-announcement-tory-bruno-is-out-as-ceo-of-unit...
2•class3shock•22m ago•0 comments

Show HN: A smile filter that adds a natural-looking smile

https://www.ailabtools.com/features/smile-filter/
1•minimk•24m ago•1 comments

The LocalNetworkAccessAllowedForUrls policy you never deployed

https://patchmypc.com/blog/the-localnetworkaccessallowedforurls-policy-you-never-deployed/
1•rref•26m ago•0 comments

Granular Convection

https://en.wikipedia.org/wiki/Granular_convection
1•thunderbong•30m ago•0 comments

The Secret Behind TikTok That The US Can’t Buy

https://www.youtube.com/watch?v=LYtIRoUO6OI
2•java-man•31m ago•0 comments

Llmon – The First Web Adversarial AI Firewall

https://llmon.dev
1•jfolkins•32m ago•1 comments

Bolmo: Byteifying the Next Generation of Language Models

https://arxiv.org/abs/2512.15586
1•mcyc•48m ago•0 comments

People who wish for the end of developers

3•haebom•51m ago•1 comments

DataFlow: Using LLMs to Build Reproducible, End-to-End Data Pipelines

https://huggingface.co/papers/2512.16676
1•Mey0320•57m ago•1 comments

814M Tokens for <$500 with Cursor

https://i.imgur.com/xmqslal.png
1•danielandrews43•59m ago•1 comments

FCC Updates Covered List to Include Foreign UAS and UAS Critical Components [pdf]

https://docs.fcc.gov/public/attachments/DOC-416839A1.pdf
19•Espressosaurus•1h ago•2 comments

Elementary OS 8.1 Available Now

https://blog.elementary.io/os-8-1-available-now/
4•NN708•1h ago•0 comments

Archivists Posted the 60 Minutes Cecot Segment Bari Weiss Killed

https://www.404media.co/archivists-posted-the-60-minutes-cecot-segment-bari-weiss-killed/
30•m-hodges•1h ago•0 comments

Top lawmaker asks White House to address open-source software risks

https://www.cybersecuritydive.com/news/open-source-security-tom-cotton-letter-white-house/808379/
2•WaitWaitWha•1h ago•0 comments

NYT reporter sues Google, xAI, OpenAI over alleged copyright infringement

https://www.reuters.com/legal/government/new-york-times-reporter-sues-google-xai-openai-over-chat...
4•alephnerd•1h ago•0 comments

In Defense of Curiosity

https://davidbau.com/archives/2025/12/09/in_defense_of_curiosity.html
1•sksq96•1h ago•0 comments

Codex vs. Claude Code (Today)

https://build.ms/2025/12/22/codex-vs-claude-code-today/
2•mergesort•1h ago•1 comments

Color Schemes

https://observablehq.com/@d3/color-schemes
2•ramoz•1h ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

1•ramsicandra•7mo 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•7mo 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•7mo 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.