frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

She Brought Meta and Trump Together–Just in Time for the Democratic Onslaught

https://www.wsj.com/tech/dina-powell-mccormick-meta-trump-zuckerberg-ai-d5984bdc
2•snikolaev•1m ago•0 comments

"Don't Handoff" is not a plan

https://bengoldhaber.substack.com/p/dont-handoff-is-not-a-plan
1•lindowe•2m ago•0 comments

Musk is running from what he did to the world's poorest kids

https://www.editorialboard.com/musk-is-running-from-what-he-did-to-the-worlds-poorest-kids/
2•archagon•7m ago•0 comments

Show HN: debian-on-fuchsia - Run an unmodified Debian graphically on Fuchsia

https://github.com/flamecoals/debian-on-fuchsia/tree/main
1•flamecoals•10m ago•0 comments

Ask HN: Are software services businesses dead?

1•smarri•11m ago•0 comments

Only 22% of new sites run WordPress

https://joost.blog/share-of-new/
2•taubek•17m ago•0 comments

LinkMate: An offline-first link saver for Android, no account needed

https://play.google.com/store/apps/details?id=com.pixelplot.linkmate&hl=en_US
1•pixelplotapp•18m ago•0 comments

Really Stream Into Your LiveView Streams

https://krasen.be/really-stream-into-your-live-view-streams.html
1•nesarkvechnep•19m ago•0 comments

A guide to tradeoffs when designing a data format

https://mostlyquantized.com/blog/format-coordinates
1•phenomenon0•25m ago•0 comments

Show HN: Pool Club Live – 3D pool in the browser, online ranked

https://wavedash.com/games/pool-club-live
1•Arjun0014•25m ago•0 comments

Lem and the Mirror Problem: Why We Might Never Recognise Alien Life

https://culture.pl/en/article/lem-the-mirror-problem-why-we-might-never-recognise-alien-life
1•bryanrasmussen•26m ago•0 comments

Filmmakers aim to release Val Kilmer AI-generated performance next year

https://www.reuters.com/lifestyle/filmmakers-aim-release-val-kilmer-ai-generated-performance-next...
2•petethomas•27m ago•0 comments

Show HN: Quilzo – Control plane with policy, approvals and signed logs for agent

https://quilzo.io/
1•ras1k•27m ago•0 comments

AlphaJelly Review: Benefits, Features, Ingredients and Results

https://open.spotify.com/episode/7vHp4ZkduVxVhrVTgbieuW
1•Markmadenn•27m ago•1 comments

TalkAlive – Real-time WebRTC lip-sync and emotion avatar runtime (Apache-2.0)

https://github.com/dingguoliang8-eng/TalkAlive
1•dejavufs•28m ago•0 comments

Sanctum – A PQ-Secure VPN

https://sanctorum.se
1•jvink•32m ago•0 comments

Show HN: Hand drawn train over real photo and light animation

https://pixels.vedasdixit.com/about
1•vedas-dixit•32m ago•0 comments

Counting large numbers of events in small floating point registers

https://dotat.at/@/2026-12-02-approx-count.html
1•fanf2•35m ago•0 comments

Posture Apps that nudge you to sit better while you work at a computer

https://github.com/ssv445/awesome-posture-apps
1•shyam-verma•35m ago•0 comments

Show HN: NexusTools – Local-first AI workspace for Markdown, PDFs, and text

https://nexustools.tech/
1•nexusnote•39m ago•0 comments

Apple's FileMaker Pro Gaining Support for AI Coding Agents

https://www.macrumors.com/2026/12/02/filemaker-pro-ai-coding-agents/
1•Tomte•39m ago•0 comments

CapCut brings editable video drafts to ChatGPT users in the US

https://runtimewire.com/article/capcut-chatgpt-plugin-video-editing-us-launch
1•shebeckom•39m ago•0 comments

Sans AI – A Font that can't be read by AI

https://www.rmit.edu.au/about/schools-colleges/media-and-communication/industry/sans-ai
2•jawheaton•43m ago•0 comments

Egypt's Aswan Damn

https://unintendedconsequenc.es/egypts-aswan-damn/
2•paulorlando•45m ago•0 comments

Show HN: DataRanger – test a data fix against source totals before applying it

https://github.com/akshaysharma1088/dataranger
1•akshaysharma108•55m ago•0 comments

cx16os: Preemptive Multitasking on a 65816

https://github.com/cnelson20/cx16os
1•cameronnelson•57m ago•0 comments

How the Tech Right Learned to Love Mordor

https://www.thebulwark.com/p/how-the-tech-right-learned-to-love-mordor-jrr-tolkien-palantir-thiel
1•SLHamlet•57m ago•0 comments

Wellbeing and AI use: A study of 2k Claude users

https://www.anthropic.com/research/wellbeing-ai-use
1•axis_official•58m ago•0 comments

Roboclock: A Unified Benchmark for Time-Aware Robotic Intelligence

https://roboclockai.github.io/
1•matt_d•58m ago•0 comments

Show HN: SolidWorks but Open Source

https://github.com/rdproberts/BrokenLiquid
3•StooLue•1h 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.