frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

I Hate AI

1•jwpapi•1m ago•0 comments

100M commits to GitHub without using Git push

https://github.com/Wuerfelhusten/commitment
1•Wuerfelhusten•5m ago•1 comments

A type of bike theft in San Francisco

https://shub.club/writings/2026/april/a-type-of-bike-theft/
1•forthwall•14m ago•0 comments

Hospital at centre of child HIV outbreak caught reusing syringes in Pakistan

https://www.bbc.com/news/articles/clyrd818gd2o
3•flykespice•14m ago•0 comments

Breaking from Your Parents [video]

https://www.youtube.com/watch?v=VhpF9jC3a18
1•Aerbil313•15m ago•0 comments

I automated my local barbershop's chaos with code

https://ravoor.com/ar
5•megoxv•16m ago•0 comments

Stop New York's Attack on 3D Printing

https://www.eff.org/deeplinks/2026/04/stop-new-yorks-attack-3d-printing
3•iamnothere•18m ago•0 comments

Unwritten – 3-minute AI short film, Top at Soulscape 2026

https://www.youtube.com/watch?v=rzdvt-qOysI
1•gltanaka•19m ago•0 comments

Show HN: VCoding – A 5 MB native Windows IDE with no dynamic dependencies

1•Tonyjw2002•22m ago•0 comments

Planning and Monitoring Indoor Vertical Green Living Walls with Remote Sensing

https://onlinelibrary.wiley.com/doi/10.1155/ina/5782002
1•PaulHoule•24m ago•0 comments

George Orwell Predicted the Rise of "AI Slop" in Nineteen Eighty-Four (1949)

https://www.openculture.com/2026/04/how-george-orwell-predicted-the-rise-of-ai-slop.html
5•doener•25m ago•0 comments

Show HN: 70% → 100% LLM accuracy by changing the representation, not the model

https://github.com/yvonboulianne/laeka-rational
2•yvonboulianne•26m ago•0 comments

Ne, the Nice Editor

https://github.com/vigna/ne
2•Lyngbakr•26m ago•0 comments

Everything we like is a psyop

https://techcrunch.com/2026/04/16/everything-we-like-is-a-psyop/
1•evo_9•27m ago•0 comments

North Korea targets macOS users in latest heist

https://www.theregister.com/2026/04/16/north_korea_social_engineering_macos/
2•Bender•27m ago•0 comments

Google Chrome lacks fingerprinting protection

https://www.theregister.com/2026/04/16/google_chrome_lacks_browser_fingerprinting/
2•Bender•28m ago•2 comments

QUIC will soon be as important as TCP – but it's vastly different

https://www.theregister.com/2026/04/16/quic_explained/
1•Bender•29m ago•0 comments

Frank Dudley Beane's Experience with Ergot and Cannabis Indica (1884)

https://publicdomainreview.org/collection/experience-with-ergot-and-cannabis/
3•apollinaire•34m ago•0 comments

The Book News Isn't All Bad

https://reactormag.com/the-book-news-isnt-all-bad/
2•samclemens•35m ago•0 comments

Claude Opus 4.7 System Prompt Leaked

https://twitter.com/elder_plinius/status/2044857095439421885
3•giancarlostoro•41m ago•0 comments

The cover of C++ The Programming Language raises questions not answered by cover

https://devblogs.microsoft.com/oldnewthing/20260401-00/?p=112180
2•ibobev•41m ago•1 comments

Isolating AI Coding Agents on Bare Metal

https://blog.singlr.ai/isolating-ai-coding-agents-bare-metal-incus-podman/
2•jacobobryant•42m ago•0 comments

Cave under castle with prehistoric hippo bones 'once in a lifetime' find

https://www.bbc.com/news/articles/c8ejjw7377jo
3•Lyngbakr•42m ago•0 comments

How customer lists and trademarks help companies borrow

https://www.chicagobooth.edu/review/how-customer-lists-trademarks-help-companies-borrow
1•hhs•43m ago•0 comments

Parcae: Doing More with Fewer Parameters Using Stable Looped Models

https://sandyresearch.github.io/parcae/
2•matt_d•43m ago•0 comments

Runway CEO: AI could help Hollywood make 50 films instead of 1 $100M blockbuster

https://techcrunch.com/2026/04/16/runway-ceo-says-ai-could-help-hollywood-make-50-films-instead-o...
1•bookofjoe•44m ago•1 comments

Resuming ZFS Send (2019)

https://oshogbo.com/blog/66/
1•QuantumNomad_•45m ago•0 comments

Why is a delay between a thread exiting and Wait­For­Single­Object returning?

https://devblogs.microsoft.com/oldnewthing/20260415-00/?p=112235
1•ibobev•45m ago•0 comments

You have to rank 5 projects before you can post your own

https://proofofworth.net
2•Meterman•46m ago•1 comments

The juggling act

https://lawliberty.org/the-juggling-act/
1•hhs•46m ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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