frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Building a simple tool to help students explore income options

https://www.sidebuz.com/student-income-finder/
1•asphero•4m ago•0 comments

Taxation in a Strong AI World

https://marginalrevolution.com/marginalrevolution/2026/01/taxation-in-a-strong-ai-world.html
1•samuel246•6m ago•0 comments

'College dropout' has become the most coveted startup founder credential

https://techcrunch.com/2025/12/31/college-dropout-has-become-the-most-coveted-startup-founder-cre...
1•0in•7m ago•0 comments

SIGGRAPH2025 Advances in Real-Time Rendering: IdTech8 Global Illumination [video]

https://www.youtube.com/watch?v=VTrdeqMMMK0
1•chii•8m ago•0 comments

UCLA Distinguished Lecturer Series – Alan C. Kay, Apple Computer, April 1993 [video]

https://www.youtube.com/watch?v=P2WnZ7n4-P4
1•gjvc•10m ago•0 comments

When cheating is harder than practicing

https://www.youtube.com/watch?v=JQB8aNKyeao
1•AstroNutt•15m ago•1 comments

Aura – A Ruby-inspired declarative language for AI/ML pipelines and web apps

https://github.com/johnvteixido/aura-lang
1•johnvteixido•16m ago•1 comments

Spherical Snake

https://kevinalbs.com/spherical_snake/
1•subset•16m ago•0 comments

British ethical hacker granted rare visa after finding 'critical vulnerability

https://www.msn.com/en-ie/money/technology/brit-hacker-cracks-australian-government-site-to-prove...
2•asdefghyk•17m ago•1 comments

Real-time liquidity and contagion risk monitoring for 24/7 tokenized markets

https://patternos.com
1•CascadeGuard•21m ago•1 comments

Generating Human Faces with VAEs

https://mayberay.bearblog.dev/generating-human-faces-with-variational-autoencoders/
1•mugamuga•22m ago•0 comments

Show HN: Neural_covenant – 129-modality AGI stack built for sovereignty

1•AISovereignDev•26m ago•1 comments

Show HN: A small R5RS-ish Scheme interpreter with call/cc

https://github.com/menezesd/scheme
1•deanmen•28m ago•0 comments

Welcome to the Public Domain in 2026

https://blog.archive.org/2026/01/01/welcome-to-the-public-domain-in-2026/
2•exploraz•34m ago•0 comments

Show HN: Ts-bridge, tsserver lsp shim with daemon for Neovim

https://github.com/chojs23/ts-bridge
3•neo22•37m ago•0 comments

Pidgin 3.0 Experimental 5 (2.94.0) has been released

https://discourse.imfreedom.org/t/pidgin-3-0-experimental-5-2-94-0-has-been-released/338
1•rw_grim•38m ago•0 comments

Apple cuts Vision Pro production and marketing after weak sales

https://www.ft.com/content/ab817ba1-15ec-473f-b609-5b5016b3258d
1•nutjob2•41m ago•0 comments

Block web unless Claude Code is running

https://github.com/T3-Content/claude-blocker
1•sanreau•43m ago•0 comments

Bayesian A/B testing is not immune to peeking

https://www.alexmolas.com/2025/10/30/bayesian-ab-test-peeking.html
3•azhenley•57m ago•0 comments

Why Write Online Now?

https://blog.tdhttt.com/post/why-write-online-now/
3•tdhttt•1h ago•0 comments

Show HN: The Best Way to use MCPs with coding agents

https://jilebi.ai
2•datron•1h ago•0 comments

Scribus – open-source Desktop Publishing

https://www.scribus.net/
1•rickcarlino•1h ago•0 comments

Wan 2.6 Video Generator,role-playing,cinematic AI video creation with Sound

https://wan2-6.org/
2•xinhuokeji•1h ago•0 comments

Show HN: Forensic evidence of iOS mesh networking bypassing Airplane Mode

https://github.com/JGoyd/NeuralNet
2•TakeFlight007•1h ago•4 comments

Tell HN: Happy New Year

4•grenran•1h ago•0 comments

The cost of finding products you love

https://notes.barkata.com/snippets/the-cost-of-finding-products-you-love
2•weliveagain•1h ago•0 comments

It Can Apply and Positive in Favor the Newton III Law on an Engine System Device

1•monterrey•1h ago•0 comments

Show HN: Arvo – TypeScript toolkit for event-driven agentic systems and mesh

https://www.arvo.land/
1•saadahmad•1h ago•0 comments

Statically Linking PipeWire

https://gamesbymason.com/blog/2025/statically-linking-pipewire/
3•todsacerdoti•1h ago•0 comments

Ask HN: Managing data and digital devices during an interstate/overseas move

2•bassiouni•1h ago•0 comments
Open in hackernews

Ask HN: Java why put string in a constant?

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