frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Show HN: Rehearse – a pytest like testing library for voice agents

1•djp2803•42s ago•0 comments

Soylent is out. Food pouches are in.

https://www.nytimes.com/2026/02/02/dining/food-pouches-soylent.html
1•bookofjoe•1m ago•1 comments

Psychics in Silicon Valley

https://www.youtube.com/watch?v=aev4b5U2VLY
1•breakyerself•2m ago•0 comments

A New AI Math Startup Just Cracked 4 Previously Unsolved Problems

https://www.wired.com/story/a-new-ai-math-ai-startup-just-cracked-4-previously-unsolved-problems/
1•ryan_j_naughton•4m ago•0 comments

Vibe Migrating off SaaS >1k Pages and Losing 80% of our traffic

https://www.hopsworks.ai/post/vibe-migrating-1k-pages-and-losing-80-percent-of-our-traffic
2•jamesblonde•5m ago•0 comments

The Coding Agent OS

https://charlielabs.ai/coding-agents-as-operating-systems/
1•mrbbk•5m ago•0 comments

Expansion Microscopy Has Transformed How We See the Cellular World

https://www.quantamagazine.org/expansion-microscopy-has-transformed-how-we-see-the-cellular-world...
1•sohkamyung•5m ago•0 comments

Show HN: Moltbot in the Cloud

https://chatbotkit.com/examples/moltbot
1•_pdp_•7m ago•0 comments

Vibecoding Audit

https://erik.wiffin.com/posts/vibecoding-audit/
1•mooreds•12m ago•0 comments

Some people experience an inability to burp

https://www.scientificamerican.com/podcast/episode/daily-misery-why-some-people-cant-burp-and-how...
2•sohkamyung•13m ago•0 comments

Haskell at Front Row (2015)

https://www.kuril.in/blog/haskell-at-front-row/
1•mooreds•13m ago•0 comments

Spent 6 months learning Kafka then realized we didn't need it

https://old.reddit.com/r/apachekafka/comments/1quut7a/spent_6_months_learning_kafka_then_realized...
2•mooreds•14m ago•0 comments

The Viking messages unearthed on Sweden's rune stones

https://www.bbc.com/future/article/20260202-the-viking-secrets-revealed-by-swedens-rune-stones
1•1659447091•15m ago•0 comments

Show HN: BlogHunter – Free AI-generated blog and hosting for SEO experiments

https://bloghunter.se/
1•the_plug•19m ago•0 comments

CLI tool to enforce RFC-driven AI coding

https://github.com/govctl-org/govctl
2•lwhsiao•19m ago•0 comments

The Wrong Work, Done Beautifully

https://domenic.me/jsdom-claude-code/
2•domenicd•21m ago•0 comments

Death of Software. Nah.

https://twitter.com/stevesi/status/2019167552794948020
1•tosh•23m ago•0 comments

The journey of how we built Manus [video]

https://www.youtube.com/watch?v=Lm-WgmYRgmI
1•pickleballcourt•23m ago•0 comments

Show HN: Post Tomato – write once, post everywhere (LinkedIn, Threads, Telegram)

https://posttomato.com
1•blindnomore•23m ago•0 comments

Show HN: LookGood Live – the extension enhances your appearance on video calls

https://chromewebstore.google.com/detail/lookgood-live/mleflnbfifngdmiknggikhfmjjmioofi
1•mda_damico•27m ago•0 comments

I Built a "Card Counter" for Facebook Ads (Visualizes Creative Fatigue)

https://finalytics.agency
1•LJRoth•28m ago•0 comments

Show HN: A PRIVACY first intimate tracker

https://apps.apple.com/us/app/do-track-intimate-sex-passion/id6757778324
1•xiaoyehua•29m ago•1 comments

Spotify, with Bookshop.org, Will Soon Offer Physical Books

https://www.wsj.com/business/media/spotify-a-major-audiobook-provider-will-soon-offer-physical-bo...
1•donohoe•30m ago•0 comments

The fall of the nerds

https://www.noahpinion.blog/p/the-fall-of-the-nerds
2•swah•30m ago•0 comments

The Pyramid of Equity Returns: Almost 200 Years of U.S. Stock Performance (2020)

https://advisor.visualcapitalist.com/historical-stock-market-returns/
2•ksec•31m ago•0 comments

Faster, cheaper, messier: lessons from our switch to self-hosted GitHub Actions

https://theguardian.engineering/blog/faster-cheaper-messier-lessons-from-switch-to-self-hosted-gi...
1•birdculture•32m ago•0 comments

The happiest country wants to stay the happiest

https://northernlightshift.com/
1•ahmaman•34m ago•0 comments

Explore Vaskange's Universe

https://www.vaskange.world/
1•sicher•35m ago•0 comments

Top downloaded skill in ClawHub contains malware

https://1password.com/blog/from-magic-to-malware-how-openclaws-agent-skills-become-an-attack-surface
1•pelario•39m ago•0 comments

Show HN: I built a lightweight CRM that runs in the browser

https://lifetimecrm.co/
1•misterpmacd•42m ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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