frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Brett Cooper values independent thought on Trump and more

https://figyj.blogspot.com/2025/12/brett-cooper-values-independent-thought.html
1•FIGYJ•48s ago•0 comments

On the Six-Cornered Snowflake

https://www.keplersdiscovery.com/snowflake.html
1•geox•1m ago•0 comments

Discrete Bayesian Sample Inference for Graph Generation

https://arxiv.org/abs/2511.03015
1•PaulHoule•4m ago•0 comments

I Tried the New Android XR Smart Glasses from Google and XReal

https://www.pcmag.com/news/i-tried-the-new-android-xr-smart-glasses-from-google-they-impressed-me
1•fcpguru•6m ago•0 comments

Toggle the "Light" Switch

https://www.incommonwith.com/collections/all-lighting
1•FelipeCortez•6m ago•0 comments

New benchmark shows top LLMs struggle in real mental health care

https://swordhealth.com/newsroom/sword-introduces-mindeval
3•RicardoRei•8m ago•1 comments

Apple Faces Scrutiny as Sanctioned Entities Slip Through App Store Controls

https://www.washingtonpost.com/technology/2025/12/10/us-sanctions-apple-google/
2•7777777phil•11m ago•1 comments

2025 Cacowards

https://www.doomworld.com/cacowards/2025/index/
1•klaussilveira•11m ago•0 comments

EU welcomes seamless data transfer between iPhone and Android

https://www.heise.de/en/news/EU-welcomes-seamless-data-transfer-between-iPhone-and-Android-111106...
1•doener•13m ago•0 comments

If Dr. Seuss Danced with Nietzche – The Sneetches on the Nietzches

https://philshapirochatgptexplorations.blogspot.com/2025/12/the-sneetches-on-nietzsches.html
1•pshapiro99•14m ago•0 comments

The boundary of copyrightability in AI-generated code under Japan and US Law

https://shujisado.org/2025/12/10/the-boundary-of-copyrightability-in-ai-generated-code/
1•jonymo•14m ago•0 comments

I Wish People Were More Public

https://borretti.me/article/i-wish-people-were-more-public
1•swah•14m ago•0 comments

"Empire of AI" is wildly misleading about AI water use

https://andymasley.substack.com/p/empire-of-ai-is-wildly-misleading
2•Tycho•15m ago•0 comments

Operation Bluebird to relaunch "Twitter," says Musk abandoned the name and logo

https://arstechnica.com/information-technology/2025/12/can-twitter-fly-again-startup-wants-to-pry...
4•pathompong•16m ago•0 comments

Ask HN: Is 13" MacBook good enough without an external monitor?

1•ShahinSorkh•17m ago•0 comments

Show HN: Fastest way for analysts to ship data pipelines – safely

https://www.youtube.com/watch?v=WKVxgCrwQHw
2•adadu2•17m ago•3 comments

Suno Is Changing Music's Future: Thoughts on the AI Music Generator

https://micahblachman.beehiiv.com/p/suno-is-changing-music-s-future
1•subdomain•20m ago•0 comments

Publishing KOReader Highlights

https://tech.stonecharioteer.com/posts/2025/kollector/
1•stonecharioteer•21m ago•0 comments

Show HN: Calamari – single-host restrictive proxy (with squid)

https://github.com/n0id/calamari
1•calamari-proxy•23m ago•0 comments

Google Maps on iOS now remembers where you parked

https://mashable.com/article/google-maps-parking-remember-spot
2•gniting•25m ago•1 comments

Building a Self-Hosted CDN for BSD Cafe Media

https://it-notes.dragas.net/2024/08/26/building-a-self-hosted-cdn-for-bsd-cafe-media/
1•gpi•25m ago•0 comments

"restart on excessive memory usage" experiment: discordapp

https://old.reddit.com/r/discordapp/comments/1pej7l7/restart_on_excessive_memory_usage_experiment/
1•speckx•26m ago•0 comments

Can NASA Bring Mars Rocks Back to Earth?

https://www.scientificamerican.com/podcast/episode/can-nasa-bring-mars-rocks-back-to-earth/
1•quapster•29m ago•0 comments

Vix dev Auto-reload and rebuild loop for C++ applications

https://vixcpp.com
1•gkirira•32m ago•1 comments

Ask HN: Outstanding packets calculation in Go-Back-N ARQ when ACK lost?

1•shivajikobardan•34m ago•0 comments

Ask HN: How can I learn smartphone repair online?

2•rishikeshs•36m ago•0 comments

Boom Superpower: The Supersonic Tech Powering AI Data Centers

https://boomsupersonic.com/superpower
3•embedding-shape•38m ago•0 comments

Show HN: AI that writes reports while your Team codes

https://www.gitmore.io/
1•hamadev•39m ago•0 comments

Show HN: WireTyped – typed, error-first HTTP client for fetch

https://github.com/kasperrt/wiretyped
2•kasperrt•40m ago•0 comments

Interactive Network Learning Platform

https://packet.school
2•r1z4•41m ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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