frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Mozilla soliciting feedback on Firefox 160's new mini window feature

https://connect.mozilla.org/t5/discussions/mini-window-beta-is-going-live-in-firefox-160-and-we-w...
1•davidee•2m ago•1 comments

Why GPT-6 Astra is suddenly so good at robotics

https://twitter.com/josefchen/status/2117749992420946241
1•josefchen•3m ago•0 comments

Revisiting Buttons and Cursors

https://www.abeautifulsite.net/posts/revisiting-buttons-and-cursors/
1•soheilpro•4m ago•0 comments

NotLate

https://www.adribyte-studio.com/mobile-apps/notlate
1•AdriByte-Studio•5m ago•0 comments

OpenSc3k – SimCity 3000 Open Source

https://opensc3k.com/
1•ludde•6m ago•1 comments

Show HN: Predictygraph – animated diagrams styled with CSS, no reshuffle on edit

https://predictygraph.github.io/
1•rjzzleep•6m ago•0 comments

Local AI app that runs an 80B model on an 8GB Mac

https://yanahchat.com
1•giovanniwants•7m ago•1 comments

Show HN:Pptx-to-Pdf – Convert PowerPoint to PDF in Node.js Without LibreOffice

https://github.com/ahmedessam090/pptx-to-pdf
1•domysalem10•7m ago•0 comments

Show HN: Gesture Studio – Windows gesture shortcuts for touch, pen, and mouse

https://apps.microsoft.com/detail/9nz37wkhnbb3?hl=en-US&gl=US
1•askfutureproof•10m ago•0 comments

The Brain Injury That Made Edward Freytag a Musical Genius

https://www.nytimes.com/interactive/2026/11/02/magazine/brain-injury-music-perfect-pitch-edward-f...
1•bookofjoe•13m ago•1 comments

Writing as an act of rebellion (Despite the AI psychosis)

https://charlesfonseca.substack.com/p/writing-as-an-act-of-rebellion
1•barddoo•16m ago•0 comments

How much do tokens cost?

https://substack.hadley.nz/p/how-much-do-tokens-really-cost
1•rorylawless•16m ago•0 comments

Raspberry Pi 5 16GB Price Rises to $385 USD

https://www.phoronix.com/news/Raspberry-Pi-5-16GB-385
2•xlayn•20m ago•1 comments

Gemini Notebook API

https://developers.google.com/notebook/docs
1•jonbaer•22m ago•0 comments

Colour Malarkey

https://retrorgb.com/colour-malarkey.html
1•bpierre•23m ago•0 comments

Testing without a server: using FakeValkey, the in-memory test double for Valkey

https://valkey.io/blog/testing-without-a-server-fakevalkey/
1•gslin•27m ago•0 comments

Google Disrupts 1.3M Device Botnet, Says TV Box Maker Sold Criminal Access

https://cloud.google.com/blog/topics/threat-intelligence/shutting-the-door-on-the-xcpe-botnet/
1•motionlessveloc•29m ago•1 comments

Taco: The Tensor Algebra Compiler

http://tensor-compiler.org/
1•measurablefunc•29m ago•0 comments

Cat Wu, product lead for Claude Code, has left Anthropic

https://www.businessinsider.com/claude-code-leader-cat-wu-exits-anthropic-before-big-ipo-2026-11
1•aanet•30m ago•2 comments

SpaceX Will Be the Biggest AI Cloud

https://newsletter.semianalysis.com/p/elon-is-doing-it-again-spacex-will
2•nsoonhui•34m ago•1 comments

Nsw Health Breached

https://www.smh.com.au/national/nsw/100-000-documents-stolen-from-isolated-nsw-health-server-2026...
3•technion•37m ago•0 comments

Show HN: Retro: I rebuilt bomberman game, same gameplay, new interface

https://playbomber.com/
2•dutay05•38m ago•0 comments

Revolut switched to GLM. We found hidden risks

https://www.hirundo.io/blog/glm-revolut
1•mattifrank•39m ago•0 comments

Systemd Loves Rust

https://amutable.com/blog/systemd-loves-rust
1•jcgl•40m ago•1 comments

AI Can Read Neural Network Weights. I Wasn't Ready for That. – Arcturus Labs

https://arcturus-labs.com/blog/2026/11/03/ai-can-read-neural-network-weights-i-wasnt-ready-for-that/
1•JohnBerryman•43m ago•0 comments

French blood storage facilities targeted in cyberattack

https://www.aa.com.tr/en/science-technology/french-blood-storage-facilities-targeted-in-cyberatta...
2•Fe2O3•43m ago•0 comments

Ask HN: What is the best non mainstream programming language or stack in 2026?

2•kbrannigan•46m ago•0 comments

Show HN: HackerReels - Short Videos for viral HN posts

https://wile.ai/v/BPOH3BHCRWWCAKU4OVNOTEQ73A
2•alexandroskyr•46m ago•3 comments

Sad Nipple Syndrome

https://en.wikipedia.org/wiki/Sad_nipple_syndrome
2•modzu•49m ago•0 comments

Outer Products: The Dual View of Linear Algebra

https://freddy.us/blog/posts/outer-products/
1•senderista•53m 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.