Functions via Python scripts vs Nodbox only Tools

lastvector's Avatar

lastvector

28 May, 2024 12:01 PM

Hi John

You have already mentioned in various posts that you like
to create functions with Nodebox only on-board tools.

The question arose in my mind: why are you trying to do some
things explicitly in Nodebox? Is this performance related?
Does this function work faster?

To what extent do the speeds of a function that works using a node
with a Python script and one that only works with nodebox means differ?

Or are there any other reasons?
gottfried

  1. Support Staff 1 Posted by john on 28 May, 2024 07:21 PM

    john's Avatar

    Gottfried,

    Good question.

    Actually, external modules written in Python or Clojure are typically faster - often much faster - than pure Nodebox code.

    In theory, Nodebox could be very fast for some tasks because it would make it easy for a compiler to divide the computation into multiple threads and do some of the work in parallel. It's also a pure and relatively simple functional language. But it was not written for speed; it was written to maximize interaction and promote play. It's no slouch, and can sort 100,000 strings in the blink of an eye, but by modern standards is relatively slow.

    There is no reason not to use external modules; it can be an interesting challenge and can open up exciting new capabilities for Nodebox. Indeed, that's why I do include about a dozen such modules in my library.

    I have two reasons, however, for preferring to code purely in NodeBox

    • As I mentioned in my other note, I like the challenge. In some ways coding in Nodebox is like doing martial arts blindfolded: no loops, no branches, no recursion, no pixels, etc. Yet, with determination, it's possible to do just about anything. From that point of view, resorting to an external module feels a bit like cheating.
    • External modules are a slight pain to set up and maintain. The best practice is to quit Nodebox, create a folder, move your ndbx file inside, make a copy of the module you need from my library (or roll your own) and transfer that inside the folder, then relaunch Nodebox and add the module to your code library. If you then distribute your project, you should zip the entire folder so that the ndbx file and the module do not become separated. If you fail to do this, the NodeBox file will refuse to open and you have to edit the text file to get it to work. Not a huge deal, but a nuisance.

    Hope that helps.

    John

  2. 2 Posted by lastvector on 28 May, 2024 07:37 PM

    lastvector's Avatar

    John

    Thank you very much for your comprehensive explanation.
    It's definitely helpful to know something about the differences
    between the two ways.

    gottfried

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

24 Jan, 2025 07:50 AM
22 Jan, 2025 11:42 PM
21 Jan, 2025 09:43 AM
21 Jan, 2025 09:41 AM
21 Jan, 2025 09:36 AM

 

21 Jan, 2025 02:00 AM
16 Jan, 2025 08:30 PM
15 Jan, 2025 06:37 AM
04 Jan, 2025 04:09 AM
03 Jan, 2025 05:32 PM
29 Dec, 2024 12:06 PM