Learning C# or Python for Grasshopper?

Hello all, hope you are well.

I am a Grasshopper user for almost 3 years now and I want to start learning either C# or Python for Grasshopper3D and have a few questions regarding the same.

  1. Which coding language is better to learn C# or Python? I have got a mixed reaction from people, in the sense that Python is easier is to learn, where as C# is more future proof and is used by other software’s as well. I will be mostly using coding for Architectural Design, Generative Art, Parametric Explorations and making work flow faster.
  2. Since I am a beginner, from where do I learn either of these coding languages? Or what could be the best place to start learning, any tutorials, books or videos?
  3. This might be irrelevant, but how much does it take to learn any of the languages. I am asking this because I learnt basics of RhinoPython and now I remember nothing.

Any guidance will be really helpful.

Thank you.

1 Like

Python is easier to learn but C# is better for Grasshopper

There’s a lot of topics on this subject already. Try doing a search (on the old forum as well).

Anywho, here’s a recent post that might help clarify a few things:

5 Likes

If you are in the AEC (notably BIM) field … C# by a huge margin.

books (with computer off).

In years: 1 (know how to do some stuff) to 10 (know what not to do).

Eat carrots.

6 Likes

:point_up_2:


As for your points:

1- your “Which coding language is better to…” question is already the perfect bait for forum wars XD.
So, imho c#. Imho python is unreadable while c# is clean, but searching in the web people say the exact opposite!
C# is generally faster than python and also grasshopper is written with it, so you can access grasshopper and its structure/methods more smoothly with c#. Also if you want to convert your c# scripts into plugins, the step is probably simpler than coming from py.
Just statistically, the cooler scripts i’ve seen on this forum were made with c#. Whatever this means.
Python is more cross-platform than c#, so learning it would give you that advantage…

2- opposite to what Peter said, i never opened a book or seen a video, just reading other people code and reverse engineering it. Often on this forum you get scripts from other users (like Peter) and learn from them! But it’s again a personal situation. I’ve never opened a book for school, still having very high scores on math and stuff (and a constant 0 on literature :sweat_smile: ). You know yourself better.

3- Is this your first time learning a typed programming language?
A person that knows Rhino and Java would program in c# inside GH in half an hour, for example.
Or, if you used python for other cases you would go faster implementing it in GH, but that is not your case.

4 Likes

Talking about Grasshopper, just learn C#.
In grasshopper you will use the RhinoCommon library which is written in C#, even if using Python.
So you will have to learn a little C# anyway (and to ‘bend’ your Python scripts a little for this)

But …

I don’t agree. (C# may be confused with C or C++, but they are different things)
C# is a Microsoft language, mostly used on Windows.
As Riccardo said, Python is a cross-platform language, used everywhere.
And it is often used as a scripting language, e.g. Blender, FreeCAD.
Python is also used for Rhino scripts, while you cannot use C# for that (C# scripts might be coming with Rhino 8). But C# is better to write Rhino plug-ins.

I think that for simple, short Grasshopper scripts, there should be no big difference between Python and C#.
But for larger, more complex scripts, you would appreciate C#'s advantages.

So, to recap, I’d say C# if you are interested in Grasshopper scripting (only), and in pretty complex scripts particularly.
Python to be able to use it to script other softwares too (classic Rhino included) or for completely different things, on any platform.

BTW Personal preference / taste is also important.
You might find one language easier to learn than the other … but I think you’d have to learn both to find out which one you like most :wink:

About points 2 and 3, IMO it’s very personal. Anyone has his/her own preferred way of learning.
I think that you’ll have to find out what works best for you … sorry.
Anyway feel free to ask here for help while learning to script. :slight_smile:

6 Likes

Thank you for the reply Seghier. I will look into C# since it is better for Grasshopper. Any recommendations on online courses or youtube videos or any other study material?

Thank you again :slight_smile:

Thank you for the reply Andres, will definitely take a look at the older post on this topic and also the post shared by you.

Thank you again.

Thanks for the reply Pfotiad0,

Yes, I am in architecture and construction industry, looks like C# it is.
Are there any books that you recommend? I am a complete newbie in C#.
Wow that’s a huge time span but 1 year sounds good and will definitely start eating lots of carrots :grinning_face_with_smiling_eyes:

Thank you again for the reply.

Thank you for the reply Riccardo.

  1. Lol, I hope there are no wars. Yes, I did some web search and most said python is cleaner and easier. Seems like C# is the better language over all. One question, what do you mean by “Python is more cross-platform”? Is it more compatible with other software’s? And since we are on the topic, lets say I learn C#, will it be difficult to transition to python then if I need in the future?

  2. That’s super cool. Personally for me, I get lost learning from posts that’s just me XD. I generally prefer a online/offline course or a book.

  3. Yes, this is almost my first time. Almost I say because I learnt little of rhinoPython but now have forgotten (need more carrots in my diet). No I am a nood let’s say need to start from syntax usage.

Thank you for such a great reply.

Today there are plenty of resources for GH related C#.
Here are some of them:


I would recommend to do also some non GH related scripting course to get the basics, even if it seems boring.

7 Likes

Thank you for the reply Emilio.

Oh I didn’t knew about that, so C# seems to a better language to start learning.

That’s interesting to know about C#, so C# will not work on MAC? Okay, thank you for the detailed explanation Emilio, really appreciate it.
So lets say I learn C# for now and later if I need to learn python, for other software will the transition be smooth or I need to learn Python again from scratch? (I ask this cause I am just beginning and there are other software’s also that I want to learn in the future like Unity, Blender and Houdini).

Wow, this seems logical but a lot of learning to do then XD For some weird reason I like python may be cause of it’s name I am not sure, sorry about the deviation. Any videos or books or courses you recommend for starting?

Thank you again for such a detailed reply. I will definitely keep you posted, if I need any help :grinning:

Start from Masters: J/B Albahari and J Skeet. With computer off read these 10 times. Then - maybe - press the red button.

Remember: in AEC Geometry is nothing … all what matters is the control of things.

Remember: Coding is kinda martial Arts. You start having in mind some things. Several years later (+ pain + tears) you’ll see the big picture.

Remember:

1 Like

c# runs ten times faster than python if you write a plugin. But c# is a lousy language. I feel difficult to read, even for the code written by myself.

1 Like

There are many free resources like this one

1 Like

Allow me to highlight this part:

Generally speaking I use GHPython for most of my daily coding (generating/analysing geometry and solving problems fast, iteratively, and on the fly) and C# whenever I need more performant code. I personally find that GHPython provides less friction when scripting directly on the canvas than the C# component/language. Conversely, writing compiled C# code in Visual Studio when developing “real” Grasshopper plugins is very low friction. So if your goal is to write a plugin I’d recommend starting with C#. Although you can “compile” your GHPython scripts it doesn’t offer performance benefits (that I know of at least) and is really rather cumbersome.

Just to point out that “better” is meaningless without context and requirements. It is 100% relative to the problem at hand and the person developing the solution.

3 Likes

Thank you so much for sharing these resources, Baris. Really appreciate it. Thanks again :pray:

Thanks again for a great reply Peter and for that amazing quote by Sun Tzu :pray:.

I will definitely look into those Books and start learning slowly and may be some day liked you said see the big picture.

Thank you again for all your help.

Thanks for the reply Zhuangja777, I will consider this when I start learning either of the language. May be I will take a look at similar codes and then decide which is more readable friendly.

Thank you so much for sharing this resource Seghier :grinning: Will look into it right away.