frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Beads – A memory upgrade for your coding agent

https://github.com/steveyegge/beads
1•latchkey•59s ago•0 comments

Modern Mermaid, a decent flowchart generator for writing documentation

https://modern-mermaid.live/
1•fragmede•8m ago•0 comments

Andrew Kelley removed his "monkeys" and "losers" references

https://web.archive.org/web/20251127021007/https://ziglang.org/news/migrating-from-github-to-code...
2•nikolay•8m ago•0 comments

I solo-developed a Call of Duty event clipper using Python and AI

1•niceshot-ai•22m ago•0 comments

Migrating to Positron, a next-generation data science IDE for Python and R

https://posit.co/blog/positron-migration-guides
3•ionychal•36m ago•1 comments

Show HN: AffiliateGrowthVault: Discover 2000 Affiliate Program Growth Strategies

https://affiliategrowthvault.com/
1•tejas3732•45m ago•0 comments

Can I Port Sonic to the Amiga from the Sega Megadrive?

https://youtu.be/Xb94oUw7_K4
1•bane•46m ago•0 comments

James Webb Space Telescope reveals new view of dying star 'Red Spider Nebula'

https://indianexpress.com/article/technology/science/james-webb-space-telescope-reveals-new-view-...
1•ashishgupta2209•47m ago•0 comments

Pretrain a Bert Model from Scratch

https://machinelearningmastery.com/pretrain-a-bert-model-from-scratch/
3•tzury•49m ago•2 comments

The SWE-Bench Illusion

https://www.microsoft.com/en-us/research/publication/the-swe-bench-illusion-when-state-of-the-art...
4•louiereederson•53m ago•2 comments

GitLab scan finds 17,000 secrets in public repos, leading to $9000+ in bounties

https://trufflesecurity.com/blog/scanning-5-6-million-public-gitlab-repositories-for-secrets
2•adrianwaj•56m ago•0 comments

Japan town retracts bear sighting warning sparked by AI image

https://www.japantimes.co.jp/news/2025/11/27/japan/society/japan-town-retracts-ai-bear-image/
1•geox•1h ago•0 comments

A world map where anyone can plant a digital bonsai

https://www.zen.com.ar/bonsais/
2•elandros•1h ago•2 comments

Pocketbase – open-source realtime back end in 1 file

https://pocketbase.io/
2•modinfo•1h ago•0 comments

Vintage Thanksgiving: Photos Showing How Families Gathered in 1950s and 1960s

https://rarehistoricalphotos.com/vintage-thanksgiving/
3•Brajeshwar•1h ago•0 comments

Show HN: AnyMusic – AI music generator (royalty‑free, songs,stems, lyrics)

https://anymusic.ai
1•lovelycold•1h ago•0 comments

China's BEV Trucks and the End of Diesel's Dominance

https://cleantechnica.com/2025/11/26/chinas-bev-trucks-and-the-end-of-diesels-dominance/
37•xbmcuser•1h ago•4 comments

Japan's human washing machines will go on sale to general public

https://soranews24.com/2025/11/28/japans-human-washing-machines-will-go-on-sale-to-general-public...
3•zdw•1h ago•2 comments

Why can't ChatGPT tell time?

https://www.theverge.com/report/829137/openai-chatgpt-time-date
1•ent101•1h ago•0 comments

OpenAI discloses API customer data breach via Mixpanel vendor hack

https://www.bleepingcomputer.com/news/security/openai-discloses-api-customer-data-breach-via-mixp...
2•DANmode•1h ago•2 comments

Shor's algorithm: the one quantum algo that ends RSA/ECC tomorrow

https://blog.ellipticc.com/posts/what-is-shors-algorithm-and-why-its-the-single-biggest-threat-to...
4•iliasabs•1h ago•0 comments

After such knowledge, what forgiveness?

https://www.stevesailer.net/p/after-such-knowledge-what-forgiveness
3•tartoran•1h ago•2 comments

PpenPanzer: JavaScript/HTML5 rewrite of Panzer General 2 game

https://github.com/nicupavel/openpanzer
2•ibobev•1h ago•0 comments

CiaoTool – No-Code Multi-Chain Token Creation and Management Platform

https://ciaotool.io/en-US
1•CiaoTool•1h ago•1 comments

OpenAI Codex Plan / Spec Mode – We'd Love Your Input

https://github.com/openai/codex/discussions/7355
1•wahnfrieden•1h ago•0 comments

The VPN panic is only getting started

https://www.theverge.com/tech/827435/uk-vpn-restrictions-ban-online-safety-act
49•cebert•1h ago•31 comments

Local LLM based code reviews at Scripbox

https://medium.com/@jpranav97/zero-cost-code-reviews-self-hosted-qwen2-5-coder-on-gitlab-ci-80104...
1•vasuadari•1h ago•1 comments

Tell HN: Gemini 3 found a stack smash in a hex dump that I missed

3•leo_e•1h ago•0 comments

Quantica: A Python-like language with native quantum computing built in

https://github.com/Quantica-Foundation/quantica-lang
2•gurukasi2006•1h ago•0 comments

My car charger can boil water really fast [video]

https://www.youtube.com/watch?v=INZybkX8tLI
1•zdw•1h 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.