frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Marx's Theory of Alianation of Labor

https://en.wikipedia.org/wiki/Marx%27s_theory_of_alienation
1•steven_noble•59s ago•1 comments

Where the Microsoft-OpenAI economics currently stand, incl capex

https://twitter.com/amir/status/2054669172240707676
1•cwwc•1m ago•0 comments

Nick and Tristan's Interview with Tyler Cowen

https://www.outrageousfortune.ca/p/nick-and-tristans-interview-with
1•paulpauper•5m ago•0 comments

Xkcd 3233 – Make It Myself

https://xkcd.com/3233/
1•arm32•5m ago•0 comments

What we learned using AI agents to refactor a monolith

https://1password.com/blog/what-we-learned-using-ai-agents-to-refactor-a-monolith
1•cdrnsf•6m ago•0 comments

Show HN: Petri – Drop-in Postgres image that forks a DB per test

https://github.com/taktekhq/petri
1•nizarmah•7m ago•0 comments

AI, Player-Coaches, and Fixing the Management Problem

https://www.axamy.com/blog/ai-player-coaches-and-fixing-the-management-problem
1•jhonovich•22m ago•13 comments

Not Forgotten – Maui Fire Relief – StartUp Non-Profit-Documentary [video]

https://www.youtube.com/watch?v=uXSO3iehL9U
1•pgroverman•22m ago•0 comments

Show HN: Showing the same info in 248 different UI

https://whoareyou.infiniwa.com/
1•ym705•22m ago•0 comments

The anti-minimalist backlash is the bigger story behind Oxygen's revival

https://filipfila.wordpress.com/2026/05/10/the-anti-minimalist-backlash-is-the-bigger-story-behin...
1•birdculture•23m ago•0 comments

The Smartphone Market Is Cracking

https://asymco.com/2026/05/13/the-smartphone-market-is-cracking/
1•ndr42•26m ago•0 comments

Old film camera can now shoot 4K video, 26MP RAW files without any modifications

https://www.digitalcameraworld.com/cameras/film-cameras/im-obsessed-with-retro-cameras-this-gadge...
1•teleforce•28m ago•0 comments

Intercom changes name to Fin

https://www.intercom.com/blog/today-intercom-becomes-fin/
12•RyanShook•29m ago•7 comments

Chinese EVs take the world by storm

https://www.nbcnews.com/world/asia/chinese-evs-take-world-storm-united-states-rcna344680
3•lxm•31m ago•0 comments

MathScroll: Infinitely Scroll Mathematics

https://projects.ollybritton.com/mathscroll/
1•pykello•35m ago•0 comments

New Yuri Anime Has Girls Duking It Out in Street Fighter 6 (and Falling in Love)

https://kotaku.com/young-ladies-dont-play-fighting-games-street-fighter-6-2000692424
1•PaulHoule•36m ago•0 comments

CEOs Say Layoffs Are AIs Fault–But Some Experts Think Companies Are Lying|Forbes

https://www.forbes.com/sites/maryroeloffs/2026/05/07/ceos-say-layoffs-are-ais-fault-but-some-expe...
2•Baljhin•36m ago•1 comments

Show HN: I made a minimalistic Tower Defense Game – iOS – Looking for feedbacks

https://voidgame.app/
1•pompeii•37m ago•0 comments

Video Is Different at 360p

https://www.youtube.com/watch?v=UCBAqaT4SQc
1•philo23•39m ago•0 comments

Software Engineers Are Obsolete

https://idiallo.com/blog/everyone-is-better-than-you
2•ilreb•41m ago•0 comments

Robyx-AI, Your AI staff, managed from chat

https://github.com/terrordrummer/robyx-ai
1•robyxyz•44m ago•0 comments

Code Structure Evolution: When Software Outlives Its Reasons

https://papers.ssrn.com/sol3/papers.cfm?abstract_id=6761138
1•camilochs•45m ago•0 comments

I Launched the Answer to TanStack Supply Chain Attack, Same Day It Happened

https://www.stackgraveyard.dev/
1•tlseternal•46m ago•0 comments

What a launch on product-hunt, without paying anyone gets you

https://docsalot.dev/blog/what-i-learned-launching-docs-benchmark-on-product-hunt
1•fazkan•49m ago•0 comments

Heritability Puzzlers

https://dynomight.net/heritable/
2•ajdecon•52m ago•0 comments

59000-year-old Neanderthal tooth may be oldest evidence of dentistry

https://www.scientificamerican.com/article/59-000-year-old-neanderthal-tooth-may-be-oldest-eviden...
1•andsoitis•53m ago•0 comments

Filter and Rank: Robust Multi-Cloud Sandbox Orchestration at Scale

https://www.tensorlake.ai/blog/multi-cloud-scheduling
1•diptanu•54m ago•0 comments

Unity AI Open Beta

https://unity.com/features/ai
3•emrehan•54m ago•0 comments

Nextpad++ feels like a fever dream

https://daringfireball.net/2026/05/nextpad
3•maxutility•56m ago•1 comments

Tim Cook's Next Act: Apple's Diplomat-in-Chief

https://www.forbes.com/sites/timbajarin/2026/05/13/tim-cooks-next-act-apples-diplomat-in-chief/
7•gastonmorixe•1h ago•2 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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