frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

White House and Anthropic hold meetings over Mythos model

https://www.bbc.com/news/articles/cyv10e1d13po
1•_josh_meyer_•1m ago•0 comments

The Business Plot of 1933

https://en.wikipedia.org/wiki/Business_Plot
3•Jimmc414•4m ago•0 comments

Channel decorrelation: 52.8% reduction across Kodak suite, no ML or codec mods [pdf]

https://github.com/PearsonZero/asymmetric-channel-decorrelation/blob/main/baetzel_2026_kodak_benc...
1•PearsonZero•11m ago•0 comments

The nine-to-five PhD: mere myth or an achievable goal?

https://www.nature.com/articles/d41586-026-00509-9
2•jyunwai•15m ago•0 comments

Effective Conversational AI Book: Detailed Review

https://noroinsight.com/effective-conversational-ai-book-review/
1•teleforce•20m ago•0 comments

Show HN: Small, an x402 powered writing site

https://getsmall.xyz/
2•trezm•26m ago•0 comments

Claude Experiment "PersMEM" Rep5: The Distributional Bias and the Third Instance

1•asixicle•30m ago•0 comments

Ketamine for negative and depressive symptoms in schizophrenia

https://www.frontiersin.org/journals/psychiatry/articles/10.3389/fpsyt.2026.1766485/full
1•PaulHoule•32m ago•0 comments

Human Accelerated Regions

https://en.wikipedia.org/wiki/Human_accelerated_regions
1•rolph•32m ago•0 comments

The rate trap: how one architecture decision kills flexibility

https://github.com/getlago/lago/wiki/The-rate-trap:-how-one-architecture-decision-kills-flexibility
1•danoandco•32m ago•0 comments

H.R.8250 Parents Decide Act – trying to force OS age verification US-wide

https://old.reddit.com/r/pcmasterrace/comments/1so9wm8/hr8250_parents_decide_act_this_is_bad/
1•LorenDB•34m ago•1 comments

Diving into Starlink's User Terminal Firmware

https://blog.quarkslab.com/starlink.html
4•techgq•40m ago•0 comments

New AI-generated videos of Iran war spread across social media

https://www.youtube.com/watch?v=0mKCBAM4wZs
1•mgh2•49m ago•0 comments

Traders place $760M bet on falling oil ahead of Hormuz announcement

https://www.reuters.com/sustainability/boards-policy-regulation/traders-place-760-million-bet-fal...
6•Jimmc414•54m ago•1 comments

Show HN: I made a calculator that works over disjoint sets of intervals

https://victorpoughon.github.io/interval-calculator/
2•fouronnes3•1h ago•1 comments

Casus Belli Engineering

https://marcosmagueta.com/blog/casus-belli-engineering/
4•b-man•1h ago•0 comments

The Bureaucrats Won't Be Toppled: Revolts No Longer Work

https://unherd.com/2025/09/why-the-bureaucrats-wont-be-toppled/
4•barry-cotter•1h ago•1 comments

Infinite Velocity

https://cube-drone.com/posts/2026/infinite_velocity/
2•tapoxi•1h ago•0 comments

Madison Square Garden's Surveillance Machine

https://www.wired.com/story/madison-square-garden-jim-dolan-surveillance-machine/
4•c420•1h ago•4 comments

Why LLMs Aren't Giving You the Result You Expect

https://akitaonrails.com/en/2026/04/15/how-to-talk-to-claude-code-effectively/
3•vinipolicena•1h ago•0 comments

The parking lot that's keeping the lights on

https://www.begiant.ca/stories/places/solar-parking-lots-energy-emissions
2•Teever•1h ago•0 comments

Reflecting on my own strange year at Uber

https://anon-ex-uber.medium.com/reflecting-on-my-own-strange-year-at-uber-e73165422245
14•anon-ex-uber•1h ago•0 comments

Education research is weak and sloppy. Why?

https://www.theargumentmag.com/p/education-research-is-weak-and-sloppy
3•barry-cotter•1h ago•0 comments

Show HN: Nilbox – Run OpenClaw without exposing your API tokens

https://nilbox.run/
2•rednakta•1h ago•0 comments

The Centaur Era

https://secondthoughts.ai/p/the-centaur-era
1•gk1•1h ago•1 comments

No one can force me to have a secure website [pdf]

https://tom7.org/httpv/httpv.pdf
1•djoldman•1h ago•0 comments

Show HN - TokensAI – Mint for AI Usage

https://tokensai.dev
1•SowjanyaY•1h ago•0 comments

GCC Compiler Adds Arm AGI CPU Target

https://www.phoronix.com/news/GCC-Arm-AGI-CPU
1•Bender•1h ago•0 comments

Linux 7.1 Crypto Code Rework Enables More Optimizations by Default

https://www.phoronix.com/news/Linux-7.1-Crypto
1•Bender•1h ago•0 comments

Wine 11.7 Brings VBScript Fixes, DirectSound 7.1 Channel Support

https://www.phoronix.com/news/Wine-11.7-Released
1•Bender•1h 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.