frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Local LLM for Private Companies

1•ahendest•2m ago•0 comments

Cutting Costs, Not Corners by moving out of big tech

https://knuthellan.com/cutting-costs-not-corners-how-we-migrated-our-ai-document-pipeline-from-aws
1•khellan•4m ago•0 comments

The semantic layer is for humans, not machines

https://getcassis.com/blog/the-semantic-layer-is-for-humans-not-machines
2•matthieu_bl•5m ago•0 comments

Externalization in LLM Agents: Unified Review of Memory and Harness Engineering

https://arxiv.org/abs/2604.08224
2•MemTensor•6m ago•0 comments

GBC/GBA Emulator in Rust

https://github.com/Sessa93/gbrust/tree/main
1•andre9317•8m ago•1 comments

Show HN: Floors – DJ mix discovery built around a music knowledge graph

https://floors.music/
1•mattbyrom•10m ago•0 comments

I got over my AI skepticism in data engineering

https://getbruin.com/blog/ai-skepticism-in-data-engineering/
3•arsalann•10m ago•0 comments

Share browser recordings on Cloudflare Pages from the command line

1•keepamovin•10m ago•0 comments

Do you want the US to "win" AI?

https://geohot.github.io//blog/jekyll/update/2026/04/23/us-win-ai.html
2•mefengl•13m ago•0 comments

Base Mac Mini Sold Out from Apple Online Store

https://www.macrumors.com/2026/04/22/base-mac-mini-sold-out-from-apple-online-store/
2•7777777phil•14m ago•0 comments

I LOVE YOU

https://en.wikipedia.org/wiki/ILOVEYOU
1•keepamovin•16m ago•0 comments

Cortex Auth – Rust secrets vault for AI agents (exec-based injection)

https://github.com/davideuler/cortex-auth
1•davideuler•16m ago•1 comments

Trust Me, I'm a Shortcut

https://www.wietzebeukema.nl/blog/trust-me-im-a-shortcut
3•wietze•25m ago•0 comments

Bitwuzla: Satisfiability Modulo Theories (SMT) Solver

https://github.com/bitwuzla/bitwuzla
1•tosh•27m ago•0 comments

"Bot or Human?" Is the Wrong Question for the Modern Web

https://blog.cloudflare.com/past-bots-and-humans/
1•emot•28m ago•0 comments

Image Generators Are Generalist Vision Learners

https://arxiv.org/abs/2604.20329
1•mohsen1•30m ago•0 comments

What you can do in a decade

https://twitter.com/swyx/status/2047217611880984935
1•tosh•31m ago•0 comments

AI and Teaching

https://eiexchange.com/content/ai-and-teaching-the-brave-new-world
1•walterbell•32m ago•0 comments

Show HN: We built an OCR server that can process 270 dense images/s on a 5090

https://github.com/aiptimizer/TurboOCR
4•pfdomizer•33m ago•1 comments

Writing a C Compiler, in Zig

https://ar-ms.me/thoughts/c-compiler-1-zig/
2•tosh•33m ago•0 comments

Subscription bombing attacks: patterns, dark web services, and mitigations

https://cacm.acm.org/practice/subscription-bombing-email-under-attack/
1•gannimo•34m ago•0 comments

Show HN: AI Applyd – score, rewrite, auto-apply via cloud browser

https://aiapplyd.com/
1•sneefle•34m ago•0 comments

A new logical model for artificial gravity cores: from pest control to railguns

https://gist.github.com/ryouta19931007
1•hamutarou•38m ago•0 comments

Programming as Theory Building – Peter Naur

https://gist.github.com/onlurking/fc5c81d18cfce9ff81bc968a7f342fb1
1•jonnonz•38m ago•0 comments

FIU Student Arrested After Joking About Netanyahu on WhatsApp

https://www.youtube.com/watch?v=o1Zsb1IijYY
11•enaaem•42m ago•0 comments

Meta layoff wave impacting 8000 jobs

https://www.usatoday.com/videos/news/2026/04/20/meta-layoffs-impacting-8000-employees/89697461007/
2•tcp_handshaker•45m ago•1 comments

Is Starlink a Secret Radar Constellation? [video]

https://www.youtube.com/watch?v=jbp3kdJZ1_A
3•msuniverse2026•51m ago•0 comments

Show HN: Nova by civai, a platform for managed AI agents

https://nova.civai.co/
2•usecodenaija•53m ago•0 comments

RFK Jr. Defends Trump's Mathematically Impossible Drug Discount Claims

https://www.nytimes.com/2026/04/22/us/politics/rfk-jr-trump-impossible-drug-discounts.html
3•tcp_handshaker•53m ago•1 comments

Vision Banana: Image Generators Are Generalist Vision Learners

https://vision-banana.github.io
2•M4v3R•54m ago•1 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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