frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Why I still teach OpenGL ES 3.0

https://eliasfarhan.ch/jekyll/update/2026/01/27/why-i-teach-opengles.html
1•abnercoimbre•41s ago•0 comments

Show HN: employkids – Hire your kids so they can retire millionaires (legally)

https://employkids.com/
1•jfeng5•1m ago•0 comments

Bonus 203: Correcting the Record in the Social Security/DOGE Case

https://www.stevevladeck.com/p/bonus-203-correcting-the-record-in
1•hn_acker•3m ago•0 comments

My app is going viral and hitting the Google books API quota

1•iboshidev•5m ago•1 comments

Had LLM/AI build an unbiased quiz: Where in the World Should I Live?

https://dev.mkn.us/world.html
1•mknweb•6m ago•0 comments

Theorizer: Turning Papers into Scientific Laws

https://allenai.org/blog/theorizer
1•headalgorithm•6m ago•0 comments

Show HN: Free On-Device AI SDK to Run PyTorch on Mobile NPUs (Open Source)

https://github.com/zetic-ai/ZETIC_MLange_apps
1•kimys1324•8m ago•0 comments

LM Studio 0.4.0

https://lmstudio.ai/blog/0.4.0
1•jiqiren•9m ago•1 comments

Building a CAD Kernel in One Night

https://campedersen.com/brep-kernel
2•ecto•10m ago•1 comments

White hat astroturfed #1 ClawdBot/MoltBot skill that can pwn all users

https://twitter.com/llmjunky/status/2016032497629319404
1•EGreg•11m ago•1 comments

VisualJJ – Jujutsu in Visual Studio Code

https://www.visualjj.com/
3•demail•11m ago•0 comments

Groop – No AI. No Influencers. No Algorithms. No Tracking

https://www.joingroop.app/
1•sampsn•12m ago•3 comments

Apple plans to launch AI-powered wearable pin device as soon as 2027

https://arstechnica.com/apple/2026/01/report-apple-plans-to-launch-ai-powered-wearable-pin-device...
2•mpweiher•13m ago•0 comments

Show HN: A single command to run Claude Code inside Lima VMs

https://github.com/sylvinus/agent-vm
1•sylvinus•13m ago•0 comments

Show HN: I'm building an AI-proof writing tool. How would you defeat it?

https://auth-auth.vercel.app/
1•callmeed•13m ago•0 comments

Britain's Strategic Limbo

https://notes.philippdubach.com/0016
2•7777777phil•14m ago•0 comments

Memory justifications provide valid indicators of retrieval accuracy across time

https://www.nature.com/articles/s44271-025-00378-4
1•PaulHoule•14m ago•0 comments

I don't know why I fixed this

https://www.youtube.com/watch?v=WNOOJvelkcE
1•iamflimflam1•15m ago•0 comments

Trump's use of AI images pushes boundaries, erodes public trust, say experts

https://apnews.com/article/ai-videos-trump-ice-artificial-intelligence-08d91fa44f3146ec1f8ee4d213...
4•randycupertino•17m ago•2 comments

Show HN: Deploying Helm charts without fear

https://github.com/avkcode/helmer
1•KyleVlaros•17m ago•0 comments

Artemis II–first manned moon mission in 52 years–could launch as early as Feb 6

https://www.nytimes.com/2026/01/28/travel/florida-artemis-ii-moon-launch.html
2•bookofjoe•18m ago•1 comments

Show HN: Ghostly: The Ultimate Platform for Ghosting Candidates (Satire)

https://staticfile-25978.wasmer.app/
1•dw1014•19m ago•0 comments

Neuralink has had 21 'Neuralnauts' in the past 2 years

https://neuralink.com/updates/two-years-of-telepathy/
1•ryzvonusef•19m ago•0 comments

Reasoning About Things Without Choosing Them

https://cognitivelayer.substack.com/p/chasing-the-ghosts-of-choice
1•CortexFlow•19m ago•0 comments

That's Not How Email Works, HSBC

https://danq.me/2026/01/28/hsbc-dont-understand-email/
7•HotGarbage•20m ago•0 comments

Show HN: Built an app to replace our failed group podcast experiment

https://roadsaudio.com/college
1•1manstartup•20m ago•0 comments

Native Instruments in Preliminary Insolvency

https://www.gearnews.com/native-instruments-insolvency/
3•thomas_witt•20m ago•0 comments

The new era of browsing: Putting Gemini to work in Chrome

https://blog.google/products-and-platforms/products/chrome/gemini-3-auto-browse/
5•xnx•20m ago•0 comments

Attached to Tragedy: Tracing Challenger "Remove Before Flight" Tags

https://arstechnica.com/space/2026/01/attached-to-tragedy-tracing-challenger-remove-before-flight...
1•LorenDB•21m ago•0 comments

Show HN: I built an AI companion to stop doomscrolling and regulate anxiety

https://mynomie.com/
1•liaai0630•21m ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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