Skip to content

add paper draft #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions paper/paper.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@misc{SetfieldPackage,
author = {{Takafumi Arakaki} and {Jan Weidner}},
title = "{Setfield.jl}",
year = {2017},
publisher = {GitHub},
journal = {GitHub repository},
url = {https://github.com/jw3126/Setfield.jl}
}

@misc{JuliaPR21912,
author = {Keno Fischer},
title = "{Heap allocated immutable arrays and compiler support}",
year = {2019}, url = {https://github.com/JuliaLang/julia/pull/21912},
publisher = {GitHub},
journal = {GitHub PR},
}


@misc{MutabilitiesPackage,
author = {Takafumi Arakaki},
title = "{Mutabilities.jl}",
year = {2019},
url = {https://github.com/tkf/Mutabilities.jl},
publisher = {GitHub},
journal = {GitHub repository},
}

@misc{HaskellLens,
author = {{Edward Kmett} and contributers},
title = "{Lens}",
year = {2012},
url = {https://github.com/ekmett/lens},
publisher = {GitHub},
journal = {GitHub repository},
}

@misc{ImmutableJS,
author = {{Lee Bryon} and contributers},
title = "{Immutable-js}",
year = {2014},
url = {https://github.com/immutable-js/immutable-js},
publisher = {GitHub},
journal = {GitHub repository}
}

@article{Julia-2017,
title={Julia: A fresh approach to numerical computing},
author={Bezanson, Jeff and Edelman, Alan and Karpinski, Stefan and Shah, Viral B},
journal={SIAM {R}eview},
volume={59},
number={1},
pages={65--98},
year={2017},
publisher={SIAM},
doi={10.1137/141000671}
}

@article{AlgebrasAndUpdateStrategies,
title = "Algebras and update strategies",
abstract = "The classical (Bancilhon-Spyratos) correspondence between view update translations and views with a constant complement reappears more generally as the correspondence between update strategies and meet complements in the order based setting of S. Hegner. We show that these two theories of database view updatability are linked by the notion of {"}lens{"} which is an algebra for a monad. We generalize lenses from the category of sets to consider them in categories with finite products, in particular the category of ordered sets.",
author = "Michael Johnson and Robert Rosebrugh and Richard Wood",
note = "The following article appeared in Journal of universal computer science, 16(5), 729-748, and can be found at http://dx.doi.org/10.3217/jucs-016-05-0729. Version archived for private and non-commercial use with the permission of the author/s and according to publisher conditions. For further rights please contact the publisher.",
year = "2010",
language = "English",
volume = "16",
pages = "729--748",
journal = "Journal of Universal Computer Science",
issn = "0958-695X",
publisher = "Technische Universitat Graz from Austria",
number = "5",
}
48 changes: 48 additions & 0 deletions paper/paper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: 'Setfield.jl: Changing the immutable'
tags:
- Julia
- Functional Programming
- Optics
authors:
- name: Jan Weidner
orcid: 0000-0002-0980-8239
affiliation: 1
affiliations:
- name: PTW-Dosimetry
index: 1
date: 13 September 2020
bibliography: paper.bib
---

# Summary
We discuss the problem of updating immutable objects. The solutions presented are implemented in the Setfield.jl package [@SetfieldPackage].

# Overview

In the Julia programming language [@Julia-2017], some objects are *mutable* (`Array`, `mutable struct`, `...`), while others are *immutable* (`Tuple`, `struct`, `...`).
Neither is strictly better than the other in every situation. However, *immutability* usually leads to code that is easier to reason about, for both humans and compilers.
And therefore less buggy and more performant programs.
One convenience with mutability is, that it makes updating objects very simple:

`spaceship.captain.name = "Julia"`

The analogous operation in the immutable case is to create a copy of `spaceship`,
with just the captains name changed to "Julia". This operation is sometimtes called functional update.
Just think for a moment, how would you do achieve this?
It is a non trivial problem and there are many approaches. Both in Julia [@JuliaPR21912; @MutabilitiesPackage] and other languages [@HaskellLens; @ImmutableJS].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutabilities.jl is just a wrapper of non-type-changing lens from Setfield.jl. So I don't feel it's adequate for showing as an alternative "approach." It may be useful for briefly discussing it as an alternative interface for lenses, though.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is an interestig perspective. I thought of Mutabilities as

melt(obj) = mutablecopy(obj)
freeze(obj) = immutablecopy(obj)

And to execute an update you would do melt ... update! ... freeze.
I thought of the partial melts/freezes as less important and passing between mutable and immutable as the key idea.
You seem to put much more emphasis on the partial aspect (which I agree is pretty close to lenses) and less emphasis on passing between mutable and immutable.

So really passing between mutable and immutable was the alternative approach I wanted to highlight.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've heard Clojure's Specter took a different(?) approach to lens for mutating immutables but I haven't looked into it yet carefully: http://nathanmarz.com/blog/clojures-missing-piece.html

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I will at take a look!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elm took an alternative approach: don't use nested immutable and make flat struct/record better.

https://elm-lang.org/docs/records (see "extensible records")
https://www.reddit.com/r/elm/comments/6c6f3b/elm_monocle_vs_haskell_lens_why_the_differences/

I think there was a talk by the creator of Elm in youtube briefly discussing this. But I can't find it at the moment.

Copy link
Collaborator

@tkf tkf Sep 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I can write a paragraph about this (so that I'd be more comfortable to put me as an author 😄) but I don't have enough time right now. Is there a deadline for the paper?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU the deadline is somewhere mid october:

Hello everyone,
We hope you had a fantastic JuliaCon 2020! We always enjoy learning about the breadth and drive of the community, as well as meeting old and new friends.
Last year we decided to have conference proceedings for the first time and we are happy and proud to announce that the first set of articles has been published! We are still working on the last few and they will be published on a rolling basis.
We would like to thank all the authors (for writing fantastic articles and for their patience), the reviewers (for their valuable contributions), and the Open Journals (especially Arfon Smith) for their infrastructure and technical support.
So what is next? Every speaker of this JuliaCon edition has the opportunity to write up an article corresponding to their talk and submit it to the JuliaCon proceedings. We accept extended abstracts (1 page without citations ) and full-sized papers (8 pages).
The important dates:
September 30th: article submission of at https://proceedings.juliacon.org Mid-october: Paper must be finalized & compilable. Authors should suggest a set of reviewers. October-June: Review period Published date: July 2021
We are still working on the website with all the details and information about the process.
If you are interested in volunteering as an Editor or Reviewer please contact one of us!
Kind regards,
Mathieu, Valentin & Ranjan JuliaCon proceedings editors

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice! Not being able to use the same names for fields of distinct types, was always very awkward in haskell.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw I took a look at Specter. I like it. I think it is close to traversals in "traditional" optics. Just uses different language. JuliaObjects/Accessors.jl#6 is somewhat inspired by it.

Copy link
Owner Author

@jw3126 jw3126 Sep 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkf FYI I plan to submit the draft tonight (tomorrow in my time zone). I would still like very much to have you listed as a coauthor. If you don't have time to add to the paper text, that's not a concern I think. What counts is your contributions to the project and it feels somewhat strange to me to not have you listed.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just submitted the paper.


The `Setfield.jl` package provides one solution to this problem. Namely it allows the user
to specify a functional update using the same syntax as in a mutable setting. The only syntactic difference is the `@set` macro in front:

`@set spaceship.captain.name = "Julia"`

And voila, this returns an updated copy. The implementation is based on the lens formalism,
see the documentation of the package. For an entry point to the lens literature see the introduction of [@AlgebrasAndUpdateStrategies].

# Acknowledgements

We acknowledge various small contributions in form of issues and pull requests, by various
authors. Details can be extracted from the github repository of the package.

# References