C# Or Python

So, I have been learning Python, partly as a better way to loop in Dynamo, but just as much to get access to the Revit API…

The Python node in Dynamo is talked about a lot so I presumed this was the only option. However as the API is in C# I’m having to mess around interpreting it into Python, when I’m a basic Python user and have no knowledge of C# this is painful.

Then I find out about this node! C# CSharp in Dynamo Am I better off jumping to C#? It might be more to learn to start with, but I won’t have to interpret so much and I’m happy just pulling a few bits of info to supplement my nodes…

All views appreciated :smiley:

Thanks,

Mark

3 Likes

aren’t you nerdy enough by now?

:slight_smile:

4 Likes

No. Not even close. Like maybe 1/3 of an acceptable level of nerdyness.

On the ‘cool’ side of the C# interpreter, you can do all the cool C# things and Revit API is a bit easier to work with as the examples are all given in that language.

On the ‘not cool’ side, you’ll be somewhat stuck with the functional limits of that node.

Personally, I always viewed that node as the ‘gateway’ to making your own C# library of custom nodes. Way easier to test with the string of code than compiling a custom node each time. That said, I have yet to take that plunge so I cannot conform it’s a good path or not.

2 Likes

Personally, I think that the C# scripting node has a lot of quirks on its own, like having to cast everything to the right type and making sure you’ve referenced all the dlls. I’ve never ended up using it in any custom nodes or projects, and instead have been using it just for testing specific sections of C# code. It’s only strength is that you can use existing inputs straight from dynamo and that you don’t have to worry about compiling or restarting Revit because some DLLs got locked.

On the other hand, the python script node does a lot more hand holding for you and there’s a lot less things to worry about. You will find a ton of examples on the dynammo forum or inside of custom nodes in people’s packages. In general there’s going to be a lot more people around that can help you with your own python code on the forums too.

10 Likes

Thanks for the insight! Useful as always. :slight_smile:

1 Like

Start with Python; its way more forgiving if you’ve not coded before and just want to have scripting skills you can mix into your day job. Ultimately, knowing both will give you the most flexibility; its important to know that the right tool for the right job also applies with programming languages. Plus, if you learn one, you’ve pretty much learnt the other, at least from a conceptual standpoint. You don’t need C# to access the Revit API either; IronPython is .NET enabled and the syntax for making Revit API calls is practically identical to C# just less verbose (so you could argue, better for getting started). There are some nuances where this rule of thumb doesn’t apply, but they are few and far between.

The main advantage with C# is the fact you can develop in a full IDE, which is ideal for developing complex programs or solving complex (design?) problems. Paradoxically, its also the ‘easiest’ option for developing by virtue of the IDE, the catch being you need to understand basic comp-sci paradigms and the language of course, before you can do anything useful with it. Python on the other-hand has a reasonable text editor, which can be improved with stubs (which emulates IntelliSense in Visual Studio), but you cant really compare the two as its really just a halfway-house at best.

14 Likes

C# lacks good and tested free and Open Source libraries for most of computational tasks. Python code is quick to write and easy to learn and requires no compilation . C# is a good choice. But, if you need to perform scientific computation and want to produce good-quality scientific plots, Python is a good choice. Go for Python.

@Thomas_Mahon Do you have the same idea or you have developed your approach from DEC 2018?
I have been learning Python for one month, and I do not have any programming language experience.
it seems for me that start with Python is better.
thanks a lot for your advice.

1 Like

i find some of the statements above against c# a bit misleading. Of course there are libraries available and if you use visual studio for development, there’s far more hand holding: debugging, syntax highlighting, code beautifying etc etc. I guess strongly typed languages are a bit tricky if you’re not used to them but the “var” keyword can at least make that a bit less painful. I think the one thing about c# is there are a lot of shorthands that can be confusing to newcomers. The problem with visual studio: licence costs!

2 Likes

There is a free version that can be used. Also there are open-source IDE solutions.

The choice between Python or C# can’t be decided by counting checkmarks. It depends on the goal. Is someone satisfied to use Python to accomplish the end result to avoid the impossibilities of Dynamo? Then that is the perfect answer if one should learn Python.

If the goal is to do much more, even plugins that run straight inside Civil 3D or connections to other solutions, then C# is a good choice.

Personally, I am a programmer, so I rather write my own plugin or Zero Touch nodes in C#. But colleagues of me prefer Python, also because they can use that in other solutions like QGIS.

2 Likes

yes certainly python is the right choice for many and I understand why c# can seem a bit daunting to a non-programmer (although I find python a bit hard to fathom at times with all the white space requirements!). I was questioning the downsides of c# that people had written above which were to me were a bit misleading.

And of course, there are free versions of IDEs for c# i’d forgotten about that! :slight_smile:

2 Likes