msg vs int/float

Jun 13, 2012 at 11:46pm

msg vs int/float

To briefly (I promise! :)) go back to my complaints about strict typing

Is there an advantage to be had by using int/float vs msg? Their function (as a local variable) is mechanically and structurally identical – you plugs your value in the right inlet and your bang in the left, and your msg with an $variable into the outlet. Surely if static typing exists for any reason other than reverse compatibility int/float would provide nontrivial performance gains?

Many thanks in advance

Jun 14, 2012 at 5:23am


if you mean using [int] vs [message] like in patch below ; a quick benchmark show you that the first is better ; it seems not a good idea to use UI object in this case when a simple non-UI object do the job very well. The problem is not type cast (as both will be considered “int” by another object) but UI painting.

[message] have a lots of great usages to format complex things and semi-colon trick … For me patch readability is the most important ; with time i learn that benchmark should be done only in real work situation with a good profiler … and not like i do below ;-)

– Pasted Max Patch, click to expand. –
Jun 14, 2012 at 4:14pm

the biggest problem is converting types, so always use that what you will need on the other end.

Jun 16, 2012 at 7:02pm

nicolas; re my original question, ty, I have no idea how I missed the display part of msg (insufficient sleep :)).

re profiling, its still a cool trick.

A) why is it useless for real work?

B)which code profiler do you recommend?

Thanks again


Jun 17, 2012 at 6:12am


A. … not useless but should be done in real situation to hunt concurrency and bottlenecks.
B. … i’m used with Shark ; but i can not recommend it as i don’t know others ;-)

Those opinions mainly comes from programming experience more than pure maxMSP patching : my 2 cents.

Jun 17, 2012 at 7:27am

One of the biggest wins for fixed types is that you know how big they are. A message have (fairly) arbitrary lengths, and have to be parsed.

This is a simple test to illustrate some of the cost:

– Pasted Max Patch, click to expand. –
Jun 17, 2012 at 4:33pm

chris, another excellent point. See, I can be reasonable if you give me an argument :).


You must be logged in to reply to this topic.