frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Hacker News Down

2•areofyl•1m ago•1 comments

Suica, Japan's First IC Transit Card

https://www.tokyodev.com/articles/the-story-of-suica
1•pwim•6m ago•0 comments

Memory Ordering in CPUs

https://fgiesen.wordpress.com/2026/08/25/memory-ordering-in-cpus/
1•Tomte•35m ago•0 comments

Placemark is now open source

https://macwright.com/2026/08/25/placemark-fully-open-source
1•Tomte•35m ago•0 comments

Run Open Models on Claude Desktop

https://ollama.com/blog/claude-desktop
1•ttunguz•54m ago•0 comments

Pilot program offering free bus rides to Detroit students to become permanent

https://www.detroitnews.com/story/news/local/detroit-city/2026/08/14/sheffield-makes-free-ddot-tr...
2•thunderbong•54m ago•0 comments

Ask HN: How do you explain system design to engineers who weren't in the room?

1•pandurang90•56m ago•1 comments

Kraftapp AI – Describe it. We build it. Customers find it

https://kraftapp.ai
1•ssurse•59m ago•0 comments

Show HN: Hands-on Docker security labs, from CIS checks to AI context poisoning

https://github.com/opscart/docker-security-practical-guide
1•opscart•1h ago•0 comments

I ran my code intelligence engine on 1k GitHub repositories

https://github.com/thecolourfoundation/rune�
1•malixp•1h ago•0 comments

I'm an Amazon SVP who hadn't coded in 25 years

https://www.aboutamazon.com/news/workplace/amazon-svp-ai-tools-employees-careers
2•dhruv3006•1h ago•0 comments

Show HN: MageCDN – Image CDN with unlimited bandwidth

https://magecdn.com/
1•shubhamjain•1h ago•0 comments

Drop JD and get customized interview course

https://www.interviewbasecamp.com/
1•balkrishnajha•1h ago•0 comments

Semantic caching has a structural gap that no threshold fixes

https://github.com/KushagraKanaujia/throttle/blob/main/scripts/negation_check.py
1•JohnScheuer•1h ago•0 comments

Show HN: A proxy that makes Forgejo speak the GitHub API

https://github.com/ThatXliner/anvil
1•thatxliner•1h ago•0 comments

The AI founders who walked away from Bezos-backed Prometheus to model universe

https://www.reuters.com/business/ai-founders-who-walked-away-bezos-backed-prometheus-model-univer...
2•petethomas•1h ago•0 comments

Extension 'ms-VSCode-remote.remote-SSH' CANNOT use API proposal

https://github.com/microsoft/vscode/issues/329735
2•themostunique•1h ago•0 comments

Students prefer Gemini over ChatGPT and Claude for AI essays in blind tests

https://studyarena.com/blog/chatgpt-vs-claude-vs-gemini-college-essays-2026
2•pasharayan•1h ago•1 comments

BetterReads: Read/Import/Track/Understand

https://www.betterreads.online
1•zlu•1h ago•1 comments

Data Centers Are Driving an Alarming Gas Power Expansion in the US

https://www.wired.com/story/us-data-centers-drive-gas-power-expansion/
3•newsomix9xl•1h ago•1 comments

Neuromancer Official Teaser

https://www.youtube.com/watch?v=g79GPZSQHBk
3•wslh•1h ago•0 comments

Ask HN: What is one simple thing LLMs are insanely bad at?

22•davidest•1h ago•38 comments

Plans for nuclear-powered merchant ships must confront risks

https://www.nature.com/articles/d41586-026-02388-6
1•mmooss•1h ago•0 comments

What platform has the best AI CMO?

1•probablygrillin•1h ago•0 comments

ILSpy in the Browser

https://osenkov.com/ilspy/
1•l33t_d0nut•1h ago•0 comments

Visual Analysis of Binary Files

https://binvis.io/#/
2•vismit2000•1h ago•0 comments

Show HN: Implementation of Kimi K3 in PyTorch

https://www.youtube.com/watch?v=U6sobPCsdaY
1•prasoon21•1h ago•0 comments

Darkbloom (AI inference on idle Macs) – security audit with PRs submitted

https://gist.github.com/mudiam/1ffc898333ac3d5bdc5d7fac96d33360
2•mudiam•1h ago•0 comments

RL Environments are all you need

https://twitter.com/madiator/status/2084657077637746957
2•gmays•1h ago•0 comments

Libracy – An ad-free, minimalist book tracker without social feeds

https://play.google.com/store/apps/details?id=com.libracy.app&hl=en_US
2•cehnzzdev•2h 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.