frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

The Bitter Lesson

http://www.incompleteideas.net/IncIdeas/BitterLesson.html
1•vishnukvmd•1m ago•0 comments

What RTO Means for AI

https://jasondoyle.ie/whitepapers/what-return-to-office-removes/
1•jamesblakes•1m ago•0 comments

Voice Calling Without Internet

https://play.google.com/store/apps/details?id=com.quicksnap.close2me&hl=en_US
1•brnmwas•3m ago•1 comments

Show HN: A social commentary on the attention economy

https://www.domybidding.lol/
1•cursorial•6m ago•0 comments

Backlinks

https://100backlinks.org/
1•Cindybaby•7m ago•0 comments

A Statement by Autistici/Inventati Collective About US Sanctions

https://cavallette.noblogs.org/2026/08/10076
2•ciclotrone•7m ago•0 comments

Xiaomi AI Cube Targets Local LLMs with 1.22 TB/S Near-Memory Bandwidth

https://www.hardware-corner.net/xiaomi-ai-cube-targets-local-llms/
1•mdp2021•8m ago•0 comments

AI Revenue Reporting: Slop

https://www.ft.com/content/a9145db8-18c1-4476-aac5-d1b4fcf70040
1•thm•9m ago•0 comments

Godot Is Too Friendly to Thieves

https://www.somethinglikegames.de/en/blog/2026/godot_is_too_friendly_to_thieves/
1•sainth_slg•9m ago•0 comments

An ongoing 3D-printer AGPL violation

https://lwn.net/SubscriberLink/1089390/1ec2c9fa0d909e45/
1•mkesper•11m ago•0 comments

I Tried Coding My Own Graphics Library

https://nebula.tv/videos/sebastianlague-i-tried-coding-my-own-graphics-library
1•andsoitis•15m ago•1 comments

Google confirms deploying goto URL redirects to search results links

https://searchengineland.com/google-confirms-deploying-goto-url-redirects-to-search-results-links...
1•thm•17m ago•0 comments

Front end Ruby Falcon, back end Ractor, a small but promising comparison

https://github.com/socketry/protocol-http-executor/tree/main/example/busy
1•ksec•17m ago•0 comments

Show HN: Clink, an embedded-first C++23 stream processing engine

https://github.com/orhaugh/clink
1•rosshaugh•20m ago•0 comments

Years Late, Billions over Budget: California High-Speed Rail Hasn't Laid a Track

https://www.wsj.com/us-news/years-late-billions-over-budget-californias-high-speed-rail-hasnt-lai...
2•petethomas•21m ago•0 comments

Haiku R1 Beta 6 Released After 2 Years; BeOS Inspired Project Turns 25 Next Week

https://www.phoronix.com/news/Haiku-R1-Beta-6
1•mdp2021•21m ago•0 comments

Show HN: Forgot the Command? Stay in the Terminal

https://humansh.com/
1•mdarabi•22m ago•0 comments

Show HN: Contextual – local codebase memory for AI coding agents

https://contextuallabs.dev
1•aarjunm04•25m ago•0 comments

Meta settles for 18B over teen addiction

https://www.theguardian.com/technology/2026/aug/26/meta-social-media-addiction-trial-settlement
1•skor•27m ago•0 comments

Soju – Battle.net and Diablo II on Apple Silicon with a Free Wine Stack

https://github.com/BCD1210/soju
1•mikey9220•27m ago•1 comments

Misogynistic views are biggest red flag for violent extremism, report finds

https://www.abc.net.au/news/2026-08-25/rising-misogyny-in-young-people/107053640
2•rendx•30m ago•0 comments

Show HN: Trace where a link goes before opening it

https://securl.online/check-link
1•ktbatterham•32m ago•0 comments

Your AI Generated Menu Triggered My Trypophobia

https://shubhamjain.co/2026/08/27/ai-food-photos-trypophobia/
3•shubhamjain•34m ago•0 comments

What a century of data tells us about today's corporate bond spreads

https://www.ft.com/content/0a50dff4-27f4-46f1-9bdd-9dc047842b2e
2•latentframe•36m ago•0 comments

Amsterdam| Full Time, hybrid – HFT C++ Engineer – Low-latency systems

https://www.42.com/careers/hft-core-engineer
2•mardariya•36m ago•0 comments

How a Ukrainian commander sped through the 'kill zone' to save wounded troops

https://www.reuters.com/world/how-ukrainian-commander-sped-through-kill-zone-save-wounded-troops-...
3•petethomas•36m ago•0 comments

What is the Sapir-Whorf hypothesis? (1984) [pdf]

https://linguistics.berkeley.edu/kay/Kay&Kempton.1984.pdf
5•the-mitr•39m ago•1 comments

Vue Streaming Tutorial: Build a Live Video Streaming App with WebRTC (WHEP)

https://www.red5.net/blog/how-to-create-webrtc-publisher-clients-with-adaptive-live-encoding/
3•mondainx•41m ago•0 comments

The UK Power Grid Has a Phantom Data Center Problem

https://www.wired.com/story/uk-data-centers-logjam-ofgem-regulations/
4•kuuuzya•42m ago•2 comments

The Seniors Against Senior Housing

https://www.bloomberg.com/news/features/2026-08-19/senior-housing-faces-opposition-from-seniors-t...
3•littlexsparkee•46m 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.