How easy is it to learn to code? - podcast episode cover

How easy is it to learn to code?

Nov 11, 202135 minEp. 21
--:--
--:--
Download Metacast podcast app
Listen to this episode in Metacast mobile app
Don't just listen to podcasts. Learn from them with transcripts, summaries, and chapters for every episode. Skim, search, and bookmark insights. Learn more

Episode description

Coding helps make so many complex tasks in science and engineering easy. Laura, and Ghinwa are joined by Emma and Clea from The University of Manchester's society for Women in Science and Engineering to talk about how they learned to code. They discuss some coding skills as well as how they use coding in chemical engineering, computational chemistry, physics and robotics. They also discuss how coding gave them confidence in their work, how they built up their own confidence in coding, and how it helped them in their careers.

Read an article based on this episode by Laura Leay on medium.com

Transcript

[Music]

hello and welcome to technically speaking a podcast where scientists and engineers come together to chat about common interests share knowledge and satisfy some curiosity i'm laura and in this episode i'm joined by guinoa emma and clear to talk about how we just learn to code and what we use it for so to start off with emma can you tell us a little bit about what you're coding and how you got into it yes well how i got into it uh perhaps a bit different to how some

people i know got into coding and that was because in my degree we had a non-optional module in python i actually enjoyed that a lot more than i thought i would and then i ended up taking another python module in my second semester and uh like over summer really really got into just like looking into what the code can actually do and in my third year now i actually joined the robot society and i'm a part of a team that's trying to get a robot arm to play chess uh

we're working in matlab there and that's like very new to me uh but that's currently what i guess i'm coding on as well as some like lab stuff which i have to do but mainly the robotics trajectory stuff ah cool so you're doing this for fun your degree is physics isn't it yes uh i'm on an emphasis on this so that our fourth year um and so i figured this isn't my final year so maybe i can spend some extra time doing some coding for fun where i don't like it doesn't

contribute towards my grade essentially so that's quite nice and that's quite a nice story about doing it for fun but having learned it from your undergrad degree my undergrad was physics as well but it was a long time ago and we learned fortran which is uh very different i think um cleo what about you how did you get into coding i do the same degree as am i also studying physics for me in coding was just very practical and it became necessary at some point because in first year so we didn't do

any coding and it just felt like especially when we were doing labs that there was a lot that we couldn't do and we were actually stuck and not being able to do some things not being able to present the data the way we wanted it to look like so i really felt like coding and using python could help me for that learning to good was actually my lockdown activity because i didn't know what else to do with my time i started doing some online courses because there's just so

much out there so when i started learning python and then i took the same module that emma mentioned that was mandatory for us um and i did really enjoy it as well and now i just mostly use python in my labs on almost daily basis i guess uh and my latest lab was on particle physics um and so we were just analyzing a lot of data using coding okay i feel like we'll get into a lot of the details about exactly what you're using it for and various other things as we get

through this conversation i really like that you're doing something that's mandatory but also enjoying it yeah you know i think your experience is quite different from emma and clears but i don't want to put any words in your mind so would you want to tell us about it yeah definitely it wasn't a fun story like clay and emma because i had to do it in late during my phd during the third year and whoever did phd knows their stress actually or the third year during phd so i had a phd project which

was meant to be totally experimental so i built a rig in the lab tested at different operating conditions but then i reach a point where i need to gain more understanding of the physics and science behind what i'm doing and i need to predict results at different operating conditions so i had to do modeling and i had to start learning coding really in my late uh third year of phd but it was a very very rewarding experience because it opened up a whole world for me and it allows me actually

to get the new job i'm going to be starting soon for you i guess you had to self-teach yourself in your phd code right yeah that's true well i had first to gain the logic behind uh coding which wasn't really the logic that we use in our day-to-day life isn't it to do that i just had to break some some link in my mind so what i did is i had to watch videos every night before sleeping for 10 minutes about coding whatever it is python or matlab any language really and then it seems

like with time i start to get the logic behind it and i start to be more familiar with what we are doing here and then i start really taking uh online training self-teaching and then getting on the track of most people do actually to learn coding wow that's so impressive and the fact that self-teaching actually helped you in your career as well very cool yeah and it sounds like there are some common themes that you've all put the effort in to learn to code in your spare time it

sounds like so i've mentioned that i did physics as part of my undergraduate degrees a long time ago now and i learned fortran it's mostly maths based i didn't think much about it at the time but maybe about five years later i ended up doing a phd and i got that phd position because i knew fortran and it was useful for the computational chemistry that i was doing in the phd but i think fortran's very different to matlab and to python as well so i guess before we get into our discussion about

what projects are working on now and a few other things it might make sense to explain what some of those differences is and how the coding languages work so if i say that 4chan is maths based it's quite simple it's the only sort of inbuilt things it can do is like trigonometric functions in logarithms i think exponents and how does that compare to python but like starters i noticed what i found incredibly useful about python when i was working on my lab in

astrophysics was just you have a module called astropi and it does everything you could ever want it to do in astrophysics and the most important thing i found it did was actually like convert between coordinate systems because i still don't really know right ascension declination and latitude and longitude you don't actually need to know it um you can just use like the inbuilt functions and in matlab as well i've noticed already there's loads of like inbuilt things you can like install as

well specifically for robotics and like statistical maths like modules you can install and you can use them to generate random numbers or you can use them to model different systems and it does kind of a lot of the work for you and it's like mainly just adapting what's there to what you want it to do python and matlab are probably a lot more similar to each other than fortran is by the sound of it probably a fortune might have changed since i first started using

it i think it was it originated like 1977 and i was using a version called fortran 95. [Music]

so what about matlab i know a little bit about how it works i think i used it once again a long time ago i was mostly frustrated by it i think it's mainly for chemical engineers so i'm surprised it's used for robotics but again remember you can tell me more yeah so i use matlab actually because it has these built-in functions that helps me solve the mathematical equations that i want and i remember i used something called cftool that basically does all the job for you

so you just need to choose what type of equation you need or try it really to fit your data and then once you choose the type of equation that fits well your data it generates all the functions and everything for you so you don't have to build actually the function itself so it was really easy in that term okay so has it got something built in there that can sort of like figure out all the maths behind um like the trends that are in your data is that right that you mean by

function if you have a trend that you have from laboratories so let's say whatever mass variation as a function of time and then you have a graph for that and you need to um what's the word for it laura you need to fit your data you need to fit your data so you need to fit your data so you have a set of equations you can use for example a linear equation an exponential equation uh whatever so you can try different equations and the one that you think that fits the best your

data or really it makes sense for what you are using so you just choose uh this and a tool called cf tool and then matlab is going to generate the function for you rather than you making the function from scratch and try to fit your data yourself so that was really make my life easy i thought we would talk about the same thing but i just wanted to make sure yes different disciplines use different words same different same words to mean different things i think maybe that's

one of the challenges when you learn to code yourself you don't necessarily know like the formal terms and things like that that's what i've found when i've picked up something new one of the things i think i found really useful from what fortran does is using two coding things called loops and if statements are like do loops and if loop that means that you can like automate a whole load of things and like set it some sort of decision-making criteria to get your code to do what you wanted to

do so if it encounters um so i was working on them atomistic simulations so i encountered like a bond length that i had made too short it could tell me about it it took some of the the mindless treachery out of it yeah you were trying to build your molecule so i think we're all saying like you could concentrate on like the interpretation of the data or whether that fits is a physically possible thing yeah with the the like if statements as well as soon as i found out about them i

don't think i've ever stopped using them we've had like a couple of projects where we've had to filter out data especially in labs and like noisy data like you can use if statements to get you like i guess quote-unquote good data to then fit one of our projects like initially one of the main tasks of it was like getting rid of the nands and the infinites and then trying to like actually get the data so you could see a relationship because a lot of the time if you don't actually do that you just

get like a horizontal line and like the values are just don't mean anything so i've used if statements way more than i ever thought i would when i first like found them and my mind just keeps on going to them all the time good to know i find it so funny that you said nan because you were the only other person i've ever encountered that says none rather than not a number this is this is not a number this is an end yeah when your math has done something it's just not physical and the equation's

like i don't know what that is you just get a whole page of not a number yeah but so i guess that sort of explains one of the benefits of learning to use these languages i mentioned it can take some of the drudgery out of it you mentioned that you can use it to filter things so it can make things a lot easier for you yeah because in chemical engineering also we need to use it or i need to use it just to set boundaries actually for my functions because sometimes for

example the function cannot be let's say negative so you need to filter all that data by using um if statement and it's quite funny so it get in my mind so deep so whenever i want for example to go and do some shopping i would be like if the price is if not or if this sandwich is if not and then just crazy you spend your entire time shopping writing logic statements in your head exactly i can't get rid of it actually and my daily life and daily tasks is just funny

i love it i think i do some of that in my writing as well i've noticed i'm far more likely to write if and then then in a sentence rather than just using one of those words i sort of alluded to some of the stuff i did in my phd and i feel like i should explain it in a bit more detail to help demonstrate some of the benefits uh so i said my phd was computational chemistry and the starting point there is to build your molecule on your computer which usually involves

using coordinates sucks you cut using coordinates and there is software that can do this for you for fairly straightforward well-known molecules but i wasn't working on those i was working on some really novel complicated ones they were polymers and they had maybe 100 atoms or so in each monomer and they had all these not unphysical linkages going on but things that you wouldn't tend to see very often so i had to figure out a way of building them and then once i build them i had to

explain to the software that was going to run the molecular dynamics simulations i had to explain to it what my molecule looked like so i had to tell it which atom was bonded to which and then where all the angles were between the bonds and i could have done that by eye and written a very long list but there's no guarantee it would have been correct and it probably would have taken me days to do just one molecule and i had 15 molecules in my simulation box i thought of a way of writing some code

and fortran i didn't actually know it was going to work i just had an idea of how to do this algorithm using all of these if statements and loop until it had gone through my list of the bonds that i'd written and written down all the angles and various other things for me so that's my example of how coding made my science easier and allowed me to focus on the outcomes of the simulations and building the simulations but what about you guys emma i'm intrigued by

your robotic chest playing arm yeah well it's very much early stages of development right now because uh there was people who were working on the arm last year they kind of got it to recognize where it was in 3d space a part of what i'm working on because we have a problem as like a team when we think about all the stuff we have to do every single time it gets more complicated and we're like okay let's try and focus on the simplest of things we can think of right now and then we'll

see where we go after that and so we're working on actually trying to get the arm to move to pick up the pieces which sounds easy but then when your pieces could be different sizes it's like the arm's gonna knock some over eventually and so we're trying to figure out what like function is best for the arm to pick up the pieces and uh how we can actually make that efficient because we don't want a chess piece to take five minutes to be took in a game it's a bit

too much thinking time for the opponent and so that's what like my subgroup is working on it's been really easy to visualize how the arm is working by using matlab and the psycho robotics like a package that helps you there's always like these limitations which go on because the arm has loads of joints and so those have been pre-coded the year before and so when we run something we can see if that path is going to work because it like visualizes it which is something that's like borderline

impossible to do without code because we're working on getting the piece to be picked up and then moved back it's also trying to understand how to get the arm to recognize what piece it is and so we have different parts of that project who are working on playing the game of chess which is a completely separate thing and then actually recognizing where the chess piece is on the board and like what it's taken up i think it's quite a big task but it's been really fun just

trying to like think about it and work on it because i'm on physics and a couple of my friends are on it doing physics but there's also a few electrical and electronic engineers and we all think about the same problems in a different way and so they might say something and we're like oh wait that's actually a really good way to think about it that we didn't think of even just being in that environment with engineers and physicists is really useful for a problem that like helps us

like actually optimize the code because there's so many ways you can do things in coding sometimes it's not always obvious which one's actually going to be the best one and so a lot of my coding experience has been just like staring at a wall and trying to think about what's actually best and then i'll give it a go and then maybe it works maybe it doesn't yeah that sounds about right so can can the robotic arm can it see the pieces it has a camera and so a lot of there is like an idea for like

the the people on the computer vision squad is what they're known as in the group it's like although i think they don't want to do this but it's uh doing like uh qr codes like the leap then beneath the chessboard so that when it picks it up it can read the qr code which corresponds to a piece and then that is how it gets recognized there's loads of ways we could do that's like a process which we're trying to do but first of all i think they're working on like getting the the camera to recognize

when something's blocking a square so it means there's a piece there and then they're gonna work on how you recognize the specific piece but there's there's so many ways you could do it you could do it with some form of infrared camera labeling or there's loads of ways but that's like me talking about physics because we're talking about picking up the pieces as well and uh all the physicists on the team were like electromagnets and everyone else was like no

yeah i imagine it having like i'll never think about the end of it so it sort of physically pinches things fixed up i mean that's a bit too simplistic i quite like the idea of using magnets but i guess you need to make sure it's gotten close enough to the right piece to pick it up and not pick up the wrong thing yeah i mean i think that was a bit of a joke among the physicists at the time on the arm there is like a hand which can pick it up but we also have to figure

out how the hand which is like the two like pincers i guess how we even code that to pick it up and how like much pressure we use and everything like that but like right now we're all thinking it's a year-long project that is a problem for futures you mentioned that you you got a job as a result of learning to code and that sounds really useful getting paid codes yeah that's very true actually it was a positive point on on my cv that i do coding by the same time i understand uh

the experimental side of stuff because usually people are either in experiments and they don't want to know anything about coding or they are encoding but they're not very much into experiments and linking both experiments and coding is very useful especially in what i do so you have always to validate what you're coding and modeling in the lab and see if it really makes sense i think i understand what you mean because you can see the problem from two different points of view can't you you

can see like how you would code this thing and what the data may look like so it gives you more insight beyond just doing the experiment and seeing what comes out of your chemical engineering rig at the end yeah um i mean in your case laura you did only modeling so you didn't have to validate anything in the lab didn't you uh it was modeling polymers that had been designed by chemists in their lab so there was a little bit of making sure that it did actually have the same

properties as the polymers that were made by the chemists i see so there's that link because in my case even in my group whoever is doing modeling they just make sure all the time to validate it with some experiments because actually you can model anything we say in mathematics this is something i learned from my math tutor that if you give me three points i can fit you an elephant so you can you can just basically fit anything but then how do you know it makes sense so you

got to go back to experiments and to the physics behind it but also i used coding because i need to solve mathematical equations and partial differential equations which are which you cannot solve without coding actually so that's why i used coding basically to solve these mathematical equations perhaps the physicist can help me out because i remember doing partial differential equations and ordinary different differential equations in my undergrad degree in physics and i i

guess they were quite simplistic it did take me a while to get my head around them but they were solvable by hand so i'm guessing you're talking about some more complex interplay between different variables yeah so you're talking about a set of equations with boundary layers and with many functions to be solved all together and a boundary conditions so you're talking about really a complex set of mathematical model that wouldn't be solved without coding so is this the

sort of like situation where like i imagine like a really simple chemical processing rig if we're talking about chemical engineering so you've got some sort of like reaction vessel with something going on inside it and you've got stuff flowing in and out and you've got temperature so you have to sort of control all those variables and then use the modeling to predict how those variables affect yeah comes out at the end does that sound right yeah that sounds right but

in a more complex way so in my case i need to integrate all together heat transfer mass transfer fluid dynamics altogether make a link to what's happening in my rig and then produce from these physical or mathematical equations a set of final partial differential equations that change with time change with mass changes whatever variable you have and then try to solve it within a boundary conditions that i set to my system i get it and the boundary conditions are

like so going up to a pressure of this amount is not possible so that's one of your boundary conditions that sort of thing yeah there's a different type of boundary conditions there's stuff that for example some mathematical equations need to be within a certain value some like cannot be negative for example it's again not a number exactly you cannot divide by zero for example this is a very simple example but also you need to set your your time frame if you're having any operating

conditions that you cannot exceed as pressure as temperature and so you need to put all these data so imagine you have all that set of conditions all together and you need to solve the problem so it wouldn't i think maybe it's you can solve it in like i don't know in a lifetime you can't just you know be like old scientists having your board and trying to solve the mathematical equations maybe you would do something about it but yeah yes if i can give like another maybe another example of like

something that is a lot simpler to maybe imagine in terms of something where you'd need numerical methods and coding so you know when and you probably did that like gcse physics when you have a pendulum and they ask you solve the equation of the pendulum you know how you only solve it for small angles that's because if you don't just solve it for small angles it's a non-linear problem and so you can't solve that equation like you mentioned before by just solving it by hand you need

something else and so for when you have a problem like that it is much easier to just use coding it's very very difficult to do by hand and it seems like an easy problem it's just like a pendulum oscillating but even that you'd need coding i'm really glad you brought that up clear in a similar we actually had a computational project on a simple harmonic oscillator but a force driven simple harmonic oscillator and uh so a part of that like was trying to actually

model a regular like unforced simple harmonic oscillator which if you speak to any physicist like if you try hard enough anything it's a simple one a gossip later yeah chemical bonds is a simple harmonic oscillator yeah yeah a part of that project was about solving the like equations of motion when you have a force system which you physically cannot do and so to do that we just literally experimented how different mathematical methods work and how they best fit the results and

you use the data you have from the unforced case to find the best method and you apply that to the force case and so you can use it to solve these like impossible non-linear systems in a way that actually is not impossible and actually quite like satisfying to do because you you know you can trust your answers it's not just like oh let's try this and see that this is probably right like you can actually validate that they're going to be a good answer which is kind of impressive when you think

about it yeah it's not having knowledge of the physics that's good enough to know when the thing that has been done by the computer actually makes sense yeah physics will take you so far but then you can go further with the code which i think is what's quite nice about it for me learning how to code really helped with my confidence like having that insight into how these things work or even like i know that i can't do that thing by hand because it will take too long or i don't have that

insight but i can code something that will give me that information would you guys say the same thing yeah i'd say even just giving me confidence to work on a problem but also doing coding has given me more confidence in my coding ability i knew python first and then moved to matlab for the robotics project but i would have never dreamed of doing that if i didn't already know python and i was kind of babied into python in our like intro to programming module having

that confidence to then work on lab projects just like writing my own thing and then working on the robotic arm even though it's in a different language it's like you have that confidence built from just practicing it and then that confidence also helps you with the actual physics behind it and the work behind it i definitely feel like it's helped me understand stuff and actually kind of argue how i understand it better than if i didn't actually use code at

all i guess there's something to be said for being able to sift through a load of data which i remember doing at various times in my life and occasionally thought maybe i should code this it might make it easier but it was a one-off thing and i think it would have taken just as long to code it as it would have to do it just in an excel spreadsheet i might be proof wrong at some point in the future yeah i've definitely had experiences where i just didn't have a choice but to code in

my last lab so it was a particle physics lab so i had to deal with a data set of nine million different events there is no way you can do that by hand you have to use coding and you have to use this if statements that we mentioned earlier and those while loops and and those functions to make to make nice nice plot in order to make some sense of that data that's a good point and i think so we kind of alluded to using these these loops and if statements it helps with if

you've got something really repetitive to do like i mentioned with figuring out what every single angle is between these bonds in this molecule yeah my case it was a lot of filtering which i guess we also mentioned before so removing everything that's negative everything that's i'm not a number or in my case i had to look at the data if i was in between two different energies so i had to just like filter those out for example yeah and one of the things it became useful for the simulations i

did i fed my molecules into some software one of the software packages did monte carlo simulations of them which is where it adds a random particle somewhere into my system and then calculates the forces acting on that particle and then makes it essentially flips a coin to say is that particle and stay there or not based on the forces the energy in that particular instance and you do that enough times to get what's called good statistics uh statistics that represent what you would

see in real life i think is what that phrase means yeah i mean i've done a similar thing with the monte carlo techniques and simulations in a project on neutron scattering it assigned like you have a random number and then depending on the probability of that neutron being absorbed by some form of attenuating material you can actually build up a representation of that material as like an attenuating material and so you can actually use it to apply it which is what i did like as an

extension of my project i applied it to if you were going to use like a materials like a moderator in a nuclear experiment or nuclear um what do you think is the right word nuclear you could say that nuclear reactor yeah yeah nuclear reactor and you can in flight to figure out like which material be the best as a moderator and so by like investigating the effects of like graphite lead or or water you can actually use the monte carlo techniques to get a really efficient way

of trying to actually just like get the properties of those materials and actually compare them using numbers and not just like using your brain because a lot of the time i was like like lead is obviously not going to be as good as graphite or water or and it's just kind of like actually having numbers to kind of back up what you know from wherever it is you know that information from the monte carlo techniques was definitely just interesting to do and i guess that

example of a nuclear reactor if there's radiation going on and you can do it with the simulation rather than exposing yourself to ionizing radiation it also is a better way of doing things like a lot of safety equipment i suppose that's my background in the nuclear industry coming out yeah i did a summer project at the uka last summer so nuclear fusion and there is so much monte carlo going on i didn't do that personally but everyone around me was doing that just figuring out what

are the best materials to use in this future nuclear fusion um small reactor nuclear fusion it's uh there's a reaction going on it's i guess yeah fusion and not efficient in the those nuclear fusion devices just makes it sound like a mobile phone like a handheld device so it's a lot bigger but yeah it does the same right simulations do get used a lot to do things that would otherwise be quite difficult or maybe even dangerous i suppose you can do experiments on a computer

i accidentally made many small suns when i was doing my simulations because i've accepted the simulation up very slightly wrong so you need to put the time and the effort and invest in your skill and not be afraid of being a newbie anyone can learn how to code yeah a good point of that is like when i've been coding it's been for like a specific purpose and so all i really know about code is like oh can you do this like measuring the drop law can you measure this seem

like this non-linear system or monte carlo integration or can you look at a robotic arm and like there's so much you can do with code and it is quite scary to just sometimes think about what you know is such a tiny like subset of all that there is but i think knowing that you're good at what you can do is enough to give you confidence with code because i think with all the subjects you think you need to have a really like huge like grasp on it but with coding you you can

understand it and be good at it by only knowing like this small fraction of what to do because it's just what applies to what you're doing individually and so you'll meet people that like seem like they know so much about code but then when you get to talking to them they really just know about what they're doing and they might not be able to understand what you're doing that's true i know when i was doing my phd there was one person in my lab there's about 15 of

us in this computer lab there's one person that i kept asking questions of and he's like you know i don't really know this right i'm just really good at googling it clearly that's a skill that i don't possess because i could try and google something and i wouldn't get an answer that made sense to me but maybe just having that person talk to me about what they'd found in google made that difference so i guess that says something like your work learning environment as well find an environment

that works for you yeah i think a lot of the problem as well if you have a problem with your code because it's so personal to how you wrote it the person who has to try and understand you understand your code to understand your problem to them fix your problem and then you have to implement that in your code and so the whole like learning process when you ask somebody else sometimes can even be a bit longer than just trying to learn yourself i found that a lot that i was actually getting

more out of debugging by just trying to fix it myself because other people would look at it and be like i don't know what you've done here and i'm like oh it's just this and this but it doesn't really necessarily make sense sometimes until you clean up of course i feel like a lot of code is just a mess before you try and actually like make it neat i took to putting comments in my code quite a lot just in case my code had to be passed on to someone else who would use it in their phd to sort of

sharing bits of information with each other so i comment is something that the computer or the compiler doesn't read but the people looking at the code can read it and say oh that's what that section of code means i get it that's what that person was doing yeah comments and doc strings for sure in the functions yeah and if you write code without commenting i mean is that really valuable because no one else can understand what your thought process was at the time we got told at the start of

our like first module it's like code is read more than it's wrote so make sure you write it well and like in that module i think i was so perfect with how i wrote my code but when i'm like roughly doing something in labs it's so quick to just like assign some bad variable names which i need to fix later but um you ever call them just like susan or dave or something i remember what that means like abcd and then you just go through the whole alphabet and then you're like

let's start with the green one it just makes sense to call your variables the thing that they actually reflect otherwise you get very confused don't call them susan with my weird deviations calling variables susan rather than pressure and temperature which would make more sense i think that's probably a good place to draw this to a close so uh hopefully we've introduced valued listeners to uh some different types of coding and how they vary from each other and how you can use

it to control something or make a robot arm do what you want it to do or to analyze some data that you wouldn't be able to do yourself or to simulate some atoms that you maybe couldn't do in the lab anyone can code and you can find a way of learning that works best for you whether that's finding the right environment or finding someone to ask or finding videos online and it helps to have a goal to work towards when you're doing that coding so you can start small

and then build up your skills from there so if you like listening to this and you want to carry on the conversation with us you can find us on twitter you can leave a comment on the episode or you can email us as well the views expressed in this podcast belong entirely to the person that said them they do not represent any industry or organization if you enjoyed listening to these views it would really help us out if you could rate us leave a review and tell a friend this podcast was

sponsored by no one but if you're interested in funding us to continue to have frank discussions about science and engineering please get in touch [Music]

Transcript source: Provided by creator in RSS feed: download file
For the best experience, listen in Metacast app for iOS or Android