frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

War Bros Didn't Always Rule Silicon Valley

https://www.wired.com/story/war-bros-didnt-always-rule-silicon-valley/
1•gmays•33s ago•0 comments

Use AI to check if a URL has been posted on HN already

1•spottedmarley•35s ago•0 comments

Etymon – Get rid of all your Claude.md, AGENTS.md, cursor/rules, mcp.json, etc.

https://github.com/landoncrabtree/etymon
1•landoncrabtree2•52s ago•1 comments

Layercake converts OpenStreetMap data into tables you can SQL query via a URL

https://layercake.openstreetmap.us/
1•raybb•2m ago•0 comments

I'm Calling for a Pause in the Development of the Universal Bone Dissolver

https://www.theatlantic.com/newsletters/2026/10/ai-slowdown-bone-dissolver/688854/
1•Jtsummers•2m ago•0 comments

Three Depths of Interaction

https://www.adidizdarevic.com/three-depths/
2•aadd•2m ago•0 comments

Pi 1.0

https://earendil.com/posts/pi-1-0/
3•sergiotapia•3m ago•0 comments

Building a Robust Ingestion System for Any File of Any Size

https://www.mixedbread.com/blog/infinite-file-sizes
1•sherlock_h•3m ago•0 comments

Show HN: Crookcooked – Open-source anti-theft alarm for Mac

https://crookcooked.github.io/crookcooked/
1•tbergkvist•4m ago•0 comments

Hanami, Why?: Introductions

https://aaronmallen.me/writing/hanami-why-introductions
1•birdculture•4m ago•0 comments

The $10B AI Assistant Challenging Meta's Muse, Grok's Bots, and OpenAI's Dots [video]

https://www.youtube.com/watch?v=Am7IWP8IpEc
1•simonebrunozzi•5m ago•0 comments

Deterministic architecture checks for coding agents

2•quynhng•5m ago•0 comments

Page Table Memory Consumption

https://frn.sh/pagetables/
1•matt_d•6m ago•0 comments

Hamas and PIJ Military Operatives Posed as Journalists

https://www.idf.il/en/mini-sites/the-press-files/
1•EvgeniyZh•8m ago•2 comments

I believe current AI models can think and understand – Part 1 of 2

https://blog.andymasley.com/p/why-i-believe-current-ai-models-can
1•jaredwiener•12m ago•0 comments

FLUX 3 Image

https://bfl.ai/models/flux-3-image
1•minimaxir•12m ago•0 comments

From Select to Sysadmin: Hijacking Microsoft SQL Copilot (CVE-2026-65669)

https://embracethered.com/blog/posts/2026/from-select-to-sysadmin-sql-copilot-bluehat-asia/
1•kerng•12m ago•0 comments

Pi Durable

https://earendil.com/posts/pi-durable/
2•paulsmith•12m ago•0 comments

The Open Anonymity Project – frontier AI models with privacy

https://chat.openanonymity.ai/login
1•owenshen24•12m ago•0 comments

Show HN: Ferry – Sync your coding agent setup to remote Linux boxes

https://dlhck.github.io/ferry/
1•dlhck•13m ago•0 comments

Show HN: Zsh-codex-assistant: codex session attached to your shell

https://github.com/klntsky/zsh-codex-assistant
1•klntsky•13m ago•0 comments

ArXiv Is Tapping the Brakes

https://blog.valency.io/posts/arxiv-is-tapping-the-brakes
2•joshbloom•14m ago•0 comments

GGUF Libra – Agent design based on forgetting mechanism

https://github.com/ckcool6/GGUF_Libra
1•lu_zhiyuan•16m ago•1 comments

To Log into the Teams

https://honeypot.net/2026/10/01/to-log-into-the-teams.html
1•speckx•18m ago•0 comments

AI-accelerated ideation across 2D, 3D, and AR in one collaborative canvas

https://www.vectary.com/canvas/
1•prfsch•20m ago•0 comments

Apex, a coding model specialized in mobile and web with React

https://www.callstack.com/blog/apex-agetic-coding-for-mobile-and-web-spcialied-in-react
5•thymikee•20m ago•1 comments

Scalable decision-making for games of imperfect information

https://www.nature.com/articles/s41586-026-11036-y
2•bucket2015•23m ago•0 comments

How to Cost Your AI-Powered Filters

https://fsdatalab.github.io/blog/ai-filter-cost-estimates/
2•shreya_shankar•23m ago•0 comments

Big Tech's Capex Is Half of Wall Street's Profit Growth

https://inlevel9.com/en/issues/half-the-growth-was-capex
9•speckx•24m ago•8 comments

Effect 4.0

https://effect.website/blog/releases/effect/40
2•stevefan1999•26m ago•2 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.