frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Ask HN: What do you use for scientific presentations?

1•hamburgererror•1m ago•0 comments

Show HN: UAVs FYI – Drone database with supply chain data, API and CLI

https://www.uavs.fyi/
1•Osoraku•2m ago•0 comments

GLM-5.2: Chop off 84% of the volume from a 1.5TB model, still retain 82% power

https://twitter.com/AYi_AInotes/status/2067642004184383564
3•vantareed•2m ago•1 comments

Claude Artifacts

https://claude.com/blog/artifacts-in-claude-code
2•czeizel•4m ago•0 comments

Show HN: One-click fork of "Everything Claude Code" onto an isolated microVM

https://www.jurniti.com/templates/ecc
1•shving90•5m ago•0 comments

Trillions of dollars spent just to work on customer services?

1•YihaoZhang•7m ago•0 comments

Capitol Alpha Machine – interactive viz of congressional stock trades

https://capitolalpha.app/
1•sylvainbe•10m ago•0 comments

GCP IAM Authorization Bypass

https://olearysec.com/research/config-connector-authorization-bypass/
3•sanbor•11m ago•0 comments

Show HN: Avera – a deterministic check that proves no regression was introduced

https://github.com/tc7kxsszs5-cloud/avera
1•kiku79•11m ago•0 comments

Build yor form back end infrastrture under 30sec

1•unaisshemim•12m ago•1 comments

Elysia Marginata

https://en.wikipedia.org/wiki/Elysia_marginata
1•ZeljkoS•14m ago•1 comments

RemotePower – self-hosted fleet monitoring with built-in vulnerability scanning

https://github.com/tyxak/remotepower
1•tyxak•19m ago•0 comments

Show HN: I was drowning in browser tabs, so I built this

https://microsoftedge.microsoft.com/addons/detail/gopeek/ffaeanmhghmohbponokefmbhfkkomnmk
4•formit34•20m ago•1 comments

Icon.museum – A curated gallery of app icon design

https://icon.museum
1•akashwadhwani35•20m ago•0 comments

Impossible Challenge

https://itch.io/jam/impossible-challenge
1•alisio85•20m ago•0 comments

Terminal-Bench Challenges: long-horizon, token-intensive, single-task benchmarks

https://www.tbench.ai/news/terminal-bench-challenges
1•matt_d•20m ago•0 comments

High-performance code intelligence MCP server

https://github.com/DeusData/codebase-memory-mcp
1•giamma•21m ago•1 comments

Show HN: Redteam:If you are using more than 2 coding agents

https://github.com/AscendyProject/redteam
1•rkdgh19•25m ago•0 comments

Usbliter8 an A12/A13 SecureROM Exploit

https://ps.tc/pages/blog-usbliter8.html
2•Cider9986•28m ago•0 comments

Ukrainian drone makers target Asia as Taiwan tensions spur demand

https://www.reuters.com/world/china/ukrainian-drone-makers-target-asia-taiwan-tensions-spur-deman...
1•JumpCrisscross•28m ago•0 comments

HN with pics – a visual hcker.news reader

https://hn.is-ai-good-yet.com/
1•ilyaizen•33m ago•0 comments

Dana Scott: Lambda Calculus, Forcing and the Foundations of Math: #14 aboutlogic [video]

https://www.youtube.com/watch?v=opLbbZ-_AWE
1•matt_d•35m ago•0 comments

Prodigy: AI Employees

https://docs.google.com/presentation/d/1aldEHGR_1Hv_F0UlTuQIL8mXhsw5s5VzuuPcgKV5czY/edit?usp=sharing
2•samayashar•39m ago•2 comments

We built a status page service on Cloudflare

https://ampliflare.com/blog/status-page-cloudflare-architecture/
1•powerpurple•41m ago•1 comments

I tested Gemma4 12B on my 8GB GPU, now I don't want to go back to smaller models

https://www.xda-developers.com/tested-google-gemma-4-12b-on-8gb-gpu-and-dont-want-to-go-back-to-s...
1•theanonymousone•42m ago•0 comments

Make-work and Sub-subsistence work

https://wilsoniumite.com/2026/06/19/make-work-and-sub-subsistence-work/
1•Wilsoniumite•42m ago•0 comments

'We created a monster': companies rein in AI usage as costs strain budgets

https://www.ft.com/content/1d37cc08-e0aa-45a4-a45d-4ad282529314
2•JumpCrisscross•43m ago•0 comments

One Model Won't Save You: How We Built Our AI Stack

https://www.xelerate.tech/one-model-wont-save-you/
1•pedrocha•45m ago•0 comments

Mantyx – Batteries Included Managed Agent Runtime

https://mantyx.io/
1•mantyx•45m ago•0 comments

Show HN: Write SaaS apps where users control where their data is stored

https://github.com/wolfoo2931/linkedrecords/
1•WolfOliver•50m 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.