frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Could Iran be using China's highly accurate BeiDou navigation system?

https://www.aljazeera.com/features/2026/3/11/could-iran-be-using-chinas-highly-accurate-beidou-na...
1•ironyman•14s ago•0 comments

Unified Sandbox SDK for AI Agents

https://sandbank.dev/
1•guoyu•49s ago•0 comments

Future AI chips could be built on glass

https://www.technologyreview.com/2026/03/13/1134230/future-ai-chips-could-be-built-on-glass/
1•Brajeshwar•56s ago•0 comments

Show HN: VibeTrade – Trading Harness for Claude

https://github.com/vibetrade-ai/vibe-trade
1•raunaqvaisoha•3m ago•0 comments

My AI Agent Knows Who I Am. Not Just What I Want. Who I Am

https://thoughts.jock.pl/p/wiz-ai-agent-self-improvement-architecture
1•joozio•6m ago•0 comments

Ask HN: Why have co-ops never played a major role in tech?

1•AbstractH24•6m ago•0 comments

Systemic Omens – AI and Work

https://muskdeer.blogspot.com/2026/02/systemic-omens-ai-and-work.html
1•bulla•7m ago•0 comments

Readers noticed updated pop culture references on Kindle

https://dailydot.com/pretty-little-liars-updated-pop-culture-references
2•HardwareLust•8m ago•2 comments

Understanding crude oil: From exploration to pricing

https://economictimes.indiatimes.com/markets/stocks/news/understanding-crude-oil-from-exploration...
1•gautamsomani•8m ago•0 comments

Can I Run AI locally?

https://www.canirun.ai/
1•ricardbejarano•8m ago•0 comments

Show HN: K-synth – A web-based array language playground for synth design

https://octetta.github.io/k-synth/
1•octetta•9m ago•1 comments

Ask HN: How do you automate the anxiety after a deploy

1•Lazy_Player82•10m ago•0 comments

The Debt Beneath the Dream

https://om.co/2026/03/09/the-debt-beneath-the-dream/
1•gmays•10m ago•0 comments

A self-contained parser for SQLite statements

https://marcobambini.substack.com/p/liteparser-a-fast-embeddable-sqlite
1•marcobambini•11m ago•0 comments

Ukraine to Make Drone Videos Available for Training A.I. Models

https://www.nytimes.com/2026/03/12/world/europe/ukraine-drones-ai-models-training.html
2•lilytweed•12m ago•0 comments

Electric air taxis are about to take flight in 26 states

https://techcrunch.com/2026/03/09/electric-air-taxis-are-about-to-take-flight-in-26-states/
1•bookofjoe•12m ago•0 comments

The state of Rust memory allocators in 2026

https://cetra3.github.io/blog/state-of-allocators-2026/
2•fanf2•12m ago•0 comments

Show HN: Codex vs. Claude for Reverse Engineering Skills

https://www.joshuamckiddy.com/blog/codex-vs-claude
1•dozercat•13m ago•1 comments

Show HN: Amux – run Claude Code agents in parallel from your phone

1•Beefin•13m ago•1 comments

Leading health tech firms and AI startups respond to HHS request for information

https://www.statnews.com/2026/03/02/hhs-clinical-ai-proposal-health-tech-wish-list/
1•mroche•14m ago•0 comments

Show HN: A modern boarding pass encoder/decoder/scanner (web and library)

https://github.com/jqssun/iata-api
1•jqssun•16m ago•0 comments

Which Web Framework Is the Fastest? We Benchmarked 9 of Them

https://ntnt-lang.org/blog/which-web-framework-is-fastest
1•joshcramer•16m ago•0 comments

Mapping Middle East kinetic events via automated OSINT and deduplication

2•aggeeinn•17m ago•0 comments

Live Nation Can 'Gouge' Fans on Fees, Ticket Directors Brag

https://www.bloomberg.com/news/articles/2026-03-12/live-nation-can-gouge-fans-on-fees-ticketing-e...
1•inaros•17m ago•0 comments

Retailer denies memory replacement due to 4x increase in DDR5 pricing

https://www.tomshardware.com/pc-components/ddr5/retailer-denies-memory-return-due-to-4x-increase-...
2•inaros•19m ago•0 comments

It's the Music You Hear All Day, Without Ever Noticing

https://www.nytimes.com/2026/03/10/magazine/sync-music-songwriters-video.html
1•XzetaU8•23m ago•0 comments

Ramp Is Coming to Europe

https://ramp.com/blog/ramp-is-launching-in-europe
1•0xedb•23m ago•0 comments

Qatar helium shutdown puts chip supply chain on a two-week clock

https://www.tomshardware.com/tech-industry/qatar-helium-shutdown-puts-chip-supply-chain-on-a-two-...
5•johnbarron•23m ago•2 comments

OS/2 Never Went Away. Its Successor Has Received an Update

https://hackaday.com/2026/03/13/os-2-never-went-away-its-successor-has-received-an-update/
2•Tomte•25m ago•1 comments

Soloterm

https://soloterm.com/
1•handfuloflight•26m ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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