frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Nova Seed. Create an AI friend and build something together

https://github.com/mas-bandwidth/nova
2•gafferongames•7m ago•0 comments

Why are AI agents lying, cheating and coordinating?

https://yoshuabengio.org/en/publication/why-are-ai-agents-lying-cheating-and-coordinating
2•jonifico•8m ago•0 comments

Fresh Kills – World Trade Center Debris Burial Ground

https://www.youtube.com/watch?v=OdMqX_F66rE
2•dsr12•8m ago•0 comments

A.I. Slopware Is Everywhere Now. Nobody Is Using It

https://www.nytimes.com/2026/09/12/opinion/ai-software-coding-apps.html
3•colinprince•9m ago•0 comments

Asking Anthropic CEO: 'Do you earnestly believe that AI could kill all humans?'

https://www.cnn.com/business/video/anderson-cooper-anthropic-ceo-dario-amodei-could-ai-kill-human...
2•oxag3n•12m ago•0 comments

Scientists Create a New Form of Ice at More Than 2000°C

https://www.sciencealert.com/scientists-create-a-new-form-of-ice-at-more-than-2000-c
4•jnord•18m ago•0 comments

Carney's Bid to Make Canada an 'Associate Member' of the EU

https://www.wsj.com/world/europe/canada-alliance-eu-carney-276f1778
2•JumpCrisscross•19m ago•1 comments

OS that runs the Mars Rovers and Artemis is helping power the Roman Telescope

https://www.windriver.com/blog/NASA-Nancy-Grace-Roman-Space-Telescope
2•ReindeerFlotill•20m ago•0 comments

The Critical Period

https://www.cell.com/current-biology/fulltext/S0960-9822(07)01519-9
2•andsoitis•23m ago•0 comments

Apple wants to train AI on your private personal data

https://machinelearning.apple.com/research/introducing-third-generation-of-apple-foundation-models
8•croes•24m ago•6 comments

The Last AI Built by Humans: Toward Genuine Recursive Self-Improvement

https://arxiv.org/abs/2609.11873
2•mlmonkey•29m ago•0 comments

Using LLMs After a TBI

https://www.urgentteam.com/healthy-living-tips/think-f-a-s-t-act-faster-stroke-signs-that-cant-wait/
2•tj_astro•31m ago•2 comments

DNSCrypt

https://en.wikipedia.org/wiki/DNSCrypt
2•st_goliath•34m ago•0 comments

Align AI and Mathematics–To Something Else

https://liorpachter.wordpress.com/2026/09/12/align-ai-and-mathematics-to-something-else/
3•nitrogenpuddle•42m ago•0 comments

Next StarCraft Game Announced at BlizzCon

https://www.ign.com/articles/next-starcraft-game-announced-at-blizzcon-as-an-open-world-shooter-b...
2•miiiiiike•44m ago•0 comments

Plunging test scores are a slow-moving catastrophe

https://www.economist.com/leaders/2026/09/10/plunging-test-scores-are-a-slow-moving-catastrophe
3•1vuio0pswjnm7•49m ago•2 comments

Competitive Landscape Cubacadabra

https://cubacadabra.com/landscape/
3•cs1996•50m ago•0 comments

The Case for Online Dating

https://rewirenewsgroup.com/2026/09/11/dating-apps-that-actually-work/
2•DeepLogin•51m ago•0 comments

Show HN: Fleecevest – The Product Counterpart to Ponytail

https://github.com/Websites-On-Computers/fleecevest
3•mattcomputer•54m ago•1 comments

Show HN: Most Penalized HN Stories

https://news.social-protocols.org/penalties
2•jwarden•54m ago•0 comments

AI Infra and Compute Debt: Duration Mismatch vs. Market Momentum

https://aigalaxiome.substack.com/p/ai-infrastructure-build-what-sec
2•aigalaxiome•55m ago•0 comments

Xkcd-Font: The Xkcd Font

https://github.com/ipython/xkcd-font
4•birdculture•59m ago•0 comments

Everyone should slow down AI development except for me

https://xeiaso.net/notes/2026/everyone-slowdown-but-me/
4•xena•59m ago•0 comments

No Lectern, No Notes: Speaking at DroidKaigi 2026

https://sergiocarrilho.com/posts/droidkaigi-experience/
1•scarrilho•1h ago•0 comments

Novel Realizations of Warp Drive Spacetimes as Solutions of General Relativity

https://www.mdpi.com/2218-1997/12/5/132
1•lambdaone•1h ago•1 comments

Eric Betzig on Live-Cell and Super-Resolution Microscopy [video]

https://www.youtube.com/watch?v=RUB37QhWNkw
1•kaivi•1h ago•0 comments

Sergey Brin pours more than $100M into fighting California's billionaire tax

https://www.latimes.com/business/story/2026-08-12/googles-sergey-brin-spent-102-million-fighting-...
20•wslh•1h ago•10 comments

Al-Qaeda regroups in Afghanistan, 25 years after 9/11

https://www.washingtonpost.com/world/2026/09/12/25-years-after-911-al-qaeda-regroups-afghanistan/
3•wslh•1h ago•1 comments

A Godot 4 port of two 1996 Bethesda shooters

https://github.com/nemo22/skynet-godot
3•nemo22•1h ago•1 comments

Serotonergic Neurotransmission in Mediating Octopus Social Behavior

https://www.frontiersin.org/journals/behavioral-neuroscience/articles/10.3389/fnbeh.2019.00185/full
1•andsoitis•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.