Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
6

The old Python v Ruby Question

asked 2018-03-24 17:26:07 -0600

Daithi101's avatar

Hi, as newbie to OpenStudio, it seems that Ruby is the easier option for exploring Measures. However, Python seems easier to learn generally...? will this be made more difficult by the fact that most (all?) examples etc seem to be in Ruby or will this problem be overcome by using Python Bindings and I will have access to the all same sample measures, etc in Python ? New to programming, and measures but a little Python previously and it seems easier ( but haven't looked at Ruby at all). Any suggestions greatly appreciated, thanks, Daithi

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
7

answered 2018-03-27 05:22:56 -0600

updated 2018-03-27 06:00:54 -0600

Ruby isn't harder than Python to learn. I have been using Python for years, and when I picked up Ruby (for OpenStudio), I had no trouble making the switch. They look pretty similar.

As far as your questions goes, I'd say it depends on what you're trying to achieve. Generally speaking, your life will be easier in the openstudio ecosystem if you use ruby, for a variety of reason:

  • Ruby is the de-facto official API language. All examples are in Ruby, all of the tools used behind the scene are in ruby (save for the SDK itself which is in C++)
  • Ruby therefore ships with the installer packages, whereas the Python bindings you need to compile yourself from source. This also means that if you use the python bindings, your code will be harder to share with others.
  • You cannot directly write an OpenStudio Measure (to be run in the OS Application or PAT) using python.

That being said, I am still an avid user of Python especially for visualization/post-processing, since Python has a ton of very useful modules for science / data manipulation / visualization, that ruby is lacking. Part of these I have explained in Time series visualization tools? if you're curious.

So I'd say that if you are a professional trying to use OpenStudio to model real world buildings, go Ruby. Even if you already know Python as a matter of fact.

Note that there are classes (online or in-person) that deal with OpenStudio scripting, you could start by looking at the Best Directory (disclaimer: I'm the owner of EffiBEM, one of the listed companies).

Only if you're just using OpenStudio as one tool inside a much vaster ecosystem, for example to run a lot of parametric analysis and want to do heavy post processing etc, then perhaps Python is the better path.

edit flag offensive delete link more

Comments

For completeness, PSD Consulting isn't listed on the Best directory, but they do provide scripting training as well.

Julien Marrec's avatar Julien Marrec  ( 2018-03-27 06:03:59 -0600 )edit
4

answered 2018-03-26 21:48:51 -0600

TomB's avatar

I asked myself this question and decided to go Ruby. I reckon that you'll make life harder for yourself in the long run by going the python route. I've been able to bash together Ruby measures that get the job done, despite my ignorance of the finer points of the ruby language.

edit flag offensive delete link more
3

answered 2018-03-28 09:42:10 -0600

I'll add to the answers just to say that one of the strengths of Python is its well developed set of scientific libraries for data manipulation and visualization (Pandas, matplotlib, etc.). However, SciRuby is developing similar ones for Ruby (GitHub repos).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

2 followers

Stats

Asked: 2018-03-24 17:26:07 -0600

Seen: 421 times

Last updated: Mar 28 '18