frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Aiope – An on-device AI agent for Android (terminal, browser, SSH, MCP)

https://github.com/XNet-NGO/aiope
1•xnet-admin•23s ago•0 comments

Discovery Loop is raising again, now at $50B valuation

https://www.businessinsider.com/jeff-deans-startup-discovery-loop-is-eyeing-a-valuation-2026-9
2•utiiiD•6m ago•0 comments

Story Beyond the Eye: Glyph Positions Break PDF Text Redaction

https://arxiv.org/abs/2206.02285
1•jumpocelot•8m ago•0 comments

Harness as a Service

https://www.harnessasaservice.dev/
1•iacguy•8m ago•0 comments

Micron's Taiwan workers to get rewards worth up to 68 months of pay

https://www.reuters.com/world/asia-pacific/microns-taiwan-workers-get-rewards-worth-up-68-months-...
2•teleforce•9m ago•0 comments

Dance MIDI Sample Pack Creator

https://monictheory.com/genre/dance/
1•song_synth•12m ago•0 comments

Hip Hop MIDI Sample Pack Creator

https://monictheory.com/genre/hip-hop/
1•song_synth•13m ago•0 comments

Military aircraft reportedly blamed for UK air traffic control outage

https://www.theguardian.com/world/2026/sep/12/military-aircraft-reportedly-blamed-for-uk-air-traf...
1•tmnvix•17m ago•0 comments

Show HN: Fog 2.0: I removed the AI auto-organizing I built my first app around

https://apps.apple.com/us/app/smart-notes-folders-fog/id6760272134
1•akshatsaladi•18m ago•0 comments

Surviving What I Can't Forgive

https://www.thecut.com/article/surviving-without-forgiveness.html
1•littlexsparkee•19m ago•0 comments

iPhone Duo and iPhone 18 Pro – Not Justifiable

1•wwolfson97•21m ago•5 comments

OpenAI puts Pro subscriptions on hold due to Astra demand

https://techcrunch.com/2026/09/10/openai-puts-pro-subscriptions-on-hold-due-to-astra-demand/
2•josefchen•27m ago•0 comments

Building your own agent harness is fun

1•mrsirg•30m ago•1 comments

Starlink Signal Leakage Threatens Radio Astronomy's Most Critical Frequencies

https://www.gadgetreview.com/starlinks-signal-leakage-is-threatening-radio-astronomys-most-critic...
4•upofadown•31m ago•0 comments

A Decade of Hype, 3k Roofs, and One Redirect URL: Tesla Kills the Solar Roof

https://www.gadgetreview.com/a-decade-of-hype-3000-roofs-and-one-redirect-url-tesla-kills-the-sol...
5•upofadown•33m ago•0 comments

Our $106k Kalshi "Bailout," Explained

https://greed.bot/blog/combo-wombo
2•kylecarbs•40m ago•0 comments

I present to you: Game Index, a power user game library manager

https://github.com/atxoxx/GameIndex
1•atxoxx•41m ago•0 comments

Richat Structure

https://en.wikipedia.org/wiki/Richat_Structure
1•jonbaer•43m ago•0 comments

Bernie's AI bill proposes to sentence AI developers to 20 years in prison

https://twitter.com/venturetwins/status/2098456905526211026
3•bilsbie•47m ago•0 comments

Ask HN: How do we deal with "hacking" Hacker News?

1•jumploops•48m ago•2 comments

Learning Alzheimer signatures by bridging EEG with spiking neural networks

https://www.sciencedirect.com/science/article/pii/S0925231226022885
2•giorgiodidio•49m ago•0 comments

Evergarden

https://evergarden.moe/
1•birdculture•49m ago•0 comments

Sometimes it's better not to say anything

https://manuelmoreale.com/thoughts/sometimes-it-s-better-not-to-say-anything
1•theorchid•50m ago•0 comments

An agent fleet that turns an IAM audit log into signed Terraform

https://medium.com/@majid.fekri/building-colony-guard-an-agent-fleet-that-turns-an-iam-audit-log-...
3•supportm•52m ago•1 comments

The Nature of Dance

https://vester.si/blog/nature-of-dance/
2•wonger_•54m ago•0 comments

Show HN: Graphify C# – Compiler-accurate Find Usages for coding agents

https://github.com/zachsaw/graphify-csharp
6•zachsaw•55m ago•2 comments

All Decks

https://jeffbaumes.github.io/all-decks/
2•scoreandseven•56m ago•0 comments

Prompts Aren't Real

https://evaluation.club
4•mcfunley•1h ago•0 comments

New type of plastic-degrading enzyme discovered in bacteria

https://www.the-microbiologist.com/news/an-enzyme-with-potential-new-type-of-plastic-degrading-en...
2•geox•1h ago•0 comments

The robotics revolution won't be humanoid

https://techcrunch.com/video/the-robotics-revolution-wont-be-humanoid/
3•ciqufi•1h ago•0 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.