frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Testing Vue Components in the Browser

https://jvns.ca/blog/2026/05/02/testing-vue-components-in-the-browser/
1•ibobev•1m ago•0 comments

Links to CSS Colour Palettes

https://jvns.ca/blog/2026/05/04/css-colour-palettes/
1•ibobev•1m ago•0 comments

Hiker finds 6th C. gold sword fitting

https://www.thehistoryblog.com/archives/76004
2•speckx•1m ago•0 comments

Kids can't use computers and this is why it should worry you (2013)

http://www.coding2learn.org/blog/2013/07/29/kids-cant-use-computers/
1•downbad_•2m ago•1 comments

Nobody understands the point of hybrid cars [video]

https://www.youtube.com/watch?v=KnUFH5GX_fI
1•CharlesW•2m ago•0 comments

Show HN: AI Generated Videos for your Code diffs

https://steerable.dev/
1•bmusuku•3m ago•0 comments

Is AI 2027 coming true?

https://secondthoughts.ai/p/is-ai-2027-coming-true
1•baxtr•3m ago•0 comments

Clozure CL

https://ccl.clozure.com/
1•tosh•3m ago•0 comments

The Fallacy of Premature Optimization (2009)

https://ubiquity.acm.org/article.cfm?id=1513451
1•downbad_•3m ago•1 comments

WebTransport is now available across all major browsers

https://caniuse.com/?search=webtransport
1•apitman•3m ago•0 comments

OpenAI launches GPT-Realtime-2

https://twitter.com/OpenAI/status/2052438194625593804
1•vthallam•4m ago•0 comments

Natural Language Autoencoders

https://www.neuronpedia.org
1•pretext•5m ago•0 comments

Build a Beeper Bridge

https://blog.beeper.com/2025/10/28/build-a-beeper-bridge/
1•luu•7m ago•0 comments

Lisp in Space (2022)

https://www.corecursive.com/lisp-in-space-with-ron-garret/
1•tosh•7m ago•0 comments

Memory Arena – AI coding agents that learn from past tournaments

https://memoryarena.xyz/arena
1•casanovaabraham•7m ago•0 comments

Lumon Terminal – A Severance-Inspired Apple Terminal Theme

https://github.com/onehorizonai/lumon-terminal
1•gusnewman•8m ago•1 comments

Show HN: Live SEO monitoring dashboard in 100 lines of Python

https://seoscoreapi.com/demo/dashboard
1•avansledright•9m ago•0 comments

Two OpenClaw Agents Negotiate a YC SAFE with Agentic Power of Attorney

https://www.juanfiguera.com/notes/system-prompt-and-vibes/
1•juanfiguera•10m ago•0 comments

Notes on the xAI/Anthropic data center deal

https://simonwillison.net/2026/May/7/xai-anthropic/
2•droidjj•11m ago•0 comments

Show HN: Bundlebase – Docker for Data

https://nvoxland.github.io/bundlebase/
2•nvoxland•12m ago•0 comments

The Self Is an Evolutionary Engineering Solution – What Does This Mean for LLMs?

https://darkomulej.substack.com/p/four-roads-to-a-vanishing-self
1•Darius-BC•12m ago•0 comments

How to Build an Agent Platform

https://www.ashpreetbedi.com/agent-platform
2•yashsolanky•12m ago•0 comments

Bell fires small number of employees who allegedly falsified attendance

https://mobilesyrup.com/2026/05/06/bell-employees-fired-in-office-mandate/
1•milkglass•13m ago•0 comments

Advancing voice intelligence with new models in the API

https://openai.com/index/advancing-voice-intelligence-with-new-models-in-the-api/
6•meetpateltech•14m ago•0 comments

JavaScript server-side interoperability with rcompat

https://bytecode.news/posts/2026/05/javascript-server-side-interoperability-with-rcompat
6•terrablue•16m ago•0 comments

The case against bearer secrets

https://credctl.com/blog/vercel-context-ai-breach/
1•matzhouse•17m ago•0 comments

OpenAI's WebRTC Problem

https://moq.dev/blog/webrtc-is-the-problem/
2•atgctg•17m ago•0 comments

Tesla's 4680 battery cells are underperforming and frustrating buyers

https://electrek.co/2026/05/07/tesla-4680-battery-cell-performance-data-shows-cant-build-own-cells/
2•Klaster_1•19m ago•0 comments

Show HN: Airlock – self-upgrading compiled AI agents

https://github.com/airlockrun/airlock/
2•cyberteaborg•19m ago•0 comments

The balcony solar boom is coming to the US

https://www.technologyreview.com/2026/05/07/1136933/balcony-solar-boom/
1•Brajeshwar•19m ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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