algorithmic modeling for Rhino
I have finally made up my mind to really learn one of the scripting languages that go with GH. I think the first question, as many people have probably asked themselves before, is which language to learn? To me this question is between C# and Python. I searched the forum and surprisingly didn't find a topic on it (seems people have made up their mind one way or the other). I did a search on the web and it seems there is a tendency toward Python, for it's a simpler and cleaner language. But that only applies to general program, not specific to Grasshopper.
So what's the people's feeling on this forum? Python or C#? I have had experience with Java back in college.
Tags:
"You will have a 10 times faster Execution of your Programm."
Hmm, what exactly are you basing this claim on? Also, it's called Python..
Ok you want to know why... it quite simple IronPython has an interpreter which is on top of the IL which also gets interpeted to machine code . It generates IL every time it executes and does not make a inmemory net Assembly. I think what the Python plugin in Grasshopper does a inmemory assembly with reflection. But still if you are dynamic it will generates extra IL code, which is bad, because a bigger book takes always longer to read. 10 times longer is based on a discussion with some guys of a geomerty division in an architecture firm , who did a triangulation experiment with C# in comparison with IronPhyton. Hope this helps.
There is certainly no question that Python will be slower (being dynamic and interpreted and what not). Ten times over just sounds like quite a lot, it would be interesting to see why that might be. Do you know if they were using the RhinoScriptSyntax library? I've found that to bog down the runtime quite significantly as compared to just using straight up RhinoCommon. Thanks for the clarification.
I looked into Steve Bears code... so the Grasshopper component seems to have a inmemory assembly .... it checks if the old code is the same like the new one and if it is it uses direct IL. The 10 times regards to IronPhyton not to the Grasshopper Plugin. I think the problem with RhinoScriptSyntax is that it is used with Rhino Gui itself as place to store and grap your Geometry. This is a Problem most CAD Systems have (like constrained systems like solidworks PRO/E which is hell for programming). The decoupering of the geometry calculation is much better with Rhinocommon, so the performance and usability is much better. This is a big plus in comparison to other cad packages. But i am not shure of this. If you have to find a object within 10 objects in your personal list with no extra data its faster, than to find it in 1000 of objects in your GUI
if (_compiled_py == null ||
string.Compare(script, _previousRunCode, StringComparison.InvariantCulture) != 0)
{
if (!(_inDocStringsMode = DocStringUtils.FindApplyDocString(script, this)))
ResetAllDescriptions();
_compiled_py = _py.Compile(script);
_previousRunCode = script;
}
}
if (_compiled_py != null)
{
_compiled_py.Execute(_py);
// Python script completed, attempt to set all of the
// output paramerers
for (int i = HideCodeOutput ? 0 : 1; i < Params.Output.Count; i++)
{
string varname = Params.Output[i].NickName;
object o = _py.GetVariable(varname);
_marshal.SetOutput(o, DA, i);
}
}
else
{
m_py_output.Write("There was a permanent error parsing this script. Please report to steve@mcneel.com.");
}
That's really interesting, thanks for the update. I might do a bit of benchmarking myself and see what I come up with (perhaps even try to implement NumPy as suggested by Giulio here). Regarding RhinoScriptSyntax being slower I did run a few test a while back (like this one) and came to the same conclusion as you. Anyhow, didn't mean to derail the thread. As you were :)
Obviously it has a lot to do with your personal interests, and the types of projects you would like to create with your new programming skills. They're both useful.
For people who want to script in Rhino & Grasshopper, I would say Python is great for quick solutions and sketching with powerful data structures in Grasshopper, but if I were going to make a windows application or write a durable, high-performance plugin for Rhino, I would use C#. Typically Python meets all of my needs. I almost always use RhinoCommon, not rhinoscriptsyntax, and this is usually plenty fast for me.
Python has introduced me to a much broader world of programming. I've been spending more time exploring web applications and interactive mapping libraries than scripting 3D programs. It's fun and easy to get help.
Python projects are often open-source, web-based, and/or cross-platform. Python has a larger user base on mac and unix-based platforms.
C# projects are often proprietary, windows-based applications. There's very few non-windows C# projects.
Check out this breakdown of open-source code repositories on Github, the order is Javascript (a very useful language for designers!), then Ruby (also great for web programming), then Python (which is almost tied with Java).
I think C# is great but I don't know it very well. It looks like the best choice for writing native Windows applications and plugins. I'm not very interested in writing native Windows applications.
I use python frequently, and I love it. Here are some reasons to learn python:
For more deep reading, check out these questions and answers comparing C# and Python:
Good luck on your programming adventures! Enjoy!
Great list of resources there, thanks Benjamin..
+ now you know why it's hard to find answers on this question. Opinions are strongly held, and solid information is scarce on the ground.
I wanna thank everybody who has given his opinion and it's nice to know where people's love and passion lie. Based on all the answers, it seems for me, an architect (and not a programmer), Python is the automatic shift that's easier and faster to start with, and C# is the stick shift that I'll appreciate in the long run. So I guess I'll start with Python and it will never be too hard to pick another language later on. And this is gonna to happen after I finish my architecture registration exams.... Ahh.......uh!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by