frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Grith

https://grith.ai/
1•handfuloflight•1m ago•0 comments

Leave the Kurds alone. We are not guns for hire

https://thenewregion.com/posts/4762
2•inaros•2m ago•0 comments

When to Use BFF and Should It Replace API Gateway?

https://reactdevelopment.substack.com/p/when-to-use-bff-and-should-it-replace
1•javatuts•4m ago•0 comments

Show HN: Real-time collaborative editing plugin for Blender

https://github.com/arryllopez/meerkat
1•arryleo10•5m ago•0 comments

Essential use cases for web scraping data extraction

https://spidra.io/blog/7-essential-use-cases-for-web-scraping
1•joelolawanle•6m ago•1 comments

Show HN: Crazly – structured AI workflows instead of random prompts

https://crazly.pro/
1•starup-guy•6m ago•0 comments

The next generations of Bubble Tea, Lip Gloss, and Bubbles are available now

https://charm.land/blog/v2/
1•atkrad•7m ago•0 comments

Trampolining Nix with GenericClosure

https://blog.kleisli.io/post/trampolining-nix-with-generic-closure
1•ret2pop•7m ago•1 comments

Show HN: I mapped 954K addresses because AI hallucinated my trash day

https://trashalert.io
1•hudtaylor•10m ago•1 comments

VoiceVista – Resurrection of Microsoft Soundscape for the Blind and VI

https://www.applevis.com/apps/ios/navigation/voicevista
1•Fr0styMatt88•13m ago•0 comments

Show HN: A new package manager for Ada

https://github.com/tomekw/tada
1•tomekw•13m ago•1 comments

JavaScript Note: ToggleEvent.source and Dialog.closedBy

https://jsdev.space/toggleevent-source-dialog-closedby/
1•javatuts•13m ago•0 comments

Stanford EE 292P: How China will 'quarantine' Taiwan

https://hnvr.medium.com/week-9-geopolitics-and-national-security-ee-292p-atoms-bits-and-the-natio...
1•malchow•13m ago•0 comments

AI Agents Have Senior Engineer Capabilities and Day-One Intern Context

https://equatorops.com/resources/blog/ai-agents-need-consequence-awareness
1•bobjordan•13m ago•1 comments

Migrating a 300GB PostgreSQL database from Heroku to AWS with minimal downtime

https://argos-ci.com/blog/heroku-to-aws-migration
2•neoziro•14m ago•0 comments

Eclipse GlassFish: This Isn't Your Father's GlassFish

https://omnifish.ee/eclipse-glassfish-this-isnt-your-fathers-glassfish/
2•henk53•15m ago•0 comments

Show HN: LM Canvas – current chat interfaces suck, so I built a canvas for LLMs

https://twitter.com/maxleedev/status/2029695170040529306
1•max-lee-dev•15m ago•0 comments

The Sandboxed Open-Source Agent that is 70% cheaper than E2B

https://coasty.ai:443/
1•nkov47as•17m ago•1 comments

MrBeast fired a video editor after Kalshi accused employee of insider trading

https://apnews.com/article/mrbeast-jimmy-donaldson-kalshi-7a8bb7e2aecee7428bcc2dd1eb08ac67
1•petethomas•17m ago•0 comments

Stop Using Grey Text

https://catskull.net/stop-using-grey-text.html
2•catskull•18m ago•0 comments

Show HN: The CTO Game – Scale your infra in real-time, under pressure

https://thectogame.com/
1•frenchmajesty•21m ago•0 comments

Labubu sues 3D printer maker Bambu Lab for items made by its users

https://www.tomshardware.com/3d-printing/labubu-sues-3d-printer-maker-bambu-lab-for-items-made-by...
2•josephcsible•21m ago•0 comments

Amazon Appears to Be Down

https://arstechnica.com/gadgets/2026/03/amazon-appears-to-be-down-with-over-20000-reported-problems/
2•samizdis•21m ago•0 comments

Feeling the Effects of 260k Federal Jobs Lost

https://www.nytimes.com/2026/03/05/climate/climate-forward-science-federal-cuts.html
3•geox•24m ago•0 comments

Show HN: AI Resume Chatbot – recruiters can chat with your resume

https://airesume.chat
1•hanishabsigh•25m ago•0 comments

Surviving the Streaming Dungeon with Kafka Queues

https://rion.io/2026/02/02/surviving-the-streaming-dungeon-with-kafka-queues/
1•rionmonster•30m ago•0 comments

Jemalloc

https://github.com/jemalloc/jemalloc
1•flykespice•30m ago•0 comments

AdonisJS 7.0.0 Has Been Released

https://adonisjs.com/
2•krthr•30m ago•0 comments

U.S. Capabilities Are Showing Signs of Rot

https://www.theatlantic.com/ideas/2026/03/military-failures-trump-iran/686244/
5•Jtsummers•31m ago•1 comments

Sam Altman Wants Elected Officials, Not OpenAI, to Decide How Military Uses AI

https://www.wsj.com/tech/ai/sam-altman-wants-elected-officials-not-openai-to-decide-how-military-...
3•ndkap•31m ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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