frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

A web and multimedia discovery, code search and local file exploration

https://kurzioai.vercel.app/
1•curzio•1m ago•0 comments

OpenAI Usage Reset 4th time in 7d

1•bavovna•6m ago•0 comments

Ten Ways NAS Is Getting Enshitified

https://nascompares.com/2026/07/31/the-10-ways-nas-is-getting-enshitified/
1•giuliomagnifico•6m ago•0 comments

LLMs can't trade and higher reasoning doesn't help

https://twitter.com/RRicefan/status/2082513323489202664
1•tosh•7m ago•0 comments

Thomson Reuters Built Its Own AI Model That Now Ranks Among the Best

https://www.thomsonreuters.com/en-us/posts/innovation/thomson-reuters-built-its-own-ai-model-that...
1•doener•7m ago•0 comments

PostgreSQL and the Linux OOM Killer: A Better Default

https://clickhouse.com/blog/strict-memory-overcommit-for-postgres
1•saisrirampur•9m ago•0 comments

Why one of the best mathematicians is joining OpenAI

https://www.theatlantic.com/technology/2026/07/jacob-tsimerman-math-fields-medal-openai/688120/
1•bryan0•10m ago•0 comments

The Four Horsemen of the AI Bubble Apocalypse

https://www.derekthompson.org/p/the-four-horsemen-of-the-ai-bubble
1•nreece•14m ago•0 comments

I told Codex to prove everything. And the proof ate the project

https://github.com/nelsonwerd/proof-ate-the-project
1•nelsonwerd•19m ago•0 comments

The AI Data Center Explained – From Electricity to ChatGPT [video]

https://www.youtube.com/watch?v=ckoi0RTEgcY
1•chirau•23m ago•0 comments

Show HN: Best Books Guide – curated books list with tracking, rating, reviews

https://bestbooks.guide/
1•gste•27m ago•0 comments

Turtle Type

https://john.fun/turtles
1•memalign•27m ago•0 comments

Battle of the Beams

https://en.wikipedia.org/wiki/Battle_of_the_Beams
2•petethomas•30m ago•0 comments

EU considers emergncy meeting as nuclear shutdown leaves HU facing energy crisis

https://www.euronews.com/my-europe/2026/07/31/eu-considers-emergency-meeting-as-nuclear-shutdown-...
3•Markoff•31m ago•1 comments

Term-wm: Cross-platform floating/tiling terminal window multiplexer

https://crates.io/crates/term-wm
1•zombiej5•34m ago•0 comments

Show HN: Equivalency Kernel – mapping emotions to recursive system states

https://github.com/jamesberge-coder/equivalency-kernel
1•jamesberge•37m ago•0 comments

Global Call Threat Report (2025) [pdf]

https://work.hiya.com/hubfs/2025/Global%20Call%20Threat%20Report_2025Q2.pdf
1•dredmorbius•37m ago•1 comments

Virtual accelerated GPU device for macOS VMs

https://reims-vgpu.com/
2•vsrinivas•42m ago•1 comments

How to Build a Real-Time Indexing Pipeline with Redis and PostgreSQL 19

https://bytepith.com/article/postgresql-19-fixes-notify-redis-pipelines-scale
1•khanhnguyen8386•50m ago•0 comments

Geometric Dimensioning and Tolerancing

https://en.wikipedia.org/wiki/Geometric_dimensioning_and_tolerancing
1•electricboots•54m ago•0 comments

Oslo Report

https://en.wikipedia.org/wiki/Oslo_Report
2•petethomas•57m ago•0 comments

The coming de-enshittification boom (2025)

https://blog.zgp.org/de-enshittification/
1•ludicrousdispla•1h ago•0 comments

Fine-Tuning from First Principles: LoRA, QLoRA, Serverless Fine-Tuning

https://debnsuma.github.io/my-blog/posts/lora-serverless-fine-tuning/
1•eigenBasis•1h ago•0 comments

Hardening Google Cloud IAM with CEL Conditions and Deny Policies

https://cloud.google.com/blog/topics/developers-practitioners/generosity-under-conditions-hardeni...
1•minherz•1h ago•0 comments

What’s new in Svelte: August 2026

https://svelte.dev/blog/whats-new-in-svelte-august-2026
1•ErenayDev•1h ago•0 comments

What Liberal Arts Education Is for (2024)

https://innig.net/teaching/liberal-arts-manifesto
10•mr_wiglaf•1h ago•6 comments

SuperDuperer

https://www.shirt-pocket.com/blog/supererduperer
1•MBCook•1h ago•0 comments

A LangGraph pipeline that generates compiling Flutter apps (with a repair loop)

https://github.com/carlosge492/app-generation-microservice
1•m2magents•1h ago•0 comments

Arch Linux AUR Package Adoptions Halted

https://www.phoronix.com/news/Arch-Linux-AUR-Adoptions-Halted
3•wanderer2323•1h ago•0 comments

Mastodon new TOS: we may restore your self-deleted content from backup

https://mastodon.social/terms-of-service/2026-08-31
4•meysamazad•1h ago•1 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.