frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

The New Thelio Mira High Performance Desktop

https://blog.system76.com/post/system76-introduces-new-thelio-mira-high-performance-desktop/
1•shaunpud•17s ago•0 comments

Not-devops.com, a satirical blog about DevOps experiences

https://not-devops.com/
1•weird_trousers•47s ago•0 comments

RSS Gizmos – Tools for Creating, Finding, and Using RSS Feeds

https://rssgizmos.com/
1•ohjeez•1m ago•0 comments

Sparkling Water Helps Gamers Stay Focused for Hours

https://www.sciencealert.com/a-simple-drink-choice-helps-gamers-stay-focused-for-hours-study-finds
2•Gaishan•1m ago•0 comments

Show HN: Devopsiphai – A Claude Code skill to audit DevOps around 5 questions

https://github.com/sanhajio/devopsiphai
1•sanhajio•2m ago•0 comments

Android 15 appends .ogx to downloaded .ogg files – a MIME type mystery

https://file-converter-online.com/why-android-15-downloads-ogg-files-as-ogg-ogx-a-mime-type-analy...
1•iopodx•7m ago•1 comments

Show HN: Lore – Local AI thought capture and recall that runs on your machine

https://github.com/ErezShahaf/Lore
1•ErezShahaf•8m ago•0 comments

Kalshi criminally charged in Arizona for operating illegal gambling business

https://www.reuters.com/world/kalshi-charged-criminally-arizona-operating-illegal-gambling-busine...
3•petethomas•8m ago•0 comments

Roberts says personal hostility aimed at judges has 'got to stop'

https://www.reuters.com/legal/government/us-supreme-courts-roberts-says-personal-hostility-aimed-...
2•petethomas•12m ago•1 comments

GlassWorm malware hits 400 code repos on GitHub, NPM, VSCode, OpenVSX

https://www.bleepingcomputer.com/news/security/glassworm-malware-hits-400-plus-code-repos-on-gith...
1•uyzstvqs•13m ago•0 comments

Conductor – Multi-agent AI workflows in YAML with parallelism and human gate

https://github.com/microsoft/conductor
1•juniorlimaivd•13m ago•0 comments

Introduction to Human Behavioral Biology – Robert Sapolsky [video]

https://www.youtube.com/watch?v=NNnIGh9g6fA&list=PL150326949691B199
1•nomilk•17m ago•0 comments

Tars – A local-first autonomous supervisor powered by Google Gemini

https://tars.saccolabs.com
1•TarsAssistant•19m ago•0 comments

Nvidia expands open model families to power agentic, physical and healthcare AI

https://nvidianews.nvidia.com/news/nvidia-expands-open-model-families-to-power-the-next-wave-of-a...
3•teleforce•20m ago•0 comments

Eureka Manifesto: The Mission for Our Civilization

https://yurimilnermanifesto.org/reader.html
1•avonmach•22m ago•0 comments

Mamba-3

https://www.together.ai/blog/mamba-3
1•matt_d•22m ago•0 comments

We Banned React's UseEffect

https://twitter.com/alvinsng/status/2033969062834045089
2•alvsng•23m ago•0 comments

Build a NAS Using FreeBSD on a Raspberry Pi

https://freebsdfoundation.org/blog/build-a-nas-using-freebsd-on-a-raspberry-pi/
1•pss314•24m ago•0 comments

Nvidia announces Dynamo 1.0, first operating system designed for AI factories

https://nvidianews.nvidia.com/news/dynamo-1-0
1•teleforce•24m ago•0 comments

Dark Matter as Gravitational Memory: A Causal Rail for Wave Function Collapse

1•EvertonB•25m ago•1 comments

Pap: Zero Trust AI Agents

https://baur-software.github.io/pap/
1•toadkicker•25m ago•1 comments

Colorectal cancer now the most common cause of cancer deaths for people under 50

https://www.livescience.com/health/cancer/colorectal-cancer-is-now-the-most-common-cause-of-cance...
1•cpncrunch•27m ago•0 comments

AI Drone Software Stock Jumps 520% in Best IPO Since Newsmax

https://www.bloomberg.com/news/articles/2026-03-17/ai-drone-software-stock-jumps-700-in-best-ipo-...
1•defly•30m ago•0 comments

API Extractor: TypeScript Analysis Tool for API Reports, Docs and .d.ts Rollups

https://api-extractor.com/
1•stefankuehnel•30m ago•0 comments

Open AI is actively censoring information about voting today in the US

2•resters•32m ago•5 comments

AI costs are showing up before revenue in public cloud companies

1•alanjacobson•32m ago•0 comments

Firefox has killed its old mascot. Here's what the new (cute) one looks like

https://www.neowin.net/news/firefox-has-killed-its-old-mascot-heres-what-the-new-cute-one-looks-l...
1•bundie•32m ago•0 comments

Ask HN: Best Tech News Sites

1•zahirbmirza•38m ago•1 comments

Framedeck: A Framework mainboard based Cyberdeck

https://github.com/brickbots/framedeck
2•PaulHoule•38m ago•0 comments

HogPocket – Mobile dashboard for PostHog analytics

https://hogpocket.app
1•omardak•40m ago•1 comments
Open in hackernews

Ask HN: Java why put string in a constant?

1•ramsicandra•9mo 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•9mo 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•9mo 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.