frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

How hotels are stopping the 'dawn dash' for sunbeds after man wins payout

https://www.bbc.co.uk/news/articles/c99l17m2ep9o
1•gbxyz•40s ago•0 comments

Manufacturing qubits that can move

https://arstechnica.com/science/2026/05/manufacturing-qubits-that-can-move/
1•rippeltippel•2m ago•0 comments

Axavive Reviews: "Gut–Skin Miracle" or Just Hype? Expert Insights

https://finance.yahoo.com/sectors/healthcare/articles/axavive-skin-exploding-2026-golden-22590060...
1•larxdalu•4m ago•0 comments

Built a safety-first AI trader for covered calls and cash-secured puts

https://puthouse.com
1•jansonlau•4m ago•1 comments

Constrained Decoding: Forcing LLMs to Respect Your Taxonomy

https://pub.towardsai.net/constrained-decoding-forcing-llms-to-respect-your-taxonomy-3aaaf13329f9
1•sachinkalsi•5m ago•0 comments

Matt Godbolt: The Bits Between the Bits: How We Get to Main [video]

https://www.youtube.com/watch?v=dOfucXtyEsU
1•dalleh•5m ago•0 comments

Traceway: MIT-licensed observability stack you can self-host in ~90s

https://github.com/tracewayapp/traceway
1•sebakubisz•6m ago•0 comments

Mythos Discovered a CVE in Its Training Data – and That's Still Worrying

https://rival.security/posts/mythos-discovered-a-cve-already-in-its-training-data---and-thats-sti...
2•chris_j•7m ago•0 comments

How long do we wait for new inventions?

https://www.construction-physics.com/p/how-long-do-we-wait-for-new-inventions
2•gwintrob•10m ago•0 comments

Nanonumpy: Build a tiny NumPy to understand vectorization

https://github.com/AdilZouitine/nanonumpy
2•AdilZtn•11m ago•0 comments

simdjson

https://github.com/simdjson/simdjson
1•tosh•11m ago•0 comments

Evolved antennas, LLM-generated code, and a potential antifuture

https://ericwbailey.website/published/evolved-antennas-llm-generated-code-and-a-potential-antifut...
1•tobr•12m ago•0 comments

The 90 Day disclosure policy is dead

https://blog.himanshuanand.com/2026/05/the-90-day-disclosure-policy-is-dead/
1•r4um•13m ago•0 comments

Create a 90s Geocities themed static website in seconds

https://www.npmjs.com/package/create-geocities-app
1•whatsupdog•14m ago•0 comments

It doesn't matter if it looks good

https://yosemitesam.ch/it-doesnt-matter-if-it-looks-good/
3•Melkor333•15m ago•1 comments

I knew my writing students used AI. Their confessions led to a teaching moment

https://www.theguardian.com/us-news/ng-interactive/2026/may/10/fiction-writing-professor-ai
3•Michelangelo11•16m ago•0 comments

Make Claude Code Sing

https://github.com/harajlim/vibe-sing
2•mharajli•17m ago•1 comments

Preserving Fisher-Price Pixter

https://dmitry.gr/?r=05.Projects&proj=37.%20Pixter
2•dmitrygr•18m ago•0 comments

Self

https://en.wikipedia.org/wiki/Self_(programming_language)
1•tosh•18m ago•0 comments

Why Attitudes Towards Intelligence Matter in Universities

1•AroosaKhalil•20m ago•0 comments

Strong Views on PostgreSQL VIEWs

https://boringsql.com/posts/strong-views/
1•radimm•21m ago•0 comments

Five years before I saw Smalltalk

https://lists.selflanguage.org/pipermail/self-interest/2020-November/004777.html
1•tosh•25m ago•0 comments

Agent Patterns for AI Agent Development

https://agentpatterns.ai/
1•ankitg12•26m ago•0 comments

AI Agents Have Two Souls. You Only Control One

https://auth0.com/blog/ai-agents-have-two-souls-you-control-only-one/
1•andychiare•28m ago•0 comments

Mythos Finds a Curl Vulnerability

https://daniel.haxx.se/blog/2026/05/11/mythos-finds-a-curl-vulnerability/
3•TangerineDream•31m ago•0 comments

The 1,001 Days of the Turkey

1•DIGITALIGENCE•32m ago•0 comments

Software Development Is Becoming a Factory Job

https://www.vincentschmalbach.com/software-development-is-becoming-a-factory-job/
3•vincent_s•34m ago•0 comments

Predictions about AI and software development

https://adamfletcher.com/writing/10-ai-predication-may-2026/
3•afletcher•37m ago•0 comments

Spec-Driven Development with Spec Kit and Claude Code

https://medium.com/vibecodingpub/spec-driven-development-with-spec-kit-and-claude-code-7e2957fd2c9b
2•SaeedZF•37m ago•0 comments

South Park Theme Song Remix

https://www.youtube.com/watch?v=GWmU7tW_0RQ
2•ninjahawk1•43m 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.