frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Live Artemis II position tracker

https://issinfo.net/artemis
1•qingcharles•6m ago•1 comments

Quantum computers need fewer resources than thought to break vital encryption

https://arstechnica.com/security/2026/03/new-quantum-computing-advances-heighten-threat-to-ellipt...
2•rickcarlino•13m ago•0 comments

China's "pig semen eyedrop" could help deliver Alzheimer's treatment

https://www.scmp.com/news/china/science/article/3348726/chinas-brain-penetrating-pig-semen-eyedro...
4•nikolay•17m ago•1 comments

Remember Their Names

https://visualizingpalestine.org/visual/end-30-billion-of-us-military-aid-to-israel-green-jobs/
1•euler2100•17m ago•0 comments

Web server ratelimits are a precaution to let me stop worrying

https://utcc.utoronto.ca/~cks/space/blog/web/RatelimitsAreAPrecaution
1•LorenDB•17m ago•0 comments

After Fighting Malware for Decades, Cybersecurity Vet Now Hacking Drones

https://techcrunch.com/2026/04/04/after-fighting-malware-for-decades-this-cybersecurity-veteran-i...
1•yesensm•18m ago•0 comments

How Pope Leo is pushing back on divine justification of war

https://www.cnn.com/2026/04/04/middleeast/pope-leo-iran-war-analysis-latam-intl
1•1659447091•19m ago•0 comments

AGI Is Here

https://breaking-changes.blog/agi-is-here/
7•oakhan3•20m ago•8 comments

Show HN: Yoink functionality from dependencies and avoid supply chain attacks

https://github.com/theogbrand/yoink
2•kstonekuan•21m ago•0 comments

Half of social-science studies fail replication test in years-long project

https://www.nature.com/articles/d41586-026-00955-5
1•prabal97•23m ago•0 comments

The Rise of Worse Is Better

https://dreamsongs.com/RiseOfWorseIsBetter.html
1•kaladin-jasnah•38m ago•0 comments

Show HN: mailtrim – find what's actually filling your Gmail inbox

5•chevuru•42m ago•3 comments

Explore union types in C# 15

https://devblogs.microsoft.com/dotnet/csharp-15-union-types/
4•0x00C0FFEE•42m ago•0 comments

AI Whiz Kids Dropped Out of College and Got Investors to Pay Their Bills

https://www.wsj.com/tech/ai/ai-college-dropouts-ecc665b7
2•lxm•44m ago•0 comments

Mlx-VLM: Fast Local VLMs and Omni Models on Apple Silicon with MLX

https://github.com/Blaizzy/mlx-vlm
2•salkahfi•46m ago•0 comments

Towards end-to-end automation of AI research

https://www.nature.com/articles/s41586-026-10265-5
3•hardmaru•47m ago•0 comments

The Perils of Privatized Cyberwarfare

https://www.lawfaremedia.org/article/the-perils-of-privatized-cyberwarfare
2•gnabgib•47m ago•0 comments

Show HN: Simple Local Meme Generator

https://github.com/KyleTryon/Gemini-Meme-Generator
2•TechSquidTV•52m ago•0 comments

Nppexec

https://github.com/d0vgan/nppexec
2•downboots•53m ago•0 comments

Computer for Taxes

https://www.perplexity.ai/hub/blog/introducing-computer-for-taxes
2•wslh•53m ago•0 comments

Conductor – Durable Execution Engine

https://conductor-oss.github.io/conductor/index.html
3•opiniateddev•54m ago•0 comments

Notes for US Performers in Montreal

https://evanp.me/2026/04/04/notes-for-us-performers-in-montreal/
2•decimalenough•55m ago•0 comments

Meta-Harness: End-to-End Optimization of Model Harnesses

https://arxiv.org/abs/2603.28052
2•kstonekuan•1h ago•0 comments

Karpathy's knowledge base matches our Grep-is-All-You-Need paper

https://www.localkin.dev/papers/grep-is-all-you-need
3•localkin•1h ago•0 comments

We Made Technology Easy to Use. That Was a Mistake

https://slate.com/technology/2026/04/usability-complexity-apple-iphone-facebook-donald-norman.html
2•kawera•1h ago•0 comments

The Awake "Sleep" Loop: Why Attention Lapses Occur in ADHD

https://neurosciencenews.com/adhd-attention-sleep-activity-30324/
3•ivewonyoung•1h ago•0 comments

Show HN: Signals – finding the most informative agent traces without LLM judges

https://arxiv.org/abs/2604.00356
3•sparacha•1h ago•0 comments

I built a $19.99 flat-fee EU261 flight compensation letter generator

https://www.sovereign-suite.com/
2•oneprofiledev•1h ago•0 comments

The Crazy Nastyass Honey Badger (2011)

https://www.youtube.com/watch?v=4r7wHMg5Yjg
2•kaycebasques•1h ago•0 comments

Beat Cancer Off

https://beatcanceroff.com/
3•cebert•1h ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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