frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Over My Dead Pencil

https://world.hey.com/dhh/over-my-dead-pencil-fb0f3647
1•duck•25s ago•0 comments

One Minnesotan's longshot plan to take down the company behind Flock cameras

https://www.startribune.com/amid-flock-backlash-one-minnesotans-longshot-plan-to-take-down-the-co...
1•bradleyankrom•1m ago•0 comments

The Performance of Open Source Software: Ninja

https://aosabook.org/en/posa/ninja.html
1•birdculture•1m ago•0 comments

Sharing AI Progress in Mathematics

https://openai.com/index/sharing-ai-progress-in-mathematics/
4•OfficialTurkey•1m ago•0 comments

Tuesday Morning Topline: Waymos Not Allowed Near Waterfront for Fleet Week

https://sfist.com/2026/10/06/waymos-not-allowed-near-waterfront-for-fleet-week/
1•mikhael•4m ago•0 comments

Replay workflows with Epiq the next gen issue tracker

https://github.com/ljtn/epiq
1•ionetan•4m ago•0 comments

What If Pull Requests Had an Explain Command?

https://github.com/rajatrao/PR_explain
1•raorajat007•4m ago•0 comments

Anduril lands $2.9B Navy submarine shipyard contract

https://www.cnbc.com/2026/10/06/anduril-navy-submarine-shipyard-contract.html
1•Teever•7m ago•0 comments

The role of cat eye narrowing movements in cat–human communication (2020)

https://www.nature.com/articles/s41598-020-73426-0
2•bushwart•8m ago•0 comments

Amazon Alexa won't stop saying 'lalala'

https://www.androidauthority.com/amazon-alexa-la-la-la-3719167/
1•cribwi•8m ago•0 comments

What stops a small language model from driving a database agent

https://arxiv.org/abs/2609.21341
1•abdullahk0634•8m ago•1 comments

CoMaps Uses Wikimedia Enterprise to Bring Wikipedia to Their Offline Maps

https://enterprise.wikimedia.com/blog/comaps-benefits-from-enterprise-free-access/
1•pizzaiolo•8m ago•0 comments

The Query Transformation Pipeline

https://readyset.io/blog/how-readyset-rewrites-your-sql-inside-the-query-transformation-pipeline
1•gvsg-rs•9m ago•0 comments

The Instant Karma Machine [video]

https://www.youtube.com/watch?v=JDpX2mvNpvU
1•AJRF•11m ago•0 comments

Nuking stats problems with a probabilistic programming language

https://jo3-l.dev/posts/probabilistic-programming/
1•jo3_l•11m ago•0 comments

Orgledge – Find knowledge risks in engineering teams from GitHub activity

https://www.orgledge.com/
1•dogansahindev•16m ago•0 comments

Observability doesn't have to be expensive

https://telemetrymachine.com/blog/observability-doesnt-have-to-be-expensive
3•tmach32•18m ago•0 comments

Show HN: An AI agent runs ten web errands a day, every transcript published

https://agentability.org/
2•khalidsaidi•18m ago•0 comments

Penguin Mail – open-source Rust email client for Linux with AI

https://penguin-mail.com/
3•kavourias•19m ago•0 comments

Async Rust: Where does the scheduler live?

https://herecomesthemoon.net/2026/10/async-rust-where-does-the-scheduler-live/
1•slopinthebag•19m ago•0 comments

Ghosts in the Machine

https://claremontreviewofbooks.com/ghosts-in-the-machine/
1•danielam•20m ago•0 comments

The Big Blob of Compute Hypothesis (BBOC) by Dario Amodei [pdf]

https://kevinroose.substack.com/api/v1/file/7087c3ff-0f96-4e38-9e7e-1d0be092d61a.pdf
1•clueless•22m ago•0 comments

We built an Ubuntu mirror and then made it faster

https://depot.dev/blog/faster-ubuntu-package-installs
2•flurly•23m ago•1 comments

How Fast is Python 3.15?

https://blog.miguelgrinberg.com/post/how-fast-is-python-3-15
3•Qem•26m ago•0 comments

What Happens When We Give Up Control of Our Cars?

https://www.caranddriver.com/features/a15080195/what-happens-when-we-give-up-control-of-our-cars-...
2•bookofjoe•26m ago•0 comments

Hexagon

https://terrytao.wordpress.com/2026/10/06/hexagon/
2•smilelamp•26m ago•0 comments

AI is going to run out of power

https://www.transformernews.ai/p/ai-will-run-out-of-power
1•50kIters•26m ago•0 comments

We are all product engineers now

https://seldo.com/posts/we-are-all-product-engineers-now/
3•iacguy•26m ago•1 comments

Sulcus – observe and control AI agents while they run

https://sulcus.dev/
1•elariz_t•27m ago•0 comments

Italian PM files to trademark her voice against AI threats

https://www.bbc.com/news/articles/ckly0g1ljq2yo
1•cisc•29m 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.