frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Show HN: Occulta – cryptographic contacts exchanged in person via UWB

https://github.com/aibo-cora/occulta
1•ghafla•30s ago•0 comments

How We Made Object Storage Faster Than ClickHouse for Log Search

https://cardinalhq.io/blog/object-storage-faster-than-clickhouse-for-log-search
1•chipfixer•1m ago•0 comments

PS1 Game on ESP32-S3

https://www.reddit.com/r/embedded/s/vkgFuZviRD
1•dmonterocrespo•3m ago•0 comments

Show HN: Giving voice agents a voice that adapts to context

https://gradium.ai/demos/voice-design-demo/
1•segu•4m ago•0 comments

Show HN: The whole Solar System and every tracked satellite, live in the browser

https://space.bl2.net/
2•wanick•5m ago•1 comments

How Long Will the AI Boom Last? Memory Stocks Offer Clues

https://www.wsj.com/tech/ai/how-long-will-the-ai-boom-last-memory-stocks-offer-clues-622be948
2•fortran77•7m ago•1 comments

Designing a Programming Language for the AI Era

https://zena-lang.dev/blog/2026/09/languages-for-the-ai-era/
1•jakelazaroff•7m ago•0 comments

The Graveyard of Good Ideas [video]

https://www.youtube.com/watch?v=ovlQ81rBc-4
1•ibobev•7m ago•0 comments

Dot.com Is Grokbot

https://twitter.com/elie2222/status/2104984753472516595
1•china•8m ago•0 comments

The Greatest Pun: JavaScript's ${{ }} tagged template literal

https://shukla.io/blog/2026-09/pun.html
1•ibobev•8m ago•0 comments

Yet Another AI Security OSS Externality

http://blog.holdenkarau.com/2026/09/yet-another-ai-security-oss-externality.html
2•holdenk•8m ago•0 comments

Can we have reachability properties in TLA⁺?

https://ahelwer.ca/post/2026-09-26-reachability/
1•ibobev•8m ago•0 comments

The Case for Drug Abundance

https://www.averincapital.com/insights/the-case-for-drug-abundance
1•brandonb•10m ago•0 comments

Qualcomm's System Level Architecture in the Snapdragon X2 Elite

https://chipsandcheese.com/p/qualcomms-system-level-architecture
1•pella•10m ago•0 comments

Reference Design Downloads

https://www.kkdatasvc.com/lab/downloads/
1•cowlove•11m ago•0 comments

Diffusion Controller unifies and simplifies AI image generation

https://research.google/blog/how-diffusion-controller-unifies-and-simplifies-ai-image-generation/
1•Hussain04•11m ago•0 comments

As a freelancer, what happens when the door won't open any more?

https://lajosmoczar.substack.com/p/as-a-freelancer-what-happens-when
1•DevOpsMaster•11m ago•0 comments

OpenJev: An open-source, Jev-compatible System One decision engine

https://github.com/GPT-AGI/OpenJev
2•rdudekul•14m ago•0 comments

CEO

1•cowlove•15m ago•0 comments

PotemkinOS: An Operating System Where the Model Writes the Userland

https://gabeortiz.net/posts/2026-09-27-potemkinos/
2•succinct_ideas•16m ago•1 comments

Prime SaaS: New Modern React, Node, PostgreSQL Boilerplate

1•missakation•17m ago•0 comments

China accounts for 77.9% of global humanoid robot shipments in H1, IDC says

https://technode.com/2026/09/29/china-accounts-for-77-9-of-global-humanoid-robot-shipments-in-h1-...
2•yogthos•17m ago•0 comments

Claude Isn't Allowed to Write Me Prose

https://blog.kvit.app/posts/agent-not-allowed-to-write-prose/
1•skolos•20m ago•0 comments

Religion, Consciousness, and Continuity

https://www.alexahn.com/2026/09/religion-consciousness-and-continuity.html
1•alexahn•20m ago•0 comments

Rasmus Hauschild on X: "just vibe-coded a flight simulator in ~2 hours

https://twitter.com/rasmushauschild/status/2077483318937862336
1•bilsbie•20m ago•0 comments

How to do agentic software development properly

https://fiodar.substack.com/p/the-art-of-agentic-software-development
1•fiodars•21m ago•1 comments

Blygger: AI-intertwingled diachronic-synchronic social publishing – blygger

https://blygger.org/talks/2026-09-24-blygger/
1•Arubis•21m ago•0 comments

Ask HN: Fong Test?

2•gojkoa•21m ago•0 comments

GPT-6.1 Sol: Release Intelligence, Performance and Price

https://artificialanalysis.ai/models/releases/gpt-6-1-sol
2•6thbit•23m ago•0 comments

Ask HN: OpenSEO inspiration for other tools, asking for opinion

2•yash_salesup•23m 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.