frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Dungeon KeeperFX 1.4.0 with Multiplayer Released

https://keeperfx.net/news/25/2026-07-04/keeperfx-140-released
2•MrJagil•6m ago•1 comments

LLM's as a Different Kind of Intelligence

https://handmadeoasis.com/llms-as-a-different-kind-of-intelligence/
1•RamtinJ95•8m ago•0 comments

Geek, Music Producer, Father CEO Info-Struct

1•gryanfawcett•8m ago•0 comments

Megawatts by Microwave

https://computer.rip/2026-07-04-microwave-and-power.html
2•eternauta3k•19m ago•0 comments

Ask HN: How Do You Connect OpenAI Secure MCP Tunnel with Claude Desktop

1•mcpzero•37m ago•0 comments

Small Change [pdf]

https://web.stanford.edu/class/comm1a/readings/gladwell-small-change.pdf
2•ABNi•37m ago•0 comments

Fixing analog audio on the $2.58 HDMI-to-VGA adapter

https://nyanpasu64.gitlab.io/blog/hdmi-vga-dac-audio/
2•zdw•38m ago•0 comments

After hooking China on coffee, Starbucks ramps up consumer strategy

https://www.scmp.com/business/china-business/article/3359294/after-hooking-china-coffee-starbucks...
1•keepamovin•39m ago•0 comments

The '1776 Diet': What Americans ate during the nation's founding

https://www.foxnews.com/health/1776-diet-what-americans-really-ate-during-nations-founding
1•keepamovin•40m ago•0 comments

A gender-swap EarthBound for my daughter (2025)

https://tommy.reddad.net/post/2025-12-04-coilsnake/
1•Sajarin•40m ago•0 comments

Show HN: Codex-review – a read-only cross-model review skill for Claude Code

https://github.com/shimo4228/codex-review
1•shimo4228•44m ago•0 comments

Beeg float library, a Rust port of Fabrice Bellard's libbf

https://github.com/lifthrasiir/libbeef
4•serialx•52m ago•0 comments

Cuba's Green Solution to the U.S. Oil Blockade: Solar-Powered Electric Tricycles [video]

https://www.youtube.com/watch?v=eeg0CthbzTE
1•thelastgallon•56m ago•0 comments

New California study finds highly educated workers most harmed by AI

https://www.sfgate.com/politics/article/california-ai-study-22321472.php
3•littlexsparkee•1h ago•0 comments

US and Chinese companies train almost all of the most-used AI models

https://ourworldindata.org/data-insights/us-and-chinese-companies-train-almost-all-of-the-worlds-...
3•TMWNN•1h ago•0 comments

Mouse: Precision Editing Tools for AI Coding Agents

https://hic-ai.com
10•handfuloflight•1h ago•11 comments

Meituan Trained a 1.6T-Parameter AI Model Without Nvidia GPUs

https://xyzlabs.substack.com/p/meituan-trained-a-16t-parameter-ai
2•mgh2•1h ago•1 comments

China's LongCat-2.0 Becomes the Biggest AI Model Without Nvidia Chips

https://tech.yahoo.com/ai/articles/china-longcat-2-0-becomes-134258951.html
3•mgh2•1h ago•1 comments

Shadcn/UI now defaults to Base UI instead of Radix

https://ui.shadcn.com/docs/changelog
48•dabinat•1h ago•4 comments

Binary Coverage the Wrong Way

https://redvice.org/2026/coverage-the-wrong-way/
4•matt_d•1h ago•1 comments

Oxc (popular front-end tooling) forked my parser but removed my copyright notice

https://github.com/oxc-project/oxc-css-parser/issues/92
4•gplane•1h ago•0 comments

Moby Dick Workout

https://www.hogbaysoftware.com/posts/moby-dick-workout/
11•helloplanets•1h ago•3 comments

My ASN Journey series (2024)

https://www.animmouse.com/p/my-asn-journey/
8•antonalekseev•1h ago•1 comments

The Electricity: Why Google may be trying to make intelligence disappear

https://manasbihani.substack.com/p/the-electricity
2•manasb25•1h ago•0 comments

Reading Minds with Ultrasound: Less-Invasive Technique for Brain's Intentions (2021)

https://www.caltech.edu/about/news/reading-minds-with-ultrasound-a-less-invasive-technique-to-dec...
3•mgh2•1h ago•0 comments

HarnessMonkey – claude mods to show hidden tokens & improve vibes!

https://github.com/hackerbara/harnessmonkey
2•hackerbara•2h ago•1 comments

RTS a TypeScript-to-Native Compiler/Runtime in Rust (Cranelift JIT and AOT)

https://github.com/UrubuCode/rts
2•azx0025•2h ago•0 comments

Show your hands honor for the power they bring you

https://aresluna.org/show-your-hands-honor/
8•aua•2h ago•1 comments

Show HN: Inches to CM converter with charts and screen size references

https://inches-to-cm.net
2•robot1996•2h ago•2 comments

Perchlorate

https://en.wikipedia.org/wiki/Perchlorate
5•soupspaces•2h ago•1 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.