frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

AI-Native vs. Anti-AI Engineers

1•grandimam•1m ago•0 comments

The Navigational Triangle

https://www.johndcook.com/blog/2025/12/04/the-navigational-triangle/
1•ibobev•1m ago•0 comments

Me vs. the VNC Guy

https://martinrue.com/coding-stories-me-vs-vnc/
1•afisxisto•1m ago•0 comments

Solving Spherical Triangles

https://www.johndcook.com/blog/2025/12/04/solving-spherical-triangles/
1•ibobev•2m ago•0 comments

Google Antigravity wipes user's HDD

https://www.tomshardware.com/tech-industry/artificial-intelligence/googles-agentic-ai-wipes-users...
1•jihadjihad•2m ago•0 comments

NY judge orders OpenAI to hand over ChatGPT conversations in win for newspapers

https://www.nydailynews.com/2025/12/03/ny-judge-orders-openai-to-hand-over-chatgpt-conversations-...
1•Cyclone_•2m ago•0 comments

Show HN: ~$ root-dir closed beta is live – a command-line community for devs

https://www.root-dir.com
1•madsmadsdk•3m ago•0 comments

From Zero to Package in Seconds: The New Conan MCP Server

https://blog.conan.io/mcp/ai/gpt/conan/conan-mcp/2025/12/04/From-Zero-to-Package-in-Seconds-the-n...
2•ibobev•3m ago•0 comments

A quine made with Nix and HTML

https://embedding-shapes.github.io/niccup/examples/quine/demo/
1•embedding-shape•3m ago•1 comments

Show HN: Feedvote – A feedback board with deep 2-way Linear/Jira sync

https://feedvote.app
1•dragssine•5m ago•0 comments

Why One Man Is Fighting for Our Right to Control Our Garage Door Openers

https://www.nytimes.com/2025/12/04/technology/personaltech/why-one-man-is-fighting-for-our-right-...
2•tysone•7m ago•0 comments

We Know the Time of Day on Mars

https://nautil.us/we-finally-know-the-time-of-day-on-mars-1252640/
1•fleahunter•8m ago•0 comments

Grothendieck's Activism and What It Says About the World

https://golem.ph.utexas.edu/category/2014/11/grothendiecks_activism_and_wha.html
1•robot-wrangler•9m ago•0 comments

Show HN: Claude-ping – a WhatsApp bridge for Claude Code

https://github.com/conbon/claude-ping
2•conbon_•11m ago•0 comments

Mapping the Missile Fields

https://www.nps.gov/articles/mappingmissilefield.htm
1•debo_•11m ago•0 comments

Becoming Unblockable

https://www.seangoedecke.com/unblockable/
1•dondraper36•12m ago•0 comments

AI chatbots can sway voters better than political advertisements

https://www.technologyreview.com/2025/12/04/1128824/ai-chatbots-can-sway-voters-better-than-polit...
1•gnabgib•12m ago•0 comments

Django 6 Released

https://docs.djangoproject.com/en/6.0/releases/6.0/
4•wilhelmklopp•12m ago•0 comments

Why Sell Lifetime Plans, in a Default Subscription World?

https://pketh.org/lifetime-plans.html
1•speckx•12m ago•0 comments

Samsung Could Convert Some HBM3E Capacity to Regular DRAM to Meet AI Demand

https://www.techpowerup.com/343642/samsung-could-convert-some-hbm3e-capacity-to-regular-dram-to-m...
2•walterbell•13m ago•0 comments

Why Ed(1)?

https://blog.thechases.com/posts/cli/why-ed1/
1•todsacerdoti•13m ago•0 comments

SpaceHey – A Space for Friends

https://spacehey.com
1•rickcarlino•15m ago•0 comments

Strategizing for My LLC

https://andys.blog/strategizing/
1•andytratt•16m ago•0 comments

CUDA-L2: Surpassing cuBLAS Performance for Matrix Multiplication Through RL

https://github.com/deepreinforce-ai/CUDA-L2
3•dzign•17m ago•0 comments

Predator spyware uses new infection vector for zero-click attacks

https://www.bleepingcomputer.com/news/security/predator-spyware-uses-new-infection-vector-for-zer...
4•speckx•19m ago•0 comments

What's new in Pandas 3.0.0 (Month XX, 2025)

https://pandas.pydata.org/docs/dev/whatsnew/v3.0.0.html
1•Anon84•20m ago•0 comments

A Visualizer for Blockchains

https://www.blockchainemulator.com/
1•crc_error•20m ago•0 comments

AI-Written CUDA Kernels Outperforms Nvidia's Best Matmul Library

https://www.rohan-paul.com/p/breakthrough-research-enables-ai
3•dzign•21m ago•0 comments

Fairphone open-sources Fairphone 5 and 6 software, and Moments switch

https://www.fairphone.com/en/2025/12/04/were-big-fans-of-open-source-buildable-code-at-fairphone-...
5•todsacerdoti•21m ago•0 comments

Show HN: I Built an UI Library that lets you create beautiful UIs in Minutes

https://ogblocks.dev/
2•karanzkk•22m ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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