Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rip off of this article from 6 years ago?

https://hackernoon.com/value-ptr-the-missing-c-smart-pointer...

https://buckaroo.pm/blog/value-ptr-the-missing-smart-ptr

People have been writing pointer-like value semantic wrappers for type-erasure for decades.



(I'm the author of the blog post)

Indeed it's exactly the same idea (and I think `value_ptr` is actually a better name than `box`).

I've googled before writing the blog post and haven't found literature about this (but I was mostly googling stuff around "box" or "deep shared ptr").

Thank you for the link! Kinda glad it's more widespread than what I though actually, it means we can think about making an official proposal.


There was a proposal for such a thing in 2014

A Proposal for the World's Dumbest Smart Pointer, v4 - Open Standards https://open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4282.p...


"Boxing" as a term is a fairly well known concept. Unboxed values, etc.


I haven't seen it used in any mainstream language.


What do you consider a mainstream language?

Rust uses it in their standard library[0]. Haskell uses it[1]. Lisp seems to have originated the concept in the form of box diagrams[2]. F# uses it [3].

I think it might be a functional programming thing.

[0] https://doc.rust-lang.org/std/boxed/struct.Box.html [1] https://downloads.haskell.org/~ghc/6.12.1/docs/html/users_gu... [2] https://www.gnu.org/software/emacs/manual/html_node/elisp/Bo... [3] https://fsharpforfunandprofit.com/posts/cli-types/


While slightly different, the first place I remember hearing the term was Java. It was solving a slightly different problem: primitive types were not objects. You’d have an int, but many data structures require the things you stored to be subclasses of Object. There were a bunch of objects with names like Integer that you could use instead, but in the early days there was a non-trivial performance hit associated with the “boxed” values.


Java isn't mainstream?

Granted, Java has 'references' instead of pointers, but they're close enough that the concept of boxing is basically the same.



I was referring to the term "Boxing", not the concept.

No mainstream language that I am aware of uses the term "Box", while they almost all have something similar in concept, if not identical.


I think Java, Haskell and C# are the main languages where you have both boxed and unboxed values (C++ if you start doing smart pointer stuff I suppose, tho "String" could be considered a very fancy boxed char*).

Python, Ruby, and JavaScript all have exclusively boxed values. "Everything is an object".

I'm not sure what languages you use but that pretty dramatically covers most of the mainstream (top 10 at least).


Boxing is common term in Java and .NET worlds.


The term Boxing is used in Java. (JVM languages really.)


I'm not sure I'd call the article a ripoff, but buckaroo's comes with an implementation: https://github.com/LoopPerfect/valuable




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: