Notifications
Clear all

[Closed] C++ vs maxScript

Do any of you other scripters program in C++ at all?

I’m just wondering why maxScript doesn’t opt for a more C++ish notation/syntax/whatever, because some things drive me nuts…

ie. the if statement
C++ Code:


if (!whatever && thing || otherThing)
{
   blah...;
}

mxs Code:


if not whatever and thing or otherthing then
(
   blah...
)

And the advantage of the c++ if is that anything that is non-zero is true and everything that is zero is false which helps.

ie.


whatever = 1
thing = 0

C++ code:


if (whatever && !thing)
{
	blah...;
}

mxs code:


if (whatever >= 1 and thing != 0) then
(
	blah...
)

There are other things though for example: ignoring white space (I for one won’t mind putting colons at the end of my lines if it means I can break larger expressions into shorter lines), tidier for loops (no more for (whatever) do’s), better casting of variables, the list goes on…

It wouldn’t really require a lot of effort on discreet’s part (HINT, HINT) to make some modifications to their exisiting parsers and lexicon analysers to get some of this going, while still keeping the old methods for the sake of backwards compatibility. They could also add more functionality in terms of object oriented programing, ie. adding member functions to custom structures (or do they already have this?!?), operator overloading, inheritance, etc. But I do concede that this is quite a big task.

Oh yes, I am also hoping that some new version/service pack/plugin/random emp shockwave/whatever, updates the maxScript environment. Some features like automatic indentation, better search and replace functionality, book marks, customizing of environment/colours, tabbed code pages (rather than having 10 scripts in their own dialogs floating around), proper auto-colouring (I’m getting tired of hitting CTRL-D everytime I paste code) and a better Visual maxScript editor, it keeps on rewriting my code as it sees fit, sometimes killing some of my functions or reordering my code which is quite an embuggerance.

Anyway, I was just in the mood to rant a bit. Does anybody else have any opinions on the matter?

6 Replies
1 Reply
(@bobo)
Joined: 2 years ago

Posts: 0

The reason is most probably usability. MAXScript was not originally developed to be used by C++ programmers (as everybody that knew C++ was already writing plugins with the SDK when MAXScript was developed), it was developed to let ARTISTS (like me!) tell Max what to do. (Yes, guys, when I started scripting, I was officially an artist and not a programmer).

The syntax is very relaxed and very Basic-like, so any idiot (including myself) can understand what the code means (provided a bit of English knowledge ;))

MEL has most of the C++ syntax rules you mentioned (symbolic logical operations, Boolean values as 1 and 0, COMPULSORY semicolons at the end of each line etc.) and compared to MAXScript, I personally think it sort of sucks syntax-wise. (Not commenting on the depth of access to the host application, that is another story).

Some things about MAXScript that are cool:
*Other than Python, you don’t even have to format a certain way for the parser to understand you.
*You can format your code with \ on as many lines as you wish and use ; or not if you want.
*Variables need no type declarations providing ultimate freedom (but also letting you do stupid things).
*Arrays can contain MIXED elements of any class, including other arrays.
*UIs are created so quickly that I can write 50 while a C++ programmer is creating one Plugin UI Resource.

If discreet would touch MAXScript’s syntax, they would kill compatibility with thousands of scripts (couple of hundreds by yours truly), and render half of the Max UI unusable. IMHO, this will never happen.

Live with what you have, or use the SDK…

I have programmed quite a bit in c++. For my PolySpeed plugin I do most of the programming in maxScript.
I think maxScript is very nice for quickly whipping up programs. The environment is the biggest problem. Make sure you haven’t missed some of the features like, ctrl right click and ctrl r, they really do help.

Myself I miss more functions for the environment and I have been posting to discreet several times.

Some things:

  • Stepping! and break. That would be enormously good, it’s very hard to find bugs now.
  • More simple things like right click and Comment.
  • Better error reports.

and hm lots more
/Andreas

I think the syntax is pretty good. Perhaps they should add some checking for the type of the variables. I mean, ARRGG, the amounts of bug you can introduce by switching variable type.
so perhaps if you could write. “Consistent variable types” and it won’t let you switch types on the fly.

It would also be very nice if you could check the type of variables for incomming functions. so that if you want an integer and the user inputs an object hell won’t break loose. These checks you can do yourself of course, but that is somewhat painful.

The biggest problem is the environment. It isn’t bad, but it sure isn’t good either. Thank good for the ctrl+right click.

I would like to point out that maxScript is very impressive language, and worth mentioning is that the help is the BEST. compared to almost any language.
I spoke with rivenDale about other programming languages. If you program in Visual C++/Basic you almost have no help. The help is often pure gibberish. If you search for something as simple as “print” you will surely find some assembler codes for printing 2bit data adresses to the primary memory etc. This works perfectly in maxScript. The help gives you pretty good examples of most of the things so you rarely have to bang your head against the wall to do simple things.
The help still needs work bobo More mini examples of the syntax. For example the meshOps and vertex paint have little help.

I also think it’s a great strength of maxScript that it’s not so hard to do your own maxScript functions in C++. Sure not super easy the first time but once you know how to do it it’s easy. So if you have time critical functions, then write them in c++ and connect to your script.

The UI in maxScript is ok, but not amazing. It doesn’t seem really finished in my opinion, many of the ui elements lack pretty basic functions that make them annoying to work with. Hopefully more will be added. Examples, more events, keyup on spinners for example. more on mouse move, on right button click etc, even for rollout floaters.

The thing that I have the most problems with in maxScript, and can be very serious problems is that you do not have full control of what the user is doing. Is he moving a vertex, extruding, is it wire frame in the viewport, is it full screen, is the mouse over an object etc, what keyboard buttons are pressed, what about the forth mouse button etc. All these things don’t work good at all and they often give me headaces when programming.
Many things are also impossible to do because of this. This is slowly getting better, but not as fast as I would have hoped.

/Andreas

1 Reply
(@bobo)
Joined: 2 years ago

Posts: 0

Hey, somebody noticed!
I have used the MEL Reference, looked into the LScript Help, and had to learn DFScript in less than a day (it had the worst documentation, with a bug in every example) so I know what you are talking about…

The help still needs work bobo More mini examples of the syntax. For example the meshOps and vertex paint have little help.

Preaching to the choir?
Of course it needs work! I hit problems every day, and always try to fix them.
Writing meaningful mini-examples is not as easy as it seems though. One of the reasons for answering so many questions on this forum is that I need ideas for simple things – I am collecting my answers and using them as inspirtation either for the Help, or for the upcoming CG-Academy DVD…

Here are some examples of mini syntax. Normally I think only one line is needed.

polyOp.moveVert $ #{1…7} [0,0,1]

One thing that often has pretty complex syntas definition that I often had to test a while before it is working is the attach

syntax
[left]meshop.attach {<target_editable_mesh_node> | <target_mesh>}
[/left]
[left]{<source_node> | <source_mesh>} \
[/left]
[left]targetNode:<node=unsupplied>
[/left]
[left]sourceNode:<node=unsupplied>
[/left]
[left]attachMat:<{#neither | #MatToID | #IDToMat}=#neither>
[/left]
[left]condenseMat:<boolean=true> \
[/left]
[left][left]deleteSourceNode:<boolean=true>[/left][/left]

meshOp.attach $originalobject $theobjectToAttach

The syntax definition above always make my head hurt, but with a line as the one above It makes perfect sense to me.
When I learned maxScript I often had to spend quite some time testing the syntax before I could figure out how to do things like attach, detach etc and I think I’m not the only one.

/Andreas

Don’t get me wrong, I do enjoy maxScript, in fact I started in maxScript then went to C++, I just feel that it could be better. I must say, however, that the lack of type checking has hindered more than helped me in the past.

My biggest gripes at the moment are:the if statements (or more precisely the logical operators, and, or, not instead of &&, ||, !) and the for loop statement, even though it is powerful as it is, it could be a bit neater. I do, however, like the way you can traverse arrays though.