frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

MLIR-Tutor: Exercises for Learning MLIR (Originally Written for PPoPP 2026)

https://github.com/Groverkss/mlir-tutor
1•matt_d•1m ago•0 comments

Ask HN: Does anyone have interests in anything besides AI?

1•drsalt•3m ago•1 comments

Resist and Unsubscribe

https://www.resistandunsubscribe.com
2•dougb5•5m ago•0 comments

Effects of Full-Fat and Fermented Dairy Products on Cardiometabolic Disease

https://www.sciencedirect.com/science/article/pii/S2161831322004367
1•brendanashworth•8m ago•0 comments

A tale of two flows: Metaflow and Kubeflow

https://blog.kubeflow.org/metaflow/
2•savin-goyal•9m ago•0 comments

Show HN: Superfocus – Pomodoro timer and focus app for students

https://www.superfocus.live/
1•Jcjimenez•11m ago•0 comments

Microsoft's New Open-Source Project: LiteBox, a Rust-Based Sandboxing Library OS

https://www.phoronix.com/news/Microsoft-LiteBox
2•heavyset_go•12m ago•0 comments

Why SOTA Hybrid Models are Stuck at 1:7

https://gist.github.com/eric2675-coder/4a1d472e0775728bbcf23f4a57e3ad05
1•eric2675•16m ago•1 comments

The Traffic Mimes of Bogotá

https://www.atlasobscura.com/articles/traffic-mimes-of-colombia
1•IgorPartola•16m ago•0 comments

Zed now supports next edit prediction models Zeta, Mercury Coder, Sweep and more

https://zed.dev/blog/edit-prediction-providers
1•DesaiAshu•19m ago•0 comments

Show HN: Dengen Shrine – A privacy-focused digital Shinto ritual

https://dengen-shrine.com/
2•yumeda•24m ago•0 comments

Discover How Pros Analyze Website Traffic (Without Access)

https://newtutoweb.blogspot.com/2026/02/discover-how-pros-analyze-website.html
1•Traumen•27m ago•2 comments

Nginx vulnerability CVE-2026-1642

https://my.f5.com/manage/s/article/K000159824
2•ericdiao•27m ago•0 comments

Show HN: AI ASMR Voice – Text to ASMR Voice Generator

https://www.aiasmrvoice.com/en
1•leoncos•27m ago•0 comments

Yet another reminder why you should not use Ollama

https://github.com/ggml-org/llama.cpp/pull/19324
1•dcreater•28m ago•3 comments

Show HN: I built an all-in-one API client, DB client and Data inspector

https://www.postpilot.dev/
1•anlac96_it•29m ago•0 comments

Chaox.io – Run Physics Simulations with Rust and Web Assembly

https://chaox.io/
1•jagveerllc•32m ago•1 comments

Toxic Truth: How Wikipedia Poisons Global Knowledge

https://ellakenan100.substack.com/p/toxic-truth-how-wikipedia-poisons
15•appreciatorBus•34m ago•1 comments

Unlocking the Codex harness: how we built the App Server

https://openai.com/index/unlocking-the-codex-harness/
1•SerCe•35m ago•0 comments

700K+ Substack emails, phone numbers leaked in October. Notified users today

https://www.hendryadrian.com/substack-data-breach-leads-to-leak-of-nearly-700000-records/
3•epsteingpt•36m ago•1 comments

Protecting Our Right to Sue Federal Agents Who Violate the Constitution

https://www.eff.org/deeplinks/2026/02/protecting-our-right-sue-federal-agents-who-violate-constit...
10•HotGarbage•38m ago•1 comments

Pixwit.ai is an AI-powered video creation platform

https://pixwit.ai
1•maysunyoung•39m ago•1 comments

Accelerating Scientific Research with Gemini: Case Studies and Common Techniques

https://arxiv.org/abs/2602.03837
3•nl•40m ago•0 comments

State of JavaScript – 2025

https://2025.stateofjs.com/en-US
1•fud101•44m ago•0 comments

Supreme Court allows California to use congressional map benefitting Democrats

https://www.scotusblog.com/2026/02/supreme-court-allows-california-to-use-congressional-map-benef...
7•cosmicgadget•45m ago•3 comments

Senate Republican on suspected biolab found in Las Vegas: 'Enormous problem'

https://thehill.com/homenews/state-watch/5722424-ron-johnson-biolab-concerns/
9•SilverElfin•46m ago•1 comments

The last U.S.-Russian nuclear pact is about to expire

https://www.pbs.org/newshour/world/the-last-u-s-russian-nuclear-pact-is-about-to-expire-ending-a-...
3•geox•47m ago•1 comments

Finding a Way to Produce Powerful Motors Without Rare Earths

https://hackaday.com/2026/01/13/finding-a-way-to-produce-powerful-motors-without-rare-earths/
1•lxm•49m ago•1 comments

What Starcraft Teaches Us About Vibe Coding

https://twitter.com/i/status/2018355437620380032
2•ajay-higgs•53m ago•0 comments

FCC Fast-Tracks SpaceX Million-Satellite Plan Public Comments Open Until March 6

https://gearmusk.com/2026/02/05/fcc-fast-tracks-spacex-million-satellite/
1•takumi123•57m ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

1•ramsicandra•8mo 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•8mo 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•8mo 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.