Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: How to teach Python and good programming practices to Matlab hackers?
2 points by sleavey 9 days ago | hide | past | web | favorite | 2 comments
I've volunteered to give an introduction to Python programming to some fellow physicists who normally use MATLAB. Rather than treat them like complete beginners, I'm trying to think of ways to pitch the material in terms of what they already know from their experience with MATLAB. They want to know how to do with Python the things they currently do with MATLAB: mainly analysis, manipulation and plotting of lab data. They also expressed interest in learning "how to program", i.e. they judge their current abilities to resemble "hacking" more than programming, and want to learn a language that employers would be interested in. However, they do understand some of the basic concepts about programming, like variables, loops, if/else blocks, mathematical operations, loading serialised data, etc.

I thought I'd start by showing them the basic syntax differences, then move on to the equivalent tools in Python to manipulate and plot arrays (Numpy and Matplotlib). However, at some point I also want to introduce lists, dictionaries, functions, defensive programming, and other key concepts that are often ignored by course that teach scientists how to analyse and plot their data.

Has anyone given, seen or had a course that was aimed at MATLAB users that I could adapt or use as inspiration? Should I treat them like absolute beginners, or can I pitch some of these concepts in terms of their existing experience?

I migrated to Python from Matlab and found the following resources very helpful:

1) Numpy for Matlab Users [1] 2) A Gallery of Interesting Jupyter Notebooks [2] 3) This introduction to Matplotlib that starts with the Matlab-style API and transitions to the object oriented API [3]

[1] https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users... [2] https://github.com/jupyter/jupyter/wiki/A-gallery-of-interes... [3] https://nbviewer.jupyter.org/github/jrjohansson/scientific-p...

The thing about Matlab is that it is very easy to work with, and so many things that are actually very tricky just work, things that you probably have never any idea could fail in a particular way.

They also probably picked a lot of habits from experience that you have no idea about, and also have specific tools and workflows they use.

The matlab documentation is just extremely good. You can actually get useful and working _examples_ of code just from searching a command name in the help browser.

Python documentation, I have found out, except the scientific stack which is actually pretty good, is lacking. You have a lot of text, and few examples, which are often not the examples you want. Python documentation is also often completely oblivious of the environment where you're using it, especially on windows.

So you want to replace matlab, the first thing you have to do is understand the environment and context of what you users want to do, and discover if you can make it "just work".

Like, soem things where in matlab would be a matter of just typing `load` and the name of the file and you magically get a variable with data in the way you already expect, where in python you have to hunt for some package or something specific.

Ask them to demo what they are working on, and see if you can reproduce that in python.

Then you start teaching them "programming".

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact