frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

The Copilot+ PC brand is dead

https://www.windowscentral.com/microsoft/windows-11/the-copilot-pc-brand-is-dead-microsoft-and-pc...
1•bj-rn•2m ago•0 comments

First DVD player announced Sept 26, 1996

https://dfarq.homeip.net/first-dvd-player-announced-sept-26-1996/
1•giuliomagnifico•3m ago•0 comments

Drum Machines (LLMs) Have No Soul

https://calvinflegal.com/2026/09/26/drum-machines-have-no-soul.html
1•calflegal•6m ago•1 comments

How to keep enjoying programming in a world of LLMs

https://discourse.haskell.org/t/how-to-keep-enjoying-programming-in-a-world-of-llms/14705
7•signa11•16m ago•1 comments

Ask HN: Indie hackers on X (Twitter) feels like a mega bubble these days

1•sankalpdomore•21m ago•0 comments

The Emacs Cat: Running Emacs in MicroVM

https://olddeuteronomy.github.io/post/running-emacs-in-microvm/
1•hndhyc0bdt•24m ago•0 comments

According to 1950s futurists, women of the year 2000 would be giantesses (2012)

https://gizmodo.com/according-to-1950s-futurists-women-of-the-year-2000-wo-5878243
1•Eridanus2•25m ago•0 comments

Overpaying for AWS Managed Nat Gateways? Fck-Nat

https://fck-nat.dev/v1.4.0/
2•edweis•27m ago•0 comments

Show HN: Aerofi – a rofi-inspired, scriptable launcher for macOS (Rust, GPUI)

https://github.com/frostymur/aerofi
1•osaill•27m ago•0 comments

I am the only one who still uses sublime text daily?

1•serg2•28m ago•0 comments

Show HN: App2Api – Give your AI the API behind your app

https://app2api.com/
1•flkdnfsnsf•30m ago•0 comments

Writing a Theorem Prover from Scratch

https://astledsa.substack.com/p/writing-a-theorem-prover-from-scratch
2•astledsa•31m ago•0 comments

Flashcat – a local AI assistant for the Mac terminal that asks first

https://github.com/TomTomsen765/flashcat
1•TomTomsen•34m ago•0 comments

An Epyc trip to Venice: about AMD's 256-core monster chip

https://www.theregister.com/systems/2026/09/23/an-epyc-trip-to-venice-everything-we-do-and-dont-k...
1•pella•36m ago•0 comments

Srijan Orizon – South Kolkata's Upcoming Landmark Project

1•Liyaans•40m ago•0 comments

Fifteen years later, the Apple Cards origin story

https://lexontech.org/fifteen-years-later-the-apple-cards-origin-story
2•ksec•44m ago•0 comments

Nintendo Wins $4.5M Judgment Against R/SwitchPirates Mod 'Archbox'

https://torrentfreak.com/nintendo-wins-4-5-million-judgment-against-r-switchpirates-mod-archbox/
2•gslin•49m ago•1 comments

The flames at Turkmenistan's Door to Hell are beginning to fade

https://www.getaway.co.za/travel/travel-ideas/door-to-hell-turkmenistan-darvaza-gas-crater/
2•giuliomagnifico•54m ago•0 comments

AMD Takes the Lid Off of Next-Gen EPYC 9006 Venice as Zen 6 Comes to Servers

https://www.servethehome.com/amd-takes-the-lid-off-of-next-gen-epyc-9006-venice-as-zen-6-comes-to...
1•ksec•54m ago•1 comments

Demo of a concept "fractal" window manager [video]

https://www.youtube.com/watch?v=Kd9AbKawwhg
4•danfessler•57m ago•1 comments

LLM Red-temaing vs. Agent Red teaming

https://www.botgauge.com/blog/llm-red-teaming-vs-agent-red-teaming
1•sanathbhat•1h ago•0 comments

Why UpdatedInput in a PreToolUse Hook Doesn't Rewrite the Command

https://mer.vin/news/why-updatedinput-in-a-pretooluse-hook-doesnt-rewrite-the-command/
3•northbridgedev•1h ago•0 comments

Using Pomodoro to limit interaction with AI

https://anaivebidder.com/posts/the-agentic-pomodoro-iterating-faster/
2•rbnafo•1h ago•0 comments

Show HN: Linecite – find and fix stale file:line references in your docs

https://github.com/gotoUSA/linecite
1•mcbg1541•1h ago•0 comments

Pass Designer

https://developer.apple.com/pass-designer/
1•soheilpro•1h ago•0 comments

Trump admin using AI to deny medical care for seniors in disastrous experiment

https://arstechnica.com/health/2026/09/trump-admin-using-ai-to-deny-medical-care-for-seniors-in-d...
2•ndsipa_pomu•1h ago•3 comments

EU Member States plan "digital expropriation" of Europeans in the interest of AI

https://noyb.eu/en/ai-eu-member-states-plan-digital-expropriation-europeans-interest-ai-companies
4•mohi-kalantari•1h ago•1 comments

Show HN: Browser-only XIRR calculator – your real return from your real deposits

https://tradune.com/tools/beat-the-market-calculator/
1•salmanovmeharet•1h ago•0 comments

Laya Studio: Specialize Laya Without Fine-Tuning

https://github.com/Hantlowt/laya-studio
1•Hantlowt•1h ago•0 comments

Everything you need to know about Manchester City's hearing and charges

https://www.theguardian.com/football/2026/sep/25/manchester-city-found-guilty-of-breaking-premier...
2•teleforce•1h 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.