Lenses in Julia

samuel2 | 120 points

Nice to see this passed around on Hacker News. I think the whole concept of lenses is super cool and useful, but suffered from the usual Haskellificiation problems of being presented in an unnecessarily convoluted way.

I think Accessors.jl has a quite nice and usable implementation of lenses, it's something I use a lot even in code where I'm working with a lot of mutable data because it's nice to localize and have exact control over what gets mutated and when (and I often find myself storing some pretty complex immutable data in more 'simple' mutable containers)

eigenspace | 15 hours ago

Certain aspects of this me of the modf macro for Common Lisp:

https://github.com/smithzvk/modf

You use place syntax like what is used with incf or setf, denoting part of some complex object. But the modification is made to the corresponding part of a copy of the object, and the entire new object is returned.

kazinator | 13 hours ago

Was hoping this was data lenses, like cambria from ink&switch

https://www.inkandswitch.com/cambria/

Not sure how "A Lens allows to access or replace deeply nested parts of complicated objects." is any different from writing a function to do the same?

Julia curious, very little experience

verdverm | 13 hours ago

I have to admit I don’t really understand the point of doing this instead of just obj.a = 2 or whatever.

binary132 | 12 hours ago

Guys, What's you're opinion on Julia?

I am thinking of using it for data science work.

Any draw backs? or advantages I should know about?

max_ | 7 hours ago

Is Julia a general purpose programming language? I mean I did check the web site which contains a "General Purpose" section, yet the articles seem to center around "scientific applications".

jhoechtl | 4 hours ago

Is this like setf in lisp?

Quitschquat | 11 hours ago