I'm getting into Python Code and need some advice (specifically, choosing an IDE)

I’ve browsed past topics and it seems like that both advancements are on the horizon, and that there is a lot of outdated information on the internet. I’ve started reading “IronPython in action”; being a LISP developer for AutoCAD I quickly realized that I have to learn lots about programming theory opposed to just typing out the code itself.

I would prefer to both be able to write stand-alone apps (even just console apps for practice) otherwise I’d probably already be into Rhino’s Python editor much the same way I would be with AutoCAD’s LISP IDE. For programming outside Rhino, my research so far tells me that my only option is MS Visual Studio and from there install an IronPython Add-in… but is it even possible to add say, IronPython 2.7 to the version of MS Visual Studio currently available? And… do I even need to use 2.7 (a topic a couple years ago stated that 3.0 is already supported). Back in the day I played around with VS and didn’t have the best time with it. It felt like getting everything I needed was a bit of a scavenger hunt… many use it successfully of course, so perhaps I just need to settle down and dig a bit deeper.

If you have any alternatives to Visual Studio I’d love to hear them! I’ve read good reviews about other IDE’s but none of them specifically state that they support IronPython (or at least as far as I’ve read into it so far). I’ve heard other IDE’s are often more user-friendly overall so long as they have support for what you’re actually intending to do with them.

I haven’t tried with IronPython, but I personally like to use Visual Studio Code. I’d imagine that you could just pick the ironpython interpreter as the one for any workspace you may have open.

I don’t think we’ll go to IronPython 3, at least I don’t have seen any plans for that. But for Rhino 8 we are going to have CPython 3 integration.

Among us more and more are using Visual Studio Code to do work. It doesn’t replace Visual Studio, because VS just has very good tools especially for debugging, profiling and other diagnostics. But VSCode provides a lot of extensions that can make your life much easier. At least on the Mac many are moving to VSCode (VS for Mac is not very good).

Anyway, with about anything you should pick the tools that click with you the best :slight_smile:

Thank you Nathan! So would you recommend that I just learn CPython instead (not much of a change at this point). Rhino 8 is still at least a year or two away no?

What’s the full story behind the switch? Isn’t it a lot of work to make a new API? To be honest I was kind of struggling to understand why ironPython was the chosen implementation in the first place. It seemed kind of odd but at the same time I was excited that I had an excuse to use a .NET language.

Ahhhh… I finally found a clue: Microsoft abandoned IronPython and now it’s maintained by a team of volunteers. This may or may not mean that it has a limited life span.

CPython / IronPython. Both have their pros.

Since the main Rhino SDK (outside of the C++ one ) is a .NET based API it makes sense to have a .NET based scripting language.

As you know the IronPython stable version is currently 2.7.11. Python 2.* got deprecated, and the IronPython 3 implementation is still in alpha.

Going to Rhino 8 was a good moment to get our Python support to the modern Python 3 and do that with CPython at the same time, making in finally possible to properly use about any (C)Python 3 module out there, including those based on native code. This has been often problematic with IronPython.

In the end any language is great when you learn to properly use it.

1 Like

You’re very informative! Yet I’m still debating what to learn. It’s not an easy decision.

Maybe VS Code with CPython to practice syntax, and just do simply scripts within Rhino’s Python editor itself?

With AutoLISP you’d just type “VLIDE” and start typing code. Easy to get into but a lower ceiling I guess hehe.

Thanks again for all your great advice!!

Oh… and just so I don’t have to ask layer, ironPython for Rhino is not going away is it? I mean if I get as far as coding my own plug-in, I won’t have to re-write it in Python 3 later on to make it compatible with Rhino 8?

For most cases you probably can just use 2to3 - Automated Python 2 to 3 code translation — Python 3.9.7 documentation. Many of changes necessary will be made for you. I wouldn’t worry to much about it. Python will be the same in many cases.

I don’t know what the plan is for IronPython, whether it will be phased out already or kept on as fallback. Time will show (:

Practically seen, if you write scripts in Rhino/GH you likely never need the full language. A script is almost never longer than 100 lines of code. And if it is, then you should not consider it as script anymore, but writing a plugin.But then you notice that IronPython is not the right language, due to limitations within the .Net environment.

The reason why IronPython was likely dropped by Microsoft, is because .Net and Python don‘t really fit. As soon as you deal with rare .net collections, interfaces, events, properties… you are accessing language features which make perfect sense on a language like C# but seem to overcomplicate Python code. In the end a good IronPython developer need to have an decent understanding of C#, F# or VB.Net. And once you use these features, your code is not much better to read than C# code…

So in the end, most Rh/Gh user ending up in writing in C#, as soon as complexity increases.

Anyway, a Python IDE I like is PyCharm, for any other languages I prefer VS Code. And for C# nothing beats Visual Studio (on Windows). Indeed, the MacVersion is horrible.

2 Likes

Thank you Tom! Funnily enough I started actually looking into C# as I started to find that getting into Python was becoming more and more convoluted (at least with regards to what I was planning to do). I can also see that I won’t need to even be very good at Python to write the scripts I’m intending to - I can just copy, paste & replace parts of the scripts readily available on the net.

I had already gotten pretty far through “IronPython in Action” when I realized the language has kind of been put aside. The book markets the language a little too well. Not all is lost in that the book does a really good job of explaining general coding topics as well as having a primer on .NET, so it wasn’t a total waste of time.

I had actually tried to get into C# for AutoCAD API programming a few years ago. I found it to be a little much for me at the time as each AutoCAD version also had a different .NET framework version. I learnt a bit of syntax but was never able to get an app to work in AutoCAD itself and therefore gave up (reverted back to LISP). After browsing McNeel’s site it looks like their C# resources are a little more clear than Autodesk’s were back then; definitely going to have another go at it :slight_smile:

1 Like

And sorry… .NET Core 4.8 right? No lower no higher?

Excellent news!! Been waiting for Python 3 support! For me Python just cut it - no so much with C# and all the heavy .NET ecosystem.
Thanks McNeel for choosing Python!

According to this post: .NET 5 for Rhino 8? - #2 by stevebaer
framework for Rhino 7 is, and most probably for Rhino 8 will be .NET Framework 4.8. There might be transition to .NET 6, but .NET Framework 4.8 should also be supported in some manner.

If you choose C# and Visual Studio there are plugin templates for Rhino 7:

Are we talking about C# now? I’m confused

At the time I wrote that I was still unsure what all the different .NET terms meant: That being .NET, .NET Core, .NET Framework, etc… but have since read up a lot on it. Different reference manuals/books/tutorials will all be using different versions. I think the most recent was C#9.0 and .NET 5.0? I decided to go with an older text - C# 7.0 and .NET Framework 4.X (4.5 I think). I don’t want to learn anything beyond what I’d ever be able to use in Rhino. At the same time I might create a simple stand-along desktop app or two (where the target framework would be the same as Rhino’s). At the moment I’m not even sure if writing my code in C#9.0 would cause any issues with a Rhino plugin. But it almost doesn’t matter as I won’t be coding anything even remotely close to something that would be extending the full capabilities of .NET Framework 4.8 nor any older variant of C#
In short, if I’m writing code I want to ensure it’s compatible with the .NET version I’ll actually be using. Remember that I’m approaching this as an AutoLISP developer; all we need to do is type “VLIDE” at the AutoCAD prompt and start coding. Nothing more to it, no “stacks”, no .NET versions, no need to download SDK’s, so all this stuff is very new to me. Interesting and fun to learn but at the same time overwhelming.

Type EditPythonScript in Rhino. This is the fastest way to get your feet wet. Once you’ve learned how to work with this in Rhino, writing a stand alone app based on CPython will be easy. We can help point you in the right direction for stand alone when and if you want to go in that direction.

1 Like