frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Publishers Clearing House's bankruptcy means winners will no longer get paid

https://www.cnn.com/2025/09/16/business/publishers-clearing-house-bankruptcy-winners-lose-prizes
1•petethomas•1m ago•0 comments

The Well Watchers

https://www.motherjones.com/environment/2025/12/abandoned-oil-wells-texas-tiktok-hawk-dunlap-sara...
1•toomuchtodo•8m ago•0 comments

Ask HN: Can systems function correctly without memory?

1•SpicyG•9m ago•0 comments

The iOS Weekly Brief – Issue #40

https://vladkhambir.substack.com/p/the-ios-weekly-brief-issue-40
1•khambir•10m ago•0 comments

Andrej Karpathy: "I've never felt this much behind as a programmer"

https://twitter.com/i/status/2004607146781278521
1•alexcos•16m ago•1 comments

Geographic shapes and flags via simple URLs

https://borderly.dev/
1•zuhayeer•16m ago•0 comments

GitHub Takes Down Rockchip MPP Repository After FFmpeg Copyright Claim

https://linuxiac.com/github-takes-down-rockchip-mpp-repository-after-ffmpeg-copyright-claim/
1•marcodiego•18m ago•0 comments

Lost Years: Expected Number of Years Lost

https://github.com/gojiplus/lost-years
1•neehao•21m ago•0 comments

Ask HN: Why does YouTube collect creator demographics?

1•journal•26m ago•0 comments

Make Your iPhone Speak the Time

https://swordandsignals.com/2025/12/27/announce-time-on-demand.html
1•jiannengli•28m ago•0 comments

Show HN: tpmjs - npm for ai sdk tools

https://tpmjs.com/
2•thomasfromcdnjs•30m ago•1 comments

Dad's Fitness May Be Packaged and Passed Down in Sperm RNA

https://www.quantamagazine.org/how-dads-fitness-may-be-packaged-and-passed-down-in-sperm-rna-2025...
13•vismit2000•50m ago•2 comments

Change, How Expensive

https://johnocens.com/soothfare/changehowexpensive
2•wonderbar•53m ago•0 comments

Bluetooth Headphone Jacking: Full Disclosure of Airoha Race Vulnerabilities

https://insinuator.net/2025/12/bluetooth-headphone-jacking-full-disclosure-of-airoha-race-vulnera...
1•marvinborner•57m ago•0 comments

2026 macro outlook – views across the street (synthesis 2026 outlook reports)

https://2026macro.vercel.app/
1•OxfordOutlander•1h ago•1 comments

Would You Kill for a Job?

https://www.nytimes.com/2025/12/27/opinion/no-other-choice-work-unemployment.html
2•mitchbob•1h ago•4 comments

Replacing JavaScript with Just HTML

https://www.htmhell.dev/adventcalendar/2025/27/
69•soheilpro•1h ago•17 comments

The case of Africa's 'vanishing' carbon deals

https://www.japantimes.co.jp/environment/2025/11/26/climate-change/africa-carbon-deals/
1•PaulHoule•1h ago•0 comments

Software ate the world. Federation will eat embeddings

https://www.gnanaguru.com/p/federation-over-embeddings-let-ai
2•gnanagurusrgs•1h ago•1 comments

Nature and Climate Wins in 2025

https://www.bbc.com/future/article/20251212-seven-quiet-wins-for-climate-and-nature-in-2025
1•kaycebasques•1h ago•0 comments

Show HN: I created a tool to design and create foamcore inserts for boardgames

https://boxinsertdesigner.com/
1•Rabidgremlin•1h ago•0 comments

Show HN: Iris – an AI-powered rental search built specifically for San Francisco

https://www.irisrents.com
2•manan08•1h ago•1 comments

Go Memory Model Deep Dive: What Every Go Developer Must Know

https://skoredin.pro/blog/golang/go-memory-model-deep-dive
1•ibobev•1h ago•0 comments

Building a Plugin System in Go: Make Your Monolith Extensible

https://skoredin.pro/blog/golang/go-plugin-system
1•ibobev•1h ago•0 comments

1Password Chrome extension is incorrectly manipulating <code> blocks

https://www.1password.community/discussions/developers/1password-chrome-extension-is-incorrectly-...
3•josephscott•1h ago•1 comments

Vaccinated dog tests positive for rabies, at least 13 people PEP so far

https://www.cookcountyil.gov/news/cook-county-department-animal-and-rabies-control-confirms-rabie...
19•stockresearcher•1h ago•2 comments

Realtime Raytracing in Bevy 0.18 (Solari)

https://jms55.github.io/posts/2025-12-27-solari-bevy-0-18/
1•ibobev•1h ago•0 comments

It's an Active Choice to Lie This Much – Micron's "Commitment" to Gamers [video]

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

Show HN: What 4M posts reveal about going viral on Hacker News

https://hn-ph.vercel.app
19•salebanolow•1h ago•3 comments

AI data centers may soon be powered by retired Navy nuclear reactors

https://www.tomshardware.com/tech-industry/startup-proposes-using-retired-navy-nuclear-reactors-f...
2•pabs3•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.