frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Compiling dynamic programming languages (2018)

https://notes.eatonphil.com/compiling-dynamic-programming-languages.html
1•azhenley•1m ago•0 comments

The unfinished solar power plant in El Médano – Tenerife part 01

https://rdnsec.info/articles/el-medano-solar-plant-part-01/
1•austinallegro•2m ago•0 comments

Show HN: NetworkX and pyarrow = 6-7x memory savings

https://github.com/networkx/networkx/discussions/8933
1•adsharma•4m ago•0 comments

Show HN: Approvegate – Deploy approvals enforced in your pipeline, not in Jira

https://approvegate.io/
1•chidog99•4m ago•0 comments

Apple Confirms iPhone 18 Pro Max AT&T Issues, Devices Require Replacement

https://daringfireball.net/linked/2026/10/03/iphone-18-pro-max-att-issues
2•orf•6m ago•0 comments

Sloppy-Con Valley: VC as Private Equity

https://em0sh.substack.com/p/sloppy-con-valley
2•em0sh•6m ago•0 comments

Show HN: Mermaidiff – git diff for behavior, PRs as sequence diagrams

https://github.com/osmangoninahid/mermaidiff
2•osmangoninahid•7m ago•0 comments

EU KIDS Act

https://commission.europa.eu/news-and-media/news/eu-kids-act-helping-children-navigate-safer-onli...
2•noisysoc•11m ago•0 comments

iNoU Agent

https://marketplace.visualstudio.com/items?itemName=MauricioGraciaGutierrez.inou-vscode
1•MaGraGuz•12m ago•1 comments

A Beginner's Guide to Running AI Models Locally

https://www.itsthatlady.dev/blog/beginners-guide-to-local-ai/
1•mooreds•13m ago•0 comments

What do you want from AI?

https://www.anthropic.com/research/your-thoughts-on-ai
1•Eridanus2•14m ago•0 comments

AI (For Normal People) with AWS Hero Thorsten Hoger [video]

https://vbrownbag.com/2026/06/episode-followup-ai-for-normal-people-with-aws-hero-thorsten-hoger/
1•mooreds•15m ago•0 comments

Show HN: [Open-source] Sign JSON and send it as a business document

https://json-doc.com/
1•spkaikai•17m ago•0 comments

Cube Rule food classifier using Cloudflare Clef classification model

https://foodbyclef.pages.dev/
1•murderszn•18m ago•0 comments

EV drivers love their cars, but some passengers feel sick – this could be why

https://www.bbc.co.uk/news/articles/c3y0zx822wlzo
1•dberhane•22m ago•0 comments

Agent-blackbox – a tamper-evident flight recorder for Claude Code

https://github.com/developerfred/agent-blackbox
1•codingsh•23m ago•0 comments

Programming Prayer: The Woven Book of Hours (1886–87)

https://publicdomainreview.org/collection/lyon-woven-prayer-book/
1•djoldman•23m ago•0 comments

Reasons I didn't become an EMT, ranked

https://ben.stolovitz.com/posts/reasons-not-emt-ranked/
1•citelao•25m ago•2 comments

Stop rebuilding your CI runner on every push

https://www.p10s.cloud/posts/warm-ci-runners/
1•ypeter•27m ago•1 comments

Training an open decision model to replace a closed one, in shadow on prod

https://kitsuno.ai/content/engineering/laya-in-shadow/
1•kitsuno•28m ago•0 comments

Foliant, a Typst-to-PDF API with Templates and an MCP Server

https://foliant.dev/
2•StorageCluster•28m ago•0 comments

In Case Anybody Still Believes Microsoft Lunduke Cares About GNU/Linux

https://techrights.org/n/2026/10/03/In_Case_Anybody_Still_Believes_Microsoft_Lunduke_Cares_About_...
2•amcclure•29m ago•0 comments

Keurig's new machine uses plastic-free compressed coffee pucks

https://www.theverge.com/tech/1003956/keurig-alta-coffee-machine-altarounds-pucks-appliance-preorder
1•rdmuser•31m ago•1 comments

Chrome extension that identifies the exact remix/edit/sped-up

https://chromewebstore.google.com/detail/musicpulse-–-identify-rem/mmpkdgbmfhikfjgokecogaabmdcm...
1•musicpulsedev•31m ago•0 comments

Show HN: Play an RL self-play policy in Pokemon Gen 3 Randbats in the browser

https://zkingston.com/advsim/
1•zak_kingston•33m ago•0 comments

'Neanderthals Among Us' by Peter Sahlins Review

https://www.historytoday.com/archive/review/neanderthals-among-us-peter-sahlins-review
1•pepys•33m ago•0 comments

Milt Windler, NASA flight director who helped save Apollo 13, dies at 94

https://arstechnica.com/space/2026/10/milt-windler-nasa-flight-director-who-helped-save-apollo-13...
2•divbzero•34m ago•1 comments

Generic Const Args and You

https://blog.rust-lang.org/inside-rust/2026/10/02/generic-const-args-and-you/
5•birdculture•38m ago•1 comments

Foldscape, an interactive atlas of mathematical curiosities

https://foldscape.zauberware.com
1•simon-franzen•41m ago•0 comments

Zordt – AI news distilled to what happened and why it matters

https://zordt.com/
1•vchilkuri•41m 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.