Group Abstract Group Abstract

Message Boards Message Boards

Objects: object-oriented programming (OOP) in Wolfram Language

Posted 1 year ago

enter image description here

Attachments:
POSTED BY: Kirill Belov
6 Replies

Kirill, thx for posting this and for such detailed descriptions.

Not to detract from your own approach, and it's probably too late for your own work now you have your own recipe for objects, but if you aren't familiar with it already, you might find it interesting to at least see what MTools does: MTools, Object Oriented Programming in Mathematica by Faysal Aberkane

If anyone else lands here, please note I'm not advocating for use of MTools over Kirill's Objects.

POSTED BY: Darren Kelly
Posted 10 months ago

Thank you so much for the appreciation of my labors! I have read the article you recommended. A lot of things are done there that I would have done myself. Initially I made a very cumbersome code for Objects, where there were a lot of checks. Plus I redefined a lot of things. For example, I also overridden the Dot function, and I also made it so that using SyntaxInformaton, information for autocompletion is added to objects on the fly. But it turned out to be complicated and slow. In the end, I removed all the unnecessary stuff to avoid scaring Mathematica users with things that don't fit the syntax of the language, and tried to keep the objects as simple as possible - they're essentially typed variable associations. It's also like the OOP format from JavaScript. But it's more important than anything else. Our mini-team (me and Kirill Vasin) started to actively use the Objects package in our work and we encountered performance problems. A lot of conditions and checks slow down atomic operations like getting and changing the value of an object field. As a result, now we managed to achieve something more or less useful from the design point of view and almost as productive as built-in lists or associations.

POSTED BY: Kirill Belov
Posted 1 year ago

Is there a way to have destructor methods implemented? I tend to re-run my notebooks frequently, and I'm worried about memory leaking. ClearAll["Global*"]; doesn't seem sufficient.

POSTED BY: Updating Name

This is amazingly useful stuff, and should be more widely known. Thank you for having implemented this!

POSTED BY: Zsombor Méder
POSTED BY: Darren Kelly
POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard