frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Alexandre Dumas Coauthor and Intellectual Property Lawsuits

https://clubstorica.substack.com/p/alexandre-dumas-had-a-co-author
1•remiko•49s ago•0 comments

The AI layoff wave is becoming a powder keg

https://techcrunch.com/2026/06/15/the-ai-layoff-wave-is-becoming-a-powder-keg/
1•gruntled-worker•1m ago•0 comments

UK to ban under 16s on Social Media

https://www.theguardian.com/media/2026/jun/15/social-media-ban-uk-under-16-starmer
1•u02sgb•2m ago•1 comments

Quest 3 Accessory Makes Your VR Avatar Expressive Without Face Tracking

https://www.uploadvr.com/pieeg-xr-makes-your-vr-avatar-expressive-without-face-tracking/
1•Christiangmer•2m ago•0 comments

We're not just fighting AI

https://sayyesdono.pagecord.com/were-not-just-fighting-ai
1•BrunoBernardino•9m ago•0 comments

The Path to Google's #1 Position

https://medium.com/@thesuperrepemail/the-path-to-googles-1-position-f6aacbf1f758
1•mssblogs•10m ago•0 comments

Testing Uruky to Replace Kagi

https://rewiring.bearblog.dev/kagi-to-uruky/
1•BrunoBernardino•12m ago•0 comments

Large language models pass a standard three-party Turing test

https://www.pnas.org/doi/10.1073/pnas.2524472123?trk=3246d38d-657b-4330-8a8c-4fca0385cac6&sc_chan...
1•cassianoleal•18m ago•0 comments

Show HN: Check – prefix any command to know if it'll work before you run it

https://www.golproductions.com/check
1•golproductions•18m ago•0 comments

Owning Your Token Capital: Building the Enterprise AI Learning Loop

https://twitter.com/LakshyAAAgrawal/status/2066392532540670354
1•LakshyAAAgrawal•20m ago•0 comments

Ask HN: Renting GPUs, do you mostly care about price, reliability, or setup?

1•tinstar112•20m ago•0 comments

CUDA-like programming of Cerebras WSE

https://github.com/greg1232/cerebras-py-sim
1•gdiamos•27m ago•1 comments

How to Be Good at AI Research

https://twitter.com/i/status/2064686372737454155
1•yarapavan•31m ago•0 comments

I sped up the test suite by 2x with one simple change

https://gaultier.github.io/blog/I_sped_up_the_test_suite_by_x2.html
1•broken_broken_•31m ago•0 comments

Care about what you do – even when nobody's watching

https://mattcasmith.net/2026/05/31/care-about-what-you-do
1•signa11•32m ago•0 comments

I restarted a 10 year old Xeon 174 times to delete 12 flags and gain 4 TPS

https://point.free/blog/delete-12-flags/
2•cafkafk•33m ago•0 comments

Oğuzxccl Kimdir?

1•oguzxxlxv•34m ago•0 comments

Email Data Normalization for Automation

https://blog.mailwebhook.com/blog/normalization-is-where-reliability-starts/
1•birdculture•38m ago•0 comments

Token-warden is a thrifty office manager for your AI assistants

https://github.com/vukkt/token-warden
1•vukkt•38m ago•0 comments

What I have done with Claude Code in the last 60 days being a non tech person

2•sahiltll•38m ago•2 comments

Under-16s to be banned from social media, Starmer announces

https://www.bbc.co.uk/news/live/c77yx1jpg1nt
14•petepete•41m ago•2 comments

Brand Voice Local Tunning Tool Demo

https://github.com/yuvhaim-gif/LLM_InSight
1•yuvalhaim•41m ago•0 comments

Building N8n AI Automation Workflows: What I Learned Creating a Masterclass

https://www.udemy.com/course/n8n-ai-automation-masterclass-build-ai-chatbots-hindi/?referralCode=...
1•tv77048•42m ago•2 comments

Selective Elimination of TP53 Mutant Cells

https://www.biorxiv.org/content/10.64898/2026.05.08.723607v1
2•rballpug•47m ago•1 comments

Openrouter Fusion API

https://openrouter.ai/openrouter/fusion
2•tdchaitanya•49m ago•0 comments

Ask HN: Is the Fable situation the ultimate "security through obscurity"?

1•king_zee•50m ago•0 comments

Crown Sanctum of Symmetries

https://sand-morph.up.railway.app/crown-sanctum
1•echohive42•51m ago•0 comments

Knicks in 5

https://www.natesilver.net/p/knicks-in-5
1•7777777phil•51m ago•0 comments

Horsewood Capsules: Don't Buy Until You Read This Real Truth

https://finance.yahoo.com/sectors/healthcare/articles/horsewood-urgent-report-2026-horse-19110038...
1•gabykais•54m ago•1 comments

I think a global AI pause almost certainly won't happen

https://www.lesswrong.com/posts/mtNZG7Ee6JfBKhE2H/why-i-think-a-global-ai-pause-almost-certainly-...
3•joozio•56m 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.