C# learning doubt

unhandled

(Pmora1990) #21

Why is that?


#22

nobody for C++ ? Rhino for both Windows and Mac are mostly written in C++

here i wonder why the Mac version does not support C++ plugins then, but i am probably not deep enough into the rabbit hole to understand that yet.


(Nikolay Bakalov) #23

Writing C++ requires some C concepts. Especially in plugin development. Shared libraries are using C export interface as well. Rhino plugins are basically .dll files with a .rhp extension.


#24

The poster is new to programming and wants to code for Unity/Grasshopper (where C# is the defacto language, though you can use any .NET language), and you guys are discussing why not C/C++. Very helpful. Why not assembly while you’re at it?


#25

yes curious thoughts.

the OP’s initial topic was handled, i dont think that he minds when this discussion goes from here where ever it may go. if one has the admin power to split this thread then pls go ahead.


(Tom) #26

My opinion:

There is a huge difference between “scripting” and “programming”!

I you want to script, learn a language like Python, or even C# will do it for that purpose.
C# might work a little better for the Rhino Environment, since the api is C++/C# as well.
Usually I would prefer Python or any other interpreted language for that kind of coding.

If you want to programm, its not wrong to learn C. Its hard, but its the mother of many languages and as such its great to get a deeper understanding on programming. However most developers today practice “object-oriented-programming” (a bit too much in my opinion) . But for higher abstraction, patterns, SOLID and all these other buzzwords, knowing C won’t help you much.

In addition to that, there is a strong difference between knowing the syntax, its principles and being able to create a complex application with it. Its a matter of years, if not decades.


#27

Perhaps dynamic and compiled programming would be better adjectives to use here (what counts as “scripting” and what counts as “programming” has never been never been a productive discussion IMO).

I already do, thank you very much. And I also personally prefer GHPython for dynamic stuff and C# for compiled stuff. That is, within the Rhino/Grasshopper environment, and imagine I’d feel the same in Unity. Veering away from whatever language the API you’re targeting (i.e. RhinoCommon and the Grasshopper API) is designed for is just silly IMO.


(Tom) #28

Sorry this reply was rather general, I hit the wrong button. I know that you know programming, of course. No offense :slight_smile: And yes, obviously it makes most sense to use the language the api was designed for. Although, when looking at COM libraries, quite often I did use another language…

Well the difference between scripting and programming is hard to distinguish, yes! C# scripting is basically also compiled. I would rather make a cut if you rely on a high percentage on prewritten higher functionality. Most script-components, even many gh plugins are just using Rhinocommon functionality. Its difficult to make a cut, but programming begins for me when your programm gets so big, that you need to care about its architecture, unit testing and all this complicated stuff. Alternatively smaller applications are not scripted if it hardly relies on 3rd party code. That would be my definition.


#29

I think we’re very much in the same boat here, and that I need more coffee :wink:


(David Rutten) #30

Is there? What is it?


(Tom) #31

Besides to what I already said, in my definition scripting is putting big chunks of existing content together to create something new. Programming (maybe the term is not well chosen) is rather about creating new content to create something new.
To give you an allegory. If you create a song, scripting would be using the melody of song a and b, and taking the voice of song c, and maybe you put in some own sounds. But the amount of 3rd party content is quite high.
In comparison to that, when writing an own melody, writing an own text and creating own sounds would be the equivalent of “programming”.

Both ways are solving a problem, in this case they create a new song. Usually you cannot always clearly differentiate between both. But there is different weighting on how its done.

Its not judgmental. I don’t think scripting is inferior to programming. But you have to admit that programming might have a much deeper complexity and requires much more knowledge of fundamental nature.


#32

But surely scripting is a subset of programming then (that is high level, dynamic, and probably written/executed within a host environment/software). Anywho, as I said, this is probably not too productive, I’ll go :coffee:


(Tom) #33

yep, time gets wasted again :stuck_out_tongue: … I know…


#34

Well, that’s hard to differentiate. In a way anything above base machine code relies (heavily) on premade libraries. Even a C Hello-World uses stdio.h to actually print the words. The music allegory is similar. Do you require to play your own instrument for the “programming” equivalent, or do you need to actually have build the instrument yourself to truly create something new instead of just reusing stuff others created?

Obviously there’s a difference in commitment, complexity and probably understanding between using the 3 unused bits in your integer data stream to encode another parameter and throwing out a XAML UI in visual studio. Still both is programming and both are ways to create something new.

You could define the difference between programing an scripting in a way that reduces scripting to automating as relatively simple task using premade blocks. But even by that definition a simple C program might be considered a script and a complex GH definition is programming…


(David Rutten) #35

Fair enough, if that is your definition. It does mean though that scripting is defined by what you do with a language, rather than what language you use to do it. Perhaps that is a more meaningful approach than the established one which has been losing validity for decades.

Either way you cannot draw sharp boundaries between programming and scripting, but then that’s true for most things in life. We humans love to categorise and we so often forget that in the end they’re all made up.


(Graham) #36

So you’re saying we humans are statically typed and we frequently raise a TypeError when parsing someone else’s type system? I think I agree :smiley: :


#37

With C# and an integrated development environment (visual studio) you’ll get the whole nine yards of Rhino. There are no limitations like with scripting; you can create custom objects, store any user data to objects and documents (not just text), you’ll get proper IntelliSense not just for SDK methods also for your custom code, you can save program parameters, you can organize code more efficient, it is faster and so on…

If you want to do serious development then I’d recommend C#.
Scripting you’ll pick up on the fly for the quick and dirty stuff :wink:


#38

I often think of development work as

  1. Architect - Designer (software architecture)
  2. Construction Worker - Programmer
  3. Caretaker - Scripting

And just like a caretaker often can do also construction work, scripting can also end up being a complex project and not only quick fixes and gluing code here and there.

Although it’s not easy to tell the difference between scripting and programming, I think plain coding (programmer) and system design (architecture) is quite different.

// Rolf


#39

-> following a path of a predefined amount of possibilities given by the one who created the language is not programming, it is “merely” following others foot steps.


#40

At this moment I just want to script in C# component in grasshopper totally noob here