frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Canada detects suspected AI-assisted cyberattack on government networks

https://www.canada.ca/en/treasury-board-secretariat/news/2026/11/statement-from-the-office-of-the...
1•elfigha•1m ago•0 comments

KeenWrite 3.7.1

https://keenwrite.com/
1•thangalin•2m ago•1 comments

Canadian Governenment says it has detected suspected AI-assisted cyberattack

https://www.cbc.ca/news/canada/federal-government-suspected-ai-cyberattack-9.7442795
1•petersonh•7m ago•0 comments

100% Incremental Rollback Netcode (Easel Dec 2026 Update)

https://easel.games/blog/2026-dec-update
1•BSTRhino•8m ago•1 comments

Show HN: Icey, a Highschooler's FPGA Board

https://github.com/darshg321/icey
1•darshg321•14m ago•0 comments

Show HN: Gantta-Claus

https://dawnofthe.dad/gantta-claus
1•userundefined•14m ago•0 comments

Advent of Chess (2026)

https://www.adventofchess.com/
1•autocorr•16m ago•0 comments

Rock Auto Stops Selling in Arizona

https://www.aztechcouncil.org/news/state-wants-11m-from-online-auto-parts-retailer-rockauto/
2•gscott•17m ago•1 comments

Perplexity AI's Comet collects browsing data after users try to restrict access

https://www.reuters.com/business/perplexity-ais-comet-browser-snoops-users-who-shut-off-tracking-...
2•bhrlady•22m ago•0 comments

Show HN: Termexo Fleet

https://github.com/gemron/Termexo-Fleet
1•gemron•34m ago•0 comments

The discipline required to create the life you want

https://ryanholiday.medium.com/the-discipline-required-to-create-the-life-you-want-117ed639e9a1
2•qikouki•42m ago•2 comments

Show HN: A game for learning computational neuroscience

https://spike.blackmetal.tech/
1•ixaxaar•43m ago•0 comments

Show HN: Adversarial Feed 100 fresh adversarial tests for AI agents every month

https://adversarialfeed.com/
1•AdamDiStefanoAI•46m ago•0 comments

Women's Preferences for Penis Size: A New Research Method Using 3D Models

https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0133079
5•Jun8•47m ago•1 comments

OpenAI, Elon Musk's Wild Plan to Set Artificial Intelligence Free

https://www.wired.com/2016/04/openai-elon-musk-sam-altman-plan-to-set-artificial-intelligence-free/
5•nastynate•47m ago•1 comments

Polytoria Goes Open Source

https://blog.polytoria.com/polytoria-goes-open-source/
1•roludemaru•51m ago•0 comments

Artex may be dangerous, but it's also dumb enough to hack itself

https://www.theregister.com/security/2026/11/30/artex-may-be-dangerous-but-its-also-dumb-enough-t...
2•magoghm•52m ago•0 comments

What If Your Dog Could Talk

https://campedersen.com/talking-dog
3•ecto•55m ago•0 comments

Israel to Install 200k Nvidia Chips in Data Centers by 2030

https://finance.yahoo.com/technology/ai/articles/israel-install-200-000-nvidia-170000871.html
4•LopRabbit•1h ago•0 comments

The Tidelift lifter program is ending Dec 31

https://twitter.com/JoshuaKGoldberg/status/2127498095823056961
2•stubish•1h ago•1 comments

ModelOS: A bare-metal GPU OS for LLM inference and training

https://github.com/yunwei37/modelos
1•yunwei37•1h ago•0 comments

Claude silently prevents security camera code from describing ethnicity, age

https://twitter.com/anorthwall/status/2127113022972088758
9•United857•1h ago•3 comments

Cloudflare Clairic System One Extraction Models Are Now Open-Weight

https://blog.cloudflare.com/open-clairic/
9•reddmachine•1h ago•2 comments

Russet is an open-source Rust FUSE server for plain and encrypted APFS on Linux

https://github.com/thatjuan/russet
2•0x6A75616E•1h ago•0 comments

Show HN: GuestGate – Leak-proof transparent proxy for VMware VMs

https://github.com/threatexpert/GuestGate
1•gonc_cc•1h ago•0 comments

Show HN: Bakodo.jp – Free Online Barcode Generator (111 Formats)

https://bakodo.jp/
2•wasmgame845•1h ago•0 comments

Nvidia brings 200k GPUs to Israel in $20B AI infrastructure push

https://www.calcalistech.com/ctechnews/article/dxjgchqry
3•myth_drannon•1h ago•0 comments

Consciousness Across Three Worldviews

https://www.noemamag.com/consciousness-across-three-worldviews/
3•argentinian•1h ago•0 comments

AgentGuard – Zero-dependency loop and spend guardrails for AI agents

https://github.com/nemor1-bit/agentguard
3•nremor1•1h ago•0 comments

The Copacetic Accord

https://therobot.institute/r/the-accords
1•matthewsinclair•1h 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.