Which language should a total beginner try to learn first?

I’ve been using grasshopper for about two years, and I’m interested in learning to code my own scripted components.

Should I try to learn Python or C# first?

Does it matter?

Why?

My first short term goal is to learn how to use single rhino commands that are available in rhinocomon in grasshopper but that nobody’s made into a component using a script component. For example, like this: Convert planar-faced NURBs polysurface to un-triangulated mesh?

1 Like

About making simple scripts from RhinoCommon methods that don’t already have a component - I tried to write a very short guide to the process in C# here:

3 Likes

That one might be in the ngon plug-in. I wouldn’t start by making one liner components, it’s too easy and you will know how to do it after a few minutes. A good way to start is to try and recreate some components from Grasshopper as they will force you to learn the language. Then move in to consolidating the processes of smaller gh definitions into components. For instance, things like series which is essentially a counting for loop. Personally, I would go to C# as I prefer languages with more of a structure to them. Python is very loose and forgiving but can also be bad if you don’t know exactly what you are doing you could get unexpected results and not really know why. C# won’t let you get away with anything unless it is written perfectly. Remember, the language you choose is deeper than Rhinocommon and will more than likely require using methods from the language itself just as much as Rhinocommon methods.

2 Likes

you should go for C++

1 Like

Thanks!

Thanks!

Since everyone is recommending C#, I have a follow up:

Does C# code written for a grasshopper component port well to being used in 3rd party rhino plugins?
For example, RhinoCAM is mostly coded in C#. Would the code for something like a CNC dogbone component, if written in C#, potentially be in any way useful for devs making CAM plugins using C#?

Just to add, also remember the excellent and free C# Scripting and Plugin Development for Grasshopper video series by @LongNguyen:

I haven’t watched the latest version, but I believe it still covers some basic Python as well. So it might also provide you with a good overview of when to use which language. Some experience on this topic:

I use GHPython as my “daily driver” for computational modelling at BIG. As it’s fast and easy to develop in (and comes with a lot of useful “batteries included”), and thus really efficient and productive in terms of design/algorithm ideation and iteration. This is at the cost of computational efficiency, so if one needs high performance, or is developing a larger modelling framework/plugin, I’d do that in C#/Visual Studio.

Update: Forgot about these two great C# learning resources by respectively @rajaa and @Petras1 :

3 Likes

Hi,

Free course (learning any programming languages is up to you).

Cheers,
BVR

1 Like

You should not go for C++.
Whatever else you do, do not start your programming career with C++.

7 Likes

it ports reasonably well. There are grasshopper specific elements to component code that you will have to replace with Rhino specific elements. And of course the boilerplate code inside components is entirely different from the boilerplate code inside commands, but you can definitely write your c# in such a way as to be usable in both contexts.

1 Like

School’s in India kick starts students’ programming career with C, C++ in high school.

2 Likes

Give yourself a week to try both, watch tutorials and do something. See in which languages you have more resources to learn what you want. Then you decide which one is a better fit for you. Having a shared impression will help you see what they have in common and what they don’t.

For adding something extra, a great thing about python is that you’ll have the doors open to the AI ecosystem. With C# you will know almost java to learn Processing and javascript to program for web will be easy for you. Maybe this doesn’t interest you right now, but once you’re there, I’m sure you’ll appreciate it.

Most of McNeel’s github is in C#, so I think it’s better to use their language of preference (at least what they have published).

1 Like

Whats wrong with C++ ? it will give you a much deeper understanding of important programming concepts such as memory allocation. After that you can pick up any programming language easily.

@Max3 At the end, it doesn’t really matter that much. The important thing is to get very good in Data Structures, algorithms, design patterns ( code architecture) as well as mathematics for computer graphics.

Right now, I am learning with this course and I recommend it!

Although probably useful IMHO not a requirement. You need to be able to think analytically, have ability to understand a problem domain and find solutions for it.

I think I’m doing pretty well with my linguistics studies only (majoring in Finnish language, but dropped out because of work) to do Raytraced (and Rhino Render in v7) and other programming stuff in Rhino/GH.

1 Like

A beginner? :face_with_monocle: Maybe skip the explanations and go to the playlist links I wrote down.

Explaination 1

Explaination 2

Explaination 3

Playlist 1 the ones which are free

Playlist 2 build a csharp swarm

Playlist 3 with programming and making components in visual studio

I see you reached my post till here. Now you got some basic abs in C# :partying_face:

I love Python. I only fluently code in Python. You should learn C#.

Python in Rhino / GrassHopper is a wrapper around the C# code, using Ironpython version 2. This means you are not getting all the advantages of modern CPython version 3. You are better off coding directly in C# and getting the speed advantages at the expense of a slightly more complicated syntax.

4 Likes

to me, it’s the opposite.
The total absence of “grammar” in python makes the code unreadable, to me.
I did learn js/css/php/html(not a programming language, i know)/svg/c# just by looking at other code.
It’s impossible with python!

C# forces you to be clean and ordinate, opposite mindset than with python.

Go with c#.

2 Likes

I think the amount of available online resources matters. You can easily find C# codes you are looking for, while you cannot for Python codes.
I like Python, but majority of people who are using Python are outside the Rhino community, and the codes they are posting often contain calls to modules that Python in Rhino doesn’t provide.(and Python 2 vs Python 3, IronPython vs CPython, how to import numpy, etc etc.)
.RhinoCommon API documentation provides sample codes for C# and VB, not Python.
Also, as someone above already mentioned, Python is a wrapper of C#/.NET. If you learn C# first, you can easily find Python equivalent. The other way around is trickier as C# is more “restrictive” than Python.

1 Like

Not exactly.
Python code samples are listed below C# and VB. You have to scroll down to see that.

EDIT
e.g. https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_Geometry_Line_Direction.htm
/ EDIT

Still I agree about learning C# first.
Only problem, you cannot write plain Rhino scripts in C# unfortunately, should you have to …
But I agree that learning IronPython after C# should be easier.

1 Like