PDA

View Full Version : NewTek: help us learn how the Python<>Lightwave interface works



jeric_synergy
09-17-2012, 11:29 PM
Ok, here's a low-energy way for NewTek to help us learn write scripts, thereby helping them sell their product:

Take the existing scripts, and comment the frack out of them. Explain every damn line.

The scripts already exist, so that's not a problem. And if they're easy to understand, ADDING COMMENTS SHOULD BE EASY TOO. :devil:

skarloc
09-18-2012, 12:31 PM
The pcore.py could use some more info - I have to resort to the C #include files to work out what parameters I need...

jeric_synergy
09-18-2012, 01:12 PM
The pcore.py could use some more info - I have to resort to the C #include files to work out what parameters I need...
There ya go: I'd be screwed since I don't speak C.

Seriously, Bob Hood, COMMENTING. Sheesh.

BigHache
09-19-2012, 05:22 PM
There ya go: I'd be screwed since I don't speak C.

To a certain extent you'll need to because Python is based on C, and the Lightwave implementation of Python is built on top of C so there's some overlap.

I've been able to make headway with creating learning resources for Python and right now I'd rather NT spend the resources completing the implementation of Python rather than writing docs for it. Session 4 of my intro series is online and I'd love to get some feedback on it.

jeric_synergy
09-20-2012, 02:28 AM
The only dox I want are lightwave specific: certainly there's no need for generalized Python dox-- that's one of the reasons for the implementation.

I also get the impression that some LW/3D specific libraries would substantially reduce the (apparent) verbosity of Python plugins.

But the sparseness of commenting in scripts in general has been lamentable for, well, decades IMO.

UnCommonGrafx
09-20-2012, 04:42 AM
I think your view is quite limiting as to what will be available into the future with the power of python.
Not understanding the general of Python, and its ability to be an oo languange with all the dexterity of c, and thus to the core of lw, would just be a bad foundation upon which to build.

For anyone that wants to learn python, http://www.codecademy.com/tracks/python, is the place to go.

Celshader's latest python snippet upload illustrates, even the trivial has more lines than one would think. That is to say, in comparison to the lscript she offers as comparison.

inkpen3d
09-20-2012, 06:27 AM
Programmers who don't adequately comment code are lazy and unprofessional.

I spent 25+ years as a professional software engineer and there's many, many times I've wanted to throttle the people who hadn't commented code that they'd written and which I've had the misfortune to modify or bug-fix. I always try to comment to the hilt any code that I'm writing, but even so, there's times when I've returned to my old code and found that either a crucial comment has been missed out or is a bit cryptic - time to slap own wrists!

Even when you know a programming language inside out, if someone's not explained in comments what the code is attempting to do, you can waste an awful lot of time just trying to get your head around it. I've found that the worst culprits are those people who consider themselves to be "coding gurus", but in fact don't know the first principles of professional software engineering (e.g. provide clear s/w designs and clearly commented modular code). Their arrogant attitude is one of - well the code I've written is so "simple" a monkey could understand what's going on, so why bother wasting my time commenting for the other plebs what's so blatantly obvious to me!

As you can probably tell, poorly commented code (and lack of good design documentation) really gets my blood boiling!

jeric_synergy
09-20-2012, 09:18 AM
Not understanding the general of Python, and its ability to be an oo languange with all the dexterity of c, and thus to the core of lw, would just be a bad foundation upon which to build.
Sure, but the market has PLENTY of generalized Python info (I'm reading "Python Essential Reference (http://www.amazon.com/Python-Essential-Reference-4th-Edition/dp/0672329786/ref=sr_1_1?ie=UTF8&qid=1348150264&sr=8-1&keywords=python+essentials)", for example). What NewTek must do is make easily findable and accessible is the unique plumbing that LightWave has installed to use Python.

For instance, someone (I think connected w/NewTek), mentioned a semi-laborious procedure to get some low level commands dox out of Python/the sdk/the api/whateverthehell. Foolish-- NEWTEK should do that and put it in the distro or someplace findable. (It's the kind of thing you only need to do once.)

And for non-C programs, spelunking inside various technical files (that are NOT dox) to wrest information out is not a walk in the park.

Every script written for LightWave makes it more valuable, more attractive, more sellable. It's in NewTek's own best intere$t$ to facilitate script-writing.

And adding comments to scripts ALREADY WRITTEN is some pretty damn low-hanging fruit. The included scripts are supposed to be educational material for LightWave customers-- they should be over-commented if anything.

+++

I spent 25+ years as a professional software engineer and there's many, many times I've wanted to throttle the people who hadn't commented code that they'd written and which I've had the misfortune to modify or bug-fix. I always try to comment to the hilt any code that I'm writing, but even so, there's times when I've returned to my old code and found that either a crucial comment has been missed out or is a bit cryptic - time to slap own wrists!

Even when you know a programming language inside out, if someone's not explained in comments what the code is attempting to do, you can waste an awful lot of time just trying to get your head around it. I've found that the worst culprits are those people who consider themselves to be "coding gurus", but in fact don't know the first principles of professional software engineering (e.g. provide clear s/w designs and clearly commented modular code). Their arrogant attitude is one of - well the code I've written is so "simple" a monkey could understand what's going on, so why bother wasting my time commenting for the other plebs what's so blatantly obvious to me!

As you can probably tell, poorly commented code (and lack of good design documentation) really gets my blood boiling!
Sing it, brother!

It's the wasted time aspect that p!sses me off: if someone had taken literally five damn seconds to add a short comment, I could avoid some cryptic puzzle that took 30 minutes to solve.

BeeVee
09-20-2012, 02:07 PM
I spoke to the engineer responsible for the Python integration in LightWave and LScript, Bob Hood. He had this to say:

"The integration of Python into LightWave was designed as two phases. The first phase, which you have in your hands right now, directly wraps the LightWave plug-in API. It is not like LScript, which takes great pains to completely hide that API. The advantage to the approach taken in integrating Python (over that of LScript) is that the process is almost completely automated. The PCore system actually parses the SDK headers, and automatically generates integration code that binds Python to LightWave. This means that additions to the SDK can be exposed to Python MUCH faster and with a lot LESS human intervention than what is required by LScript.

The second phase, which has yet to begin, is intended to begin adding elements, written in Python, that will simplify the raw exposure to the plug-in API (more akin to how LScript works). When this phase is complete, the Python integration will offer two tiers of access: one low-level (what you have today), and one high-level (more like LScript), and the script writer can decide which to use, or even mix them both in the same script.

However, there are only so many hours in a day, and only so many things that can be done in a given development cycle. Phase 2 is still on the road map, but it has not yet begun. So, if it is LScript-like features you are needing, and you simply don't have the time or inclination to learn LightWave's plug-in API, then you can certainly continue to use LScript until LightWave Python matures to a point that suits you."

Bob has written an excellent converter for LScript to Python (http://www.lucidgears.com:21134/) as well. LScripts translated this way almost always need cleaning up unless they are the simplest of scripts, but it will enable the user to be able to make that leap from language to another.

B