frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Encapsulation Beyond Syntax: Do Access Modifiers Still Matter?

https://www.lihil.cc/blog/encapsulation-beyond-syntax-do-access-modifiers-still-matter/
1•ibobev•2h ago

Comments

ivanjermakov•2h ago
The most important function of encapsulation is separating public interface and internal implementation. For example, a library declares public functions available for users and private functions to use abstraction and implement functionality.

Of course it's not about syntax, it's about intent. In a language with no access modifiers using a foreign function starting with an underscore is automatically accepting that it is internal an has no guarantees as public API.

But encapsulation can be applied where it shouldn't. First, it is controversial to apply encapsulation in class or module level. If you're a part of the same codebase, what's the problem with breaking the contract? Famous problem arising from this is unit testing private methods of a class.

Second, it's controversial to encapsulate state. For example, there are no private structure fields in Zig[1]. Justification is that for a great control user needs to know the layout of the struct.

So to me it boils down to a decision of where to draw the line between API and internal. One could alas write programs as a bunch of small models each having own API. Or one could write the whole program in five huge classes, making private methods necessary to make differentiate "useful" ones.

The article has a bit of a "clean code" smell and lacks critique and shortcomings of lack and excess of encapsulation.

[1]: https://github.com/ziglang/zig/issues/9909

mrkeen•1h ago
There is a fantastic concept called encapsulation, but OO encapsulation isn't it.

For an actual example of encapsulation, look at C stack variables. They are actually encapsulated within their function.

It's how the C function is able to operate as a black box - the true meaning of "encapsulation".

If you could write getter methods to expose C stack variables to outside callers, they would become just as non-encapsulated as OO class fields.

Good online floor plan cad tool

https://floorplancreator.net/
1•morpheos137•2m ago•1 comments

People who see society as cutthroat value antagonistic leaders, study finds

https://www.livescience.com/human-behavior/people-who-see-society-as-cutthroat-value-antagonistic-leaders-study-finds
1•Bluestein•3m ago•0 comments

Rapidhash: A new fastest rust hasher

https://github.com/hoxxep/rapidhash
1•liam-gray•5m ago•1 comments

KDE Plasma prepares crackdown on focus-stealing window behavior under Wayland

https://www.neowin.net/news/kde-plasma-prepares-crackdown-on-focus-stealing-window-behavior-under-wayland/
1•bundie•5m ago•0 comments

Photonic SNN chip reaches 1 GHz and supports on-chip learning

https://arxiv.org/abs/2506.14272
1•juanviera23•7m ago•0 comments

So Long to Tech's Dream Job

https://www.nytimes.com/2025/08/04/technology/tech-jobs-silicon-valley-changes.html
1•gist•8m ago•0 comments

Dark clouds ahead: hyperscalers can't safeguard one nation's data from another

https://www.theregister.com/2025/08/04/when_hyperscalers_cant_safeguard_one/
1•rntn•14m ago•0 comments

Pianobook gets new creative director

https://www.youtube.com/watch?v=fH9VQbzc0-g
1•tomcam•18m ago•0 comments

A.I. Has Ushered in Silicon Valley's 'Hard Tech' Era

https://www.nytimes.com/2025/08/04/technology/ai-silicon-valley-hard-tech.html
1•ianrahman•19m ago•0 comments

The Q Programming Language

https://git.urbach.dev/cli/q
1•ygritte•21m ago•0 comments

Libra AI: The open-source V0/Lovable alternative

https://github.com/nextify-limited/libra
1•yaobingxun•22m ago•0 comments

Practical Steps to Avoid ChatGPT Psychosis

https://carsonogenic.substack.com/p/practical-steps-to-avoid-chatgpt
1•thatsso1999•24m ago•1 comments

Britain missed the first crypto wave. We can't miss the second

https://www.ft.com/content/3eded430-a854-44d6-9739-e8a350eae25f
1•NomDePlum•29m ago•1 comments

Fun with MeshBlend

https://www.c0de517e.com/024_meshblend.htm
1•ibobev•29m ago•0 comments

The curse of 'Disco Elysium', the greatest RPG ever made

https://www.ft.com/content/5ae5bf4f-4c05-4286-8133-5b812309d636
1•tolien•30m ago•1 comments

Debugging AMD-Specific Issues with Driver Experiments Tool

https://asawicki.info/news_1788_debugging_amd-specific_issues_with_driver_experiments_tool
1•ibobev•30m ago•0 comments

OpenAI Needs Adult Supervision

https://www.thepourquoipas.com/post/openai-needs-adult-supervision
1•ThePourquoiPas•32m ago•0 comments

Perfecting anti-aliasing on signed distance functions

https://blog.pkh.me/p/44-perfecting-anti-aliasing-on-signed-distance-functions.html
3•ibobev•32m ago•0 comments

Pocket ID: A Simple but Powerful OIDC Provider for SSO with Passkeys

https://github.com/pocket-id/pocket-id
1•alexanderameye•39m ago•0 comments

Show HN: I Built a Web App with Svelte and GPTs

https://www.ivontime.com/app
1•liviu31•42m ago•0 comments

Open Music Foundation Models for Full-Song Generation

https://map-yue.github.io/
1•selvan•42m ago•0 comments

Plastics a 'grave' danger to health, scientists warn before UN talks

https://www.ft.com/content/09108445-c1cb-45c2-b145-d767d56aeb7b
3•cebert•42m ago•1 comments

Tesla Approves Interim 96M Stock Award for Musk

https://www.bloomberg.com/news/articles/2025-08-04/tesla-approves-interim-stock-award-for-musk-ahead-of-pay-vote
2•helsinkiandrew•43m ago•1 comments

Ask HN: UX – What time consuming tasks have you successfully automated?

1•iolmao•44m ago•0 comments

Show HN: PageZero – Learn any skill through AI-driven interactive prompts

https://pagezero.ai
1•hskhawaja•44m ago•0 comments

Show HN: AI Sandbox with Kata, Firecracker, Cloud HV (E2B, Daytona Alternative)

https://www.cognitora.dev
2•mikerubini•45m ago•1 comments

Steve Wozniak is not boring

https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go
2•TheSilva•49m ago•2 comments

Show HN: Pro quality AI themed photo packs from your selfies curated by humans

https://coolphoto.ai
4•ferreirarmp•50m ago•0 comments

Phaistos Disc

https://en.wikipedia.org/wiki/Phaistos_Disc
2•wjSgoWPm5bWAhXB•52m ago•0 comments

Tesla board awards $29B of shares to Elon Musk

https://www.ft.com/content/ae085ae9-3d15-4d68-a28f-39c88e8bf8c8
4•TheAlchemist•55m ago•1 comments