frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Accelerando, but Janky

https://taoofmac.com/space/blog/2026/02/06/1245
1•rcarmo•23s ago•0 comments

Show HN: Model Tools Protocol (MTP) – Forget MCP, bash is all you need

https://github.com/modeltoolsprotocol/modeltoolsprotocol
1•nr378•37s ago•0 comments

Thoughts on AI-Assisted Software Development in 2026

https://taoofmac.com/space/notes/2026/02/01/2130
1•rcarmo•1m ago•0 comments

Show HN: Sign Any PDF Free – No account, no watermarks, no limits

https://signanypdffree.com/
1•detroitwebsites•2m ago•0 comments

AgentVault: Security Wrapper for OpenClaw (built in a couple hours))

https://github.com/hugoventures1-glitch/agentvault
1•hugoventures1•3m ago•1 comments

UK justice ministry orders deletion of largest court archive court

https://twitter.com/europa/status/2020851497437708297
1•nomdep•3m ago•0 comments

SAIR: Terence Tao's Foundation Uniting Nobel, Turing, Fields Laureates and AI

https://sair.foundation/
1•badr_elmazaz•4m ago•0 comments

Show HN: GPU ROI simulator based on token usage and model architecture

https://axiomos.ai/decide/
1•pierreseck•5m ago•1 comments

Hex Fiend – Simple hexadecimal math game

https://do-say-go.github.io/hexfiend/
1•keepamovin•8m ago•0 comments

Show HN: Darna – Atomic commit validator for Go

https://github.com/darccio/darna
1•darccio•9m ago•0 comments

What we can learn from tiny traces of ancient blood chemicals

https://theconversation.com/life-in-fossil-bones-what-we-can-learn-from-tiny-traces-of-ancient-bl...
1•PaulHoule•9m ago•0 comments

The things I am good at

https://cnicodeme.com/the-things-i-am-good-at
3•cx42net•9m ago•0 comments

I Cut My Google Search Dependence in Half

https://hister.org/posts/how-i-cut-my-google-search-dependence-in-half/
7•mstef•10m ago•2 comments

Four Spaces Before <?php

https://brunopinto.dev/four-spaces-before-php/
1•placeholder_•11m ago•0 comments

Crocker's Rules

http://sl4.org/crocker.html
1•surprisetalk•11m ago•0 comments

Shades of Halftone

https://blog.maximeheckel.com/posts/shades-of-halftone/
2•surprisetalk•11m ago•0 comments

Israel used weapons in Gaza that made Palestinians evaporate

https://www.aljazeera.com/features/2026/2/10/israel-used-weapons-in-gaza-that-made-thousands-of-p...
5•Qem•11m ago•1 comments

Blockchain Is a Galactic Algorithm

https://shakeddown.substack.com/p/blockchain-is-a-galactic-algorithm
1•surprisetalk•11m ago•0 comments

Client PrompX

https://client.prompx.com
1•PrompX•12m ago•1 comments

How the Little Guy Moved

https://animationobsessive.substack.com/p/how-the-little-guy-moved
1•vinhnx•12m ago•0 comments

Show HN: Murmur – open-source cron daemon for coding agents

https://github.com/t0dorakis/murmur
1•t0dorakis•13m ago•1 comments

A tool for automatic Haskell binding generation from C header files

https://well-typed.com/blog/2026/02/hs-bindgen-alpha/
2•romes•15m ago•0 comments

Tuning to Experiential Learning

https://www.sounding.com/2026/02/10/tuninglearning/
2•mooreds•16m ago•0 comments

Show HN: Open-source Liquid sections for Shopify themes

https://github.com/bilalnaseer/shopify-sections
2•wspycnews•16m ago•0 comments

Estonian Intelligence 2026 International and Domestic Threat Report

https://raport.valisluureamet.ee/2026/en/
2•atlasunshrugged•16m ago•0 comments

No one wants to admit the real reason corporations are laying off thousands

https://thehill.com/opinion/technology/5726509-valuable-employees-corporate-layoffs/
5•nradov•16m ago•0 comments

Show HN: Browser-based video compositor built on WebGPU

https://www.masterselects.com
3•Sportinger•18m ago•0 comments

The death of Washington Post's Book World: What it means for readers

https://www.newyorker.com/books/page-turner/the-death-of-book-world
2•bookofjoe•19m ago•3 comments

Show HN: Taphouse – A Native macOS GUI for Homebrew

4•mmsols•19m ago•0 comments

Guide to Java Web Application Errors: Common Exceptions and Real-World Solutions

https://www.jvmhost.com/articles/most-common-java-errors/
1•jvmhost•19m ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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