I am eager to start learning coding, specifically in C#, but I have some doubts about transitioning from GH into it.
When working in GH, you have clusters and components that work also like clusters. In coding you have to write and come up with everything everytime? To divide a curve for example, I believe the Gh component makes speheres on every point and the intersection is the division point… but in Gh you just need to type “divide curve”.
How do you visualize the process in coding? And where do you do it? visual studio is the most common IDE, but can it draw a curve like Rhino + Gh?
Sometimes lofts dont work ok because of curve orientation, etc. How you do check for this in code? In GH you could simply visualize the loft and see it was no right.
I think these are the questions that come to mind when trying to transition from Gh into coding. Hopefully someone can give me some insight.
Maybe have a look at the C# Scripting and Plugin Development videos on developer.rhino3d. While it might seem daunting at first, it should provide you with a good introduction to what is involved in C#/GH.
Another good start would be the Rhino.Python.Guides. I personally wouldn’t recommend anyone new to coding to dive into the deep end of the pool with a full blown Visual Studio setup (but to each their own and such), but start with the GHPython component, then the C# Scripting component. Slowly ramp up complexity, without breaking your neck
In my humble opinion, coding is a great tool but lacks of live feedback. Gh gives you visual feedback quite fast. you can combine both and even create your own components tailored to your needs. So I say get in to it it is a great adventure.
One of the factors that make a code a good code is reusability. There’s no point in repeating things. And in gh-code you don’t have to. If you write with scripting components in gh you can save them as userObjects/clusters or using a snippet storage like BrickBox or Metahopper, if you write in Visual Studio you can create your own .dll library to reuse it in other projects. Or simply saving the document with the script with a recognizable name for your future self.
Unfortunately yes, because the GH functionality is encoded within the GH_Component instead of accessible functions out of the shell. Most plugins are also written this way, which is a big slip from my point of view.
What I do, and I suppose that everyone, is first to do the sketch with scripting components in gh, in order to be able to debug it more easily. Personally, this is not a problem for me. There is also an extension that allows you to write in VS and run it in a scripting component automatically, but I rarely use it. In VS you can easily debug to a certain extent, because for certain exceptions it is not necessary to restart, just stop, correct and continue. But it’s still annoying to me. Fortunately, everything from scripting components, except component appearance topics, can be done perfectly.
Remember that coding (programming) is not about the language, but about solving problems. Language like C++, C#, Visual Basic and Python are merely a tool for that. You solve problems with algorithms just like Grasshopper. The way it is done is different, but the concepts are pretty much alike.
Thats good news I think.
What troubles me is that I don’t know the coding equivalent of visualizing your geometry to know whether it is right so far or not, or checking data structures with panels,etc.
As already hinted at you can start by using the C# or Python components in Grasshopper. You can start with typing code for the ‘simpler’ parts, and utilizing the rest of Grasshopper components to handle the visualization.
As you learn more, understand better how things work, you’ll eventually find you also understand how to go about writing visualization code yourself.
I do believe Grasshopper is a form of programming, just as Python and C# and RhinoScript, but I cannot deny that I work in entirely different ways when using GH from writing code in Visual Studio.
When coding, I am primarily occupied with type-design (what functionality and data belong together? what parts of an algorithm are allowed to change over time, what parts are immutable? what inheritance makes the most sense?) and flow-design (conditionals, loops, which data-structures to use, etc.).
Whereas when I work in GH I’m mostly thinking about operations. I guess I mostly try to solve lower-level problems when coding, which means a focus on different aspects.
Grasshopper is certainly nice because it has a lot of immediacy. You can see right away what your algorithm does just by looking at the viewport or at a panel. That sort of code inspection is usually a lot more cumbersome in textual IDEs. On the other hand VS comes with a really good debugger, which is something that is really lacking in GH.