frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Time Travel in Braid (2015)

https://qntm.org/braid
1•Ariarule•4m ago•0 comments

New recession odds and economic metric website

https://cyclewatch.org/
1•Macrolens•6m ago•0 comments

Donate AI Tokens for Open Source Projects

https://moochy.dev
2•sanix-darker•8m ago•1 comments

Ideogram 4.5: The most precise edit model

https://ideogram.ai/models/4.5/
1•gmays•10m ago•0 comments

Skyfall – open-source WebGPU aircombat game that runs in your browser

https://github.com/a7ul/skyfall
3•atulfiled•10m ago•0 comments

Ghost Debt - How influence outlives you, and the debt it leaves behind

https://medium.com/@aggelosbellos/ghost-debt-43437f792256
1•bellangelo•11m ago•0 comments

Against Personal Agents Theory of Everything Why the Future of Work Is a Factory

https://www.gettheleverage.com/p/against-the-personal-agents-theory
1•rmason•12m ago•0 comments

NDS National Design Studio

https://en.wikipedia.org/wiki/National_Design_Studio
1•sans_souse•12m ago•0 comments

Gen Z is betting on sports. Experts warn of the risks

https://www.cnbc.com/2026/10/04/gen-z-sports-betting-financial-and-mental-health-risks.html
1•pseudolus•14m ago•0 comments

Site-Blocking Will Not Defend IP, No Matter the Bill's Name

https://www.eff.org/deeplinks/2026/10/site-blocking-will-not-defend-ip-no-matter-bills-name
2•droidjj•15m ago•0 comments

Ultrise

https://www.ultrise.com
1•abderrazzakecha•17m ago•0 comments

JavaScript Demos – Practical browser-based JavaScript examples, no frameworks

https://brysonbw.github.io/js-demos/#/
1•Brysonbw•22m ago•1 comments

Show HN: DoubtBench – does Jev know when humans disagree?

https://github.com/deeplearningguy/doubtbench
1•deepbuilder•22m ago•0 comments

What Is HLS Streaming? HTTP Live Streaming Explained

https://www.red5.net/blog/what-is-hls-streaming/
2•mondainx•33m ago•0 comments

Show HN: Severance-inspired terminal that prints task tickets

https://highlatencylife.com/notes/task-printer-machine-out-of-severance/
1•strizzo•33m ago•0 comments

Ask HN: What happens when AI writes a Bible ver 2.0, geared toward its interest?

2•netfortius•36m ago•2 comments

Your bookmarks are a mess. Fix them

https://chromewebstore.google.com/detail/kosh-bookmark-manager/meldjdfnfgefeoegccphimkmgmeamcce
1•havu12•37m ago•0 comments

New York Times Saved $45M with Tax Break It Faults Meta for Using

https://freebeacon.substack.com/p/new-york-times-co-saved-45-million
5•CGMthrowaway•38m ago•0 comments

An AI couldn't beat humans at StarCraft, so it decided to cheat

https://www.theverge.com/ai-artificial-intelligence/1004543/openai-gpt-cheat-starcraft
3•sbulaev•40m ago•0 comments

Show HN: Last Internet Connection

https://reparadoxy.itch.io/last-internet-connection
1•PolishDevelop22•41m ago•0 comments

I'm Calling for a Pause in the Development of the Universal Bone Dissolver

https://www.theatlantic.com/newsletters/2026/10/ai-slowdown-bone-dissolver/688854/
3•rmason•44m ago•0 comments

Show HN: Baloo, self-hosted AI code review for GitHub

https://github.com/bluebear-io/baloo-bear
2•amirshk80•45m ago•0 comments

In the wake of closure, a digital archive of animated materials appears online

https://filmstories.co.uk/news/tippett-studios-in-the-wake-of-its-closure-a-digital-archive-of-an...
1•rdmuser•45m ago•0 comments

Show HN: I open-sourced the gradient picker from our design editor

https://github.com/rishimohan/colorshot
1•zinx•46m ago•0 comments

Lawmakers look to require AM radio in new cars despite automakers' pushback

https://chicago.suntimes.com/media/2026/10/03/lawmakers-am-radio-new-cars-automakers-pushback
3•TMWNN•47m ago•0 comments

Scoop: White House monitors suspected plague outbreak in Russia

https://www.axios.com/2026/10/04/russia-plague-outbreak-white-house-us
3•colinhb•48m ago•2 comments

Annotated Finnegans Wake

https://finwake.com/01/01.htm
1•gregsadetsky•49m ago•1 comments

Fallstreak Hole

https://en.wikipedia.org/wiki/Fallstreak_hole
1•the-mitr•50m ago•1 comments

Show HN: MapLibre Compose, Interactive Vector Maps for Compose Multiplatform

https://github.com/maplibre/maplibre-compose
3•sargunv•51m ago•0 comments

Repair Café Silicon Valley

https://repaircafesv.org/
1•akman•52m 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.