frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Boundary Enforcement in Code Review

1•mthssalome•2m ago•0 comments

Owners, not renters: Mozilla's open source AI strategy

https://blog.mozilla.org/en/mozilla/mozilla-open-source-ai-strategy/
1•nalinidash•2m ago•0 comments

Show HN: Janus – Anki flashcards from PDFs, videos and notes

https://janus.cards
1•A-F-V16•3m ago•1 comments

$999 RTX 5090 GPU scam claims 42 victims

https://www.tomshardware.com/pc-components/gpus/usd999-rtx-5090-gpu-scam-claims-42-victims-fanny-...
1•croes•3m ago•0 comments

People as Harmonic Oscillators

https://dogdogfish.com/blog/2026/01/13/people-as-oscillators/
1•matthewsharpe3•10m ago•1 comments

Hit squad recruiter for Sweden's Foxtrot criminal network arrested in Iraq

https://www.thenationalnews.com/news/mena/2026/01/13/hit-squad-recruiter-for-swedens-foxtrot-crim...
1•campuscodi•10m ago•0 comments

Show HN: MakersHub.dev – A community platform for people building with AI tools

https://makershub.dev/
1•adilmoujahid•11m ago•0 comments

Show HN: FreeMarker Support for Zed Editor

https://github.com/debba/zed-freemarker
1•debba•12m ago•0 comments

Ask HN: Quantum Computation, Computers and Programming

1•rramadass•15m ago•0 comments

Show HN: Policy-governed AI system for offline deployment in expertise deserts

https://github.com/thepoorsatitagain/Tutor-to-disaster-expert
1•thepoors•15m ago•0 comments

Podshop, the hedge fund game. As seen on Bloomberg's money stuff

https://www.podshop.io
1•WiseHare•16m ago•0 comments

Could Magic Mushrooms Have 'Woken Up' Our Ancestors?

https://thesporereport.com/?p=580
1•richrichardsson•17m ago•0 comments

WebUSB Unpinner: network analysis for the masses

https://reversing.works/posts/2025/12/webusb-unpinner-network-analysis-for-the-masses/
1•chobeat•18m ago•0 comments

Show HN: High-precision mouse polling rate tester

https://mousepollingratetest.com/
1•zylics•21m ago•1 comments

User authorization just got 10x harder

https://leaddev.com/event/user-authorization-just-got-10x-harder
2•mooreds•21m ago•0 comments

Ask HN: Infrastructure teams – what's your biggest compliance headache?

1•coppinfra•23m ago•0 comments

Iran official says 2k people have been killed in unrest

https://www.reuters.com/world/china/iranian-mp-warns-greater-unrest-urging-government-address-gri...
5•JumpCrisscross•23m ago•2 comments

Dullness and Disbelief: The 2026 AI Regression

https://vibesbench.substack.com/p/dullness-and-disbelief-the-2026-ai
2•firasd•24m ago•0 comments

Show HN: Fruito – match-3 puzzle game I made with Claude Code

https://fruito.sawirstudio.com/
1•sawirricardo•25m ago•1 comments

The World Has a New Lowest Birth Rate Country: Taiwan at 0.72

https://www.taipeitimes.com/News/front/archives/2026/01/10/2003850357
1•cwwc•25m ago•0 comments

Is Elon Musk the Worst in Tech?

https://aiweekly.co/issues/459
1•treadump•27m ago•2 comments

DoorDash and Pizza Arbitrage (2020)

https://www.readmargins.com/p/doordash-and-pizza-arbitrage
1•timvdalen•27m ago•0 comments

Docker just made their hardened images free and open source

https://twitter.com/BetterStackHQ/status/2011011753136517126
1•landsman•28m ago•0 comments

Thirteen Months That Changed IBM

https://newsroom.ibm.com/Thirteen-Months-That-Changed-IBM
2•vednig•29m ago•0 comments

Using the Physics of Radio Waves to Empower Smarter Edge Devices

https://pratt.duke.edu/news/using-the-physics-of-radio-waves-to-empower-smarter-edge-devices/
1•wjSgoWPm5bWAhXB•30m ago•0 comments

Facebook login thieves now using browser-in-browser trick

https://www.bleepingcomputer.com/news/security/facebook-login-thieves-now-using-browser-in-browse...
1•7777777phil•31m ago•0 comments

Why Is Everyone Suddenly Talking About Putting Data Centers in Space?

https://theintercept.com/2026/01/12/data-centers-space-ai/
2•Qem•31m ago•0 comments

The value of random zero-sum games

https://arxiv.org/abs/2601.07759
2•7777777phil•31m ago•0 comments

How General Counsel Can Operationalise AIVO Inside Legal Workflows

https://www.aivojournal.org/how-general-counsel-can-operationalise-aivo-inside-legal-workflows/
1•businessmate•32m ago•1 comments

What's the deepest modern book on forecasting? (I wrote one)

https://valeman.gumroad.com/l/MasteringModernTimeSeriesForecasting
1•predict_addict•33m ago•1 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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