As a software engineer who uses a lot of code written by medical researchers - please don't just learn the basics! If you're going to publish your code, it's just as important as the text and figures of your paper. Comments, modularity, good variable and procedure names, and most importantly documentation of how to use the code is critical. Dr. Smethurst, I think this is a great intro to how important software can be. A lot of engineers don't think of it this way, but I definitely think we should be making computers easy for everyone to program - so that writing good code is easy and you can focus on the interesting parts of your science!
One of the biggest aspects is to never assume that you'll even be able to understand what your own code is doing a year or two later. I've got code that I've been maintaining for literally the last 20 years. Excellent readability, commenting and documentation are key to not having to waste hours or even days when it comes to having to maintain the code we write. And key here is that writing the initial code is just the beginning of that code's life cycle.
@@TraneFrancks I follow "if it's hard to write, it should be hard to read" and my 5 year old code still looks readable... (This is a joke, don't take this seriously)
But most people know what coding means. I mean if your interested in astrophysics, you probably do. Seems so very basic. Personally, I'd wish she would talk in more detail on how to code to process an image.
Learn to code for your use in your job is a good thing. Become a (professional) programmer isn't all that great though, you basically need to learn all the jobs you do projects for. That being said though I think in most academia programming is at least on the curriculum may it be in just statistics or more technical aspects.
I coined a nearly relevant saying: "Computers will always do exactly what you tell them to do, and if you're lucky, they'll also do what you want them to do."
@@Betacak3 Of course I prefer my phrasing, but it's not surprising that variations of this sentiment exist. I am crestfallen that I'm not as original as I thought -- great minds think alike, after all (not that I would ever claim that I have a great mind).
Seems like you need a bit of luck for computers to do exactly what you tell them to do. This seems to have gotten worse with modern operating systems, but even back in the late 1970s I remember compiling the exact same program 2 times and getting different error message.
The amount of time I've spent on stack exchange for work is unreal. The best thing about coding is that 99.9% of anything you need to code has been coded before and shared online.
This is so true. When I teach people to code, once they know if, else, for, while, functions and arrays, then I teach them that almost all other coding is looking it up. Usually, the only time I outright code is when I become so comfortable with a language that I already know the optimal solution. In fact, in the most recent data analysis code I wrote I included the weblink for each line of code could have been looked up so I can use it as a future example to show to people how coding actually works.
@@arctic_haze You should check out Pandas. I used to do most of my plotting and statistical analysis in R, but Pandas made me finally convert to Python. That said, R's standardization of package documentation is very nice, and I still love "->" over "=".
I've been lucky enough not to have to go through any technical interviews for programming jobs, but if I had to, I suspect most of my answers would be: "I don't know that off hand, but give me a minute while I look on Stack Exchange..."
When I was an Astrophysics student, we were told the most likely career for someone with an undergraduate astrophysics degree was computer programmer. There was even a local engineering company that specifically recruited physics and astrophysics students as programmers because they approached problems differently from comp-sci students.
@@papaburger in my experience, as a tech lead who was a physicist, we tend to be more practical and less theoretical. Computer Science teaches the science of computing and software, it’s not a training course. Although I do know theory of operating systems and so on, I don’t actually care why something has a big O value of X, just which is algorithm is best for a situation. Also we tend to be building systems. I worked on gravitational wave detectors before moving to the tech industry.
Thank you so much for this! I was confused between pursuing astrophysics and comp sci.(leaning more towards astro ofc) until I watched your day in the life vlog and I realised I could pursue astrophysics and get the best of both worlds! I would have never been able to make the decision if it wasnt for the videos you make! Your such an inspiration!! I hope I can study at oxford one day.(I like cambridge a lil more though😂)
As a CS coder person, your description of code was brilliant, "a language that both you and the computer understand." This is perfect. You're writing something that has two very different audiences. A very dumb, pedantic but very fast savant - the compiler. Most people know that, but the other audience for code, and arguably the most important, are other people. Be it you six months later or someone else tomorrow. You have to communicate ideas to them. Comments are a crutch to that, but the code itself should do that. Really well done video. Love it.
In other words, don’t bother commenting on the very low-level stuff that anyone who has used the same language recently should be able to figure out by reading it, but _do_ make comments of a more “high-level” nature? Is that correct?
Yes. Nowadays I'm more interested in readable code and decent commit messages than comments. I can tie commit messages in with git blame and other history commands.
I love seeing stuff from real astrophysicists working on simulations. I'm a programmer self-teaching astrophysics to make a live simulator, and these kinds of things keep me going.
Are you using python and LaTeX together or separately? I have never done so, but I heard it's possible to write LaTeX files from python. I have used LaTeX quite a bit over the last two decades but have no idea how python and LaTeX can be combined.
It's great to see that giant book, Feynman's Lectures on Physics, being put to good use as a laptop stand haha :D Keep on coding and sciencing, Dr. Becky!
Oof, you gave me a flashback. I did a lot of assembly back in the day myself. That's a rough rode to travel! Very intimate, though, it's just you and the processor, with you speaking its language, one level above raw 1's and 0's with no frills. I never did it on a mainframe, though. I'm guessing the instruction set is huge(?)
@@Videot99 you might enjoy this: en.wikipedia.org/wiki/Supercomputer_architecture Modern 'supercomputers' are actually clusters of untold thousands of relatively modest processors linked by fast data buses and wrapped in lots of control and cooling equipment.
@@SlEasyTarget Interesting, thanks. I recently ran into an involuntary use of the networked clustering architecture via internet. I was running Adblock and noticed that my (6 times 2 core Intel) CPU usage would start climbing and get extremely high when I wasn't doing anything. After investigating I learned that Adblock was using people's idle computing power for cryptocurrency mining. Cute scheme! I switched to Ublock.
@@gregf9160 it's mostly related to the fact that those code-bases and libraries they use literally started over half a _century_ ago; before C existed, and when assembly was much, much different
One of my favorite software bugs of all time is from FORTRAN. At one point, early in one of the compilers history the constants for the numerals 0-9 were actually just stored in memory like any other variable. So if you weren’t careful you could assign a value to the numeric (not so) “constant”. This means you could assign the value 3 to 1 and then forever after in your program 1+1 would equal 6. I’m not sure but I think this is the origin of the phrase: “2+2=5 for incredibly large values of 2.”
@@gregf9160 These days with modern tools there’s no need for assembler (compilers are damn good at optimisation) but yes, C or FORTRAN. I haven’t coded it since I left uni, but I did leave knowing both languages.
Doing a PhD in CS and really looking forward to learning to code. Been doing it for a solid 10 years now.. look forward to figuring it out anyday now 😌
About ten years ago a friend asked me to help tutor him in FORTRAN as he was studying climatology in college. As a general computer programmer I’m quite rusty in that language, but we muddled through it. In principle so long as you understand what the capabilities of any computer language are, the rest is just making sure you are using the correct syntax to express your instructions.
Yay, my area of experience! Well coding in FORTRAN but haven't yet learnt Python. I first learnt FORTRAN at school back in the 1970s and my first job was going to be a simulation engineer in aerospace, but I ended up writing real-time code in assembler instead. PS love the use of "Feynman Lectures on Physics, boxed set" as a laptop riser!
To be clear, much power that Python is known for comes from the libraries that the community accumulated over time. The language itself is not as performant as any other lower-level languages (some python libraries are actually C/C++ binaries with a python wrapper for better performance). Python's strength as a language comes in flexible type system and syntax, making it easy to write some crazy data jugging in Python without dealing with a lot of conventions like other lower-level (or established) languages, thus people can spend time on the actual logic rather than typing semicolons or converting floating point numbers to integers.
Thank you for not having me type this up. Python is commonly used for data science purposes, but that doesn't mean it's the "best" tool for the job. Most all languages can do amazing things. Sometimes the right one is the one you know, or other times the one with the libraries. Other times you need a low level language to eek out the best performance.
I was going to comment this :) For example that image processing example from the beginning of the video would be horribly slow if implemented in pure Python.
Agreeing with most of what's said here, I've often heard python mentioned as the second best language for anything which makes it a very powerful language. One comment on python's performance. Because of the community support, packages like numpy, and pandas are quite fast if used smartly. Additionally using packages like Numba and their just in time compiler, python can be nearly as fast or faster then C code (hand crafted well optimized C code can still beat Numba but you can get huge performance gains just using Numba). murillogroupmsu.com/numba-versus-c/
Sure, but this does not change the fact that it makes sense to learn to code. Most programming languages today do not require in-depth knowledge of structured programming as was the case in the past. As you point out, the actual coding has become easier with, among other things, extensive use of libraries and a minimum of conventions. This in turn has also made coding more efficient in that one can spend much more time on the logic itself than on writing the correct syntax (as you point out).
Type systems are there to help prevent errors. Python's flexible type system means errors that could have been caught are not being caught. By errors, I mean errors that arise from things like using incorrect units, incorrect domains and other mathy errors. Type systems are there for you to encode all these kinds of mathematical rules as types so that they are checked at compile time. How many hundreds of millions of dollars have we lost because of "simple" things like the use of correct units and conversions? And how many bad results are there from people not understanding why they need to convert between floating point and integers? "The actual logic" is useless unless it is correct, and the time you spend on the "actual logic" would be significantly reduced if you learned how to use type systems properly to generate code that is correct by construction.
Thanks for this! Just the inspiration I need for another day learning Python. I did the Brilliant course & it was a good start, but only takes you so far. I followed with the excellent 'Python Crash Course' book by Eric Matthes. Now working through 'Automate the Boring Stuff in Python' by Al Sweigart which is also very good. Oh, the hours I could've saved over the years if I'd known this stuff before.
Learning how to code is as important as learning a second language nowadays! The great thing about coding (and learning a second language) is that the fundamental principles (algorithms / grammar) repeat and once you're proficient in one programming language, it's so much easier to learn others. :) I really think there's nothing more mind blowing than using a computer to convert analogue signals from sources such as the spin of protons into actual quantitative images! Also, nowadays there is sooo much awesome free content (Python is free) available on the interwebs! Happy coding everyone!
A thing most people don't realize is, that modelling, programming and algorithmic thinking is and always has been part of their daily life. Now that computers are ubiquitous and easy to learn programming langauges such as Python exsist, one can effectively practice and put those skills to use.
@@ArgoIo Python is the slow brother of C++. You trade errors is all and for some solutions you have better libraries. But you are ALWAYS slower. I would not hire a Python programmer if that is all they knew. I regularly find articles about how much faster it is to write python code and then I write the same code in C++ and find it is almost the same size. Like within 5 lines and those are declarations. The thing I then learn is that the person critiquing the C++ side of things can't code in C++. :) So obviously its faster in Python when you are a Python guy. I could prove that Python is way slower to code if I was the test subject! :)
@@buddysnackit1758 Get off your high horse. It's exactly those declarations which look daunting to any beginner. I do enjoy coding in C++, but I would never use it to explain an algorithm to ie. a family member.
@@ArgoIoTypical answer from someone who can't take their ideas being challenged. I'll let people judge if variable declarations are "hard". Another guy was talking about all those semi-colons. How much darned time you must save in Python by not typing them. He also said you waste time converting floats to integers. Funny stuff!
@@no_mnom HTML is a markup language - it looks at data within HTML tags. It doesn't really 'do' that much on its own and doesn't have if/else statements, so technically isn't a programming language.
@@josephcohen734 It’s “a type of star that pulsates radially, varying in both diameter and temperature and producing changes in brightness with a well-defined stable period and amplitude,” according to Wikipedia.
I'm retired now, but I used to LOVE learning code languages and cobbling together commands to take care of otherwise tedious analyses. I always found it challenging to know when to declare it "good enough" and get on with it. There was always a more clever, efficient, quick way to get from A to Z. One can waste gobs of time tweaking code. :-)
Shared this with my math-crazy daughter. She has taken Geometry and is now in Algebra II. In our schools, the very first introduction to formulas in science class is eigth grade, and she attended virtual python day camp this past summer. This was my chance to show her that math is fun, and here are real scientists putting all the foundations she has been learning recently to work at understanding the universe. No real knowledge of Fortran though, so always more to learn.
Thank you I needed this. I’m applying for PhD positions for Astrophysics and Cosmology rn, and other than my research looking for candidate ultra faint dwarf galaxies using Jupyter Notebooks, I’m super intimidated by code. I’ve heard from people in the field that we tend to take bits and pieces from other code to build our own… it’s just scary when we focus on classes in undergrad and are expected to teach ourselves how to code at the same time.
I'm a retired software engineer and this was a really good high-level description of what code is for. I programmed in 13 different languages in my career and after seeing this, I have decided to take a look at Python for some private system utility needs I have. Thanks for another excellent vlog!
I loved this video! Every week I confirmed that this is what I want to do the rest of my life with your videos and it amazed me that I already do 3 of the 5 things you mentioned so that means that im on the right row to become an astrophysicist, thank so much Dr Becky! P.S. Loved your sweater😊
I look for a video like this for so long, thank you very much, I´m a 17 yo chilean, and I wanna be an astrophysicist, I always wanted to know why and how a scientist use codes and how they actually work, the more I learn about this career the more I fall in love with it. Hope someday I can dedicate my life to science, I think I finally found the youtube channel that I was looking for.
I was a bit lost about the usages of coding for physics related matters until now. Thanks so much! I am a mechatronics/aerospace engineering student, really helped!
Yup. Though for most "new" codes C++ has become the standard, mainly for its object-oriented features. Fortran is now primarily the domain of "dinosaur codes", which were started decades ago and are so massive it would be unthinkable to rewrite them in a more modern language.
With close-to-metal languages, there really isn't anything about them that would make you pick one over the other or force you to switch once you picked one. Pretty much the only consideration is compatibility with work of your colleagues. That's why Fortran is alive and well in its niche of science. That's why C is alive and well in its niche of systems. That's why C++ is alive and well in niche of AAA gaming.
@@ToadalChaos An advantage Fortran has over C++ is that things like exponentiation and complex numbers are built into the language, instead of being handled by function calls. That can be significant in a large-enough problem.
So I did a physics and astronomy degree. Back when I did it all the maths libraries were FORTRAN. One of the projects was a colliding galaxy simulator. The systems were slow so it was small galaxies and took days to generate the animation. By the time I finished that degree I had learnt FORTRAN, C and Pascal. A few years later I ended up returning to uni, doing a masters in machine vision and becoming research assistant where as I was basically a coder. Now, I”m a tech lead in a embedded device consultancy.
I have been a techy nerd for over 45 years. I love coding and appreciate that you use Python for data analysis. Keep up the good work on these very interesting videos.
I just started to learn python by stacking many Fits images together in order to maximise the signal to noise ratio. I’m just an amateur astronomer, but hope to code something that helps me to be more conscious of the discovery we all read about every day and maybe catch a little asteroid waving us now and then. :) Thanks for sharing your experience with so much inspiring enthusiasm.
@Peter Mortensen I’m not using public data yet (except in the last period, I needed files to test my code and radio signals from pulsars seems pretty interesting for that purpose, but I know there are many other survey projects out there from exoplanets to galaxies). Till now I used Fit files collected by OnlineRemote telescopes. I focused on Near earth Asteroids just to perform some observations. There’s already Astrometrica to do most of the things an amateur may need and Find_orb to analyse residuals and their orbit.. but I feel python can open up new opportunities. Right now I’m more concentrated on techniques rather on a specific field of research (cross-matching objects with optical catalogues for example)
I am currently studying Geology at university and just got started learning Python, I am really excited to see all the possibilities that this language can offer.
I noticed the big box holding your laptop up with Feynman written on the side. Richard Feynman, another great communicator of science. Check out his lectures and talks. Especially, Los Alamos From Below. A true passionate genius, who was a gentleman and a wonderful human being who changed the face of physics. RIP Prof. Feynman.
As a Computer Scientist/Bioinformatician you can do these things in any language you like. The most important thing is what libraries are easy to use. Python is my main language in biology. It has lots of nice scientific libraries. But I could do any of the things I do in several languages. Python is super nice though, the other language for scientists is often R. You can find some really powerful, cutting edge statistics libraries and plotting libraries in R. Python is actually still behind R in this case. Also if you're doing huuuge dynamics, weather, or orbit simulations, the kind you would usually need a supercomputer for, you would probably use FORTRAN, C, or C++.
I have been writing code for science tasks for almost 40 years. First Pascal and Fortran then C and recently R. When I had to improve someone's Python code I called my son-in-law to ask him: "Have I got crazy or do they really use whitespace for formatting in Python?" For someone working long in C and C++, it is a heresy.
@@caw25sha I do. But the code I was supposed to improve has been formatted with a mixture of spaces and tabs with a different lengths than that used by my editor. I lost a lot of time before I realized what the problem is and corrected it replacing all tabs with the correct number of spaces. In C++ such mishap happens often and makes the code look ugly but it still compiles fine.
I have to agree about the semantically-significant whitespace. Badly-indented code can be a pain in other languages, but at least it doesn't affect the meaning of the code. And I have seen professional programmers produce randomly-indented code. And physicists produce not-indented-at-all code (not only in Fortran).
@@michaelsommers2356 we learned not to indent when punchcards were only 80 characters wide. Semantically meaningful whitespace broke my mind when i first encountered it.
I am an amateur visual astronomer and also physics enthusiast. Presently learning JavaScript,newbie in coding . Thanks very much for the video ... 👍👍 It opened my mind of coding applied in physics
Thanks for sharing 5 ways an astrophysicist's uses code. I've coded orbital mechanics (satellite control), image rectification for stereoscopictry, radio direction finding (interferometry) and more using about 9 different coding languages. How the giants of the past did physics without computers really causes admiration for the tenacity. Your encouraging call for new astrophysicist to become coders is spot on!
Small tip for all you programming learners out there: *Comment your own code.* Always. Everywhere. Well written code is usually easy and quick to read. But not as easy and quick as a short string at the top of the function. And if the code is a bit on the complicated side (which you should try to avoid), a comment can really help you (and others!) out.
Heresy! Real programmers don't need comments. Good code documents itself! (I must have been told that more than a dozen times during my time as the lead on various projects throughout the years. Of course, in reality, most coders just hate writing comments, and worse, keeping them up to date!)
@@EnglishMike One should only comment things that are not logical from the context. For example a hack to get around a problem with a library you're using.
I have been coding for over 30 years. I have written code with and without comments. The problem with comments is they can get out of sync with the code. So you have to read the code to find out if the comments are current. I go with self documenting code these days. Intention declaring method and variable names. Of course hacks are always a good time to document with comments. Especially when some code is counter intuitive.
As a developer myself I can only agree. Two sets of eyes see more than one and explaining to someone else how your code works (or is supposed to work) can very well help you realize what you could improve. Code reviews and pair programming are such useful tools for preventing and fixing bugs.
also, just talking to someone who knows what you're talking about can literally let you talk yourself into a solution... some talk to rubber duckies... I prefer a human with a little extra insight
@@scifino1 I'm not a fan of pair programming but apart from that agreed. Many hands make light work, many eyes make shallow bugs, but not every way of getting many hands onboard and many eyes looking works well for everyone.
@@MechanicaMenace to each their own. Obviously pair programming is a technique that isn't always feasible. At my firm we only use that in certain situations. For example when someone who is new to a certain framework could use help from someone with more experience in working with that framework.
Fortran still kicking. The king of science no one ever will dethrone. High five to the people who design it 70 years ago, if there's any survivor around. I'm still amazed on how well was it designed for the specific purpose. The first fortran release did a monte-carlo simulation of the code on compile time to find the better memory assignment strategy. Just a detail on how hardcore it is
As a particle physicist (who really loves this channel filling me in on the other side of physics, that I almost picked, so you know, thanks Becky!), I use code for pretty much the exact same things, swapping out image processing for something like triggers and particle track reconstruction.
To me, coding is like giving a constructive proof of some result, that way of thinking clear the path to write better and thinking better ways of coding something.
What a breath of fresh air! A dialogue between two scientists who know their stuff, are enthusiastic about their stuff, and know how to communicate their stuff to a lay-audience. Thanks to both of you!
Started studying a Master's in Space Science and Technology this year, with a focus on Astrophysics, and I knew Python was coming. I did some tutorials in my own time, some Udemy courses etc. But was I ready? I was not ready. The "buh-ding" noise of my code not working is seared into my eardrums. My desk is falling to bits under the onslaught of my frustrated fists. My software-savvy friends no doubt look at my pleading pathetic requests for help with no more pity, as I have annoyed them beyond their continued caring. Still really good fun though
Fast to program and iterate in, yeah. And the performance can be tuned up where needed as it's all just written in C/C++ in the end. But as her friend said in the video, they use FORTRAN for the really performance heavy stuff.
@@Invalid571 yes. The point is kind of lost unless you build the standard library from scratch. Python is used to call libraries from other languages. You don't do anything computationally intensive in python.
@@Invalid571 for example I could say on any compiled langue that "hehehe it is the compiler that does the work" or "hehehe the standard library does the work", but is really just splitting hairs and doesn't really make sense. You use cpp to do a thing it work. You use python to do a thing it works.
Technically, python is actually very bad at handling large arrays of data. However, you use modules like numpy, pandas and OpenCV to do this, which are written in C, which is muuuch faster than python. And even if you use numpy and the like, you need to reduce the amount of native python as much as possible to keep your code fast. Basic rule: Whenever possible, do not use for loops but numpy/pandas indexing instead! All the heavy lifting in your code should really be done in C, so in numpy. Numpy is mighty. Use it. And for gods sake, don't write your own data tables to textfiles with for loops (I have seen that in simulation code). Pandas is mighty. Use it. So python is basically... usable or at least more accessible C ^^'
Nicely stated. I have been a business dev for 20+ years and you did a nice job of giving an easily understandable way for people to understand how/why to deal with the basics of code.
In the early 1970s, I began a career as a computer programmer, and I was *very* good at it. BASIC, FORTRAN, COBOL, and to a certain degree assembly language, they all were my bailiwick. They were all linear languages, of course, but who knew anything could replace them? Well, in the 1980s came C, C+, and C++ (and Python), "object-oriented" languages, and I simply could not make the leap from the old to the new. I tried several times, but it was no go. I could handle & got my degree in multimedia languages like HTML & Javascript, but it was not enough. So my career as a computer programmer came to an end. But I started another career as a bus driver and loved it just as much. But kids these days are learning to code! Amazing.
@@DrBecky True but then BT come along and put a pickaxe through the cable and your internet is gone for a week. It happens more often than you think. Don't just rely on cloud back-ups, take some hard copies too. If it is important, secure it.
@@DrBecky That's true but I've heard my colleagues complaining that they lost their old code that I wonder if they subconsciously want the old code to vanish. After all it is sometimes easier to write it anew than to understand what exactly it was supposed to do.
Yes of course you are. I'm the only person who prefers LISP to any other programming language. I don't know why we are the way we are but it's definitely weird.
Leaning the library pandas in python changed my life. One line to import a .csv of data into a dataframe that I can manipulate is game changing. Pandas dataframes are essentially numpy arrays so they are directly convertible.
Pandas is cool. Astronomy standard data format is .fits though - it can handle both images and tables in one file, so thankfully the astropy module wrote up a way to handle those like pandas and it's a game changer
I am working as a research astronomer but then I quickly realized the need of coding in Astrophysics and I learned python and ML algorithms. Enjoying it to its fullest now.
It's lovely the way you manage to transmit enthusiasm along with information: that's a rare gift. Also good to hear FORTRAN being praised for its efficiency!
Dr. Becky. Enjoyed this discussion! As an atmospheric scientist, I have used Fortran to run complex, atmospheric dispersion models. As you may recall, Fortran was the primary language of NASA's space program throughout much of its early years. I didn't hear it mentioned in your discussion. Fortran has evolved A LOT, but now seems rarely taught much anymore. Seems as though Python has sort of supplanted it. But Fortran still "screams" speed and multi-processing capability. But, alas, it's fading in popularity, which has puzzled me, and also sort of makes me sad, because it really is an easy language--and less cryptic--even than python.
My love for space science is why I enrolled in a coding bootcamp, and I just got my Python certification too. I graduate May 28. Soooooo happy I found this video, I was wondering what language would be best for being an astrophysicist.
This is so interesting! I am a plain old software engineer, and I know firsthand it takes time to master the skills to write good software. I didn’t realize astrophysicists write their own code on top of the extensive skill set they already have in their field. Very impressive!
Hey Dr. Becky, I just stumbled upon your channel and find it both interesting and hits close to home. I took astrophysics as my major in my undergrad, planning to pursue grad school but have not found a scholarship yet. Watching your videos bring me back to my years as a student where we were usually engaged in discussion about astrophysics, from the science to technical aspect such as finding the best way to do something in python (most of the students use it). My field of interest is studying interstellar matter detected in stellar spectra to trace the Milky Way's large-scale structure. P.S.: Sorry for my bad English :')
As a cosmology student, it is nice to see that astrophysics has a similar methodology. For me, simulations in clusters is the hardest part of the job. Thanks for the video!
Love your videos..... Kinda gives a perspective for aspiring students who are basically driven for their love of the stars and separate out the ppl who hate the math, or say, coding.......
Every time I watch your video I'm amazed. The depth of your knowledge is unbelievable. I really hope to be as devoted as you are about science. You are an inspiration 💙💙
I studied physics and I went from university directly to a software company and I am pretty happy with it. I also think I have acquired a relatively good understanding of programming practices in my time in university where I used it daily - though I learned most of it in my spare time... I can totally support Becky when she says that you should learn to code if you are in science (and I can only add: do it even if you are not going into science - it is a universal tool to fix problems!)
I’m a Computer Scientist who actively works every day with Data Scientists; with our two points of view, we use Python to create Machine Learning models. It’s so much fun!
As a software engineer who uses a lot of code written by medical researchers - please don't just learn the basics! If you're going to publish your code, it's just as important as the text and figures of your paper. Comments, modularity, good variable and procedure names, and most importantly documentation of how to use the code is critical.
Dr. Smethurst, I think this is a great intro to how important software can be. A lot of engineers don't think of it this way, but I definitely think we should be making computers easy for everyone to program - so that writing good code is easy and you can focus on the interesting parts of your science!
One of the biggest aspects is to never assume that you'll even be able to understand what your own code is doing a year or two later. I've got code that I've been maintaining for literally the last 20 years. Excellent readability, commenting and documentation are key to not having to waste hours or even days when it comes to having to maintain the code we write. And key here is that writing the initial code is just the beginning of that code's life cycle.
If we can convince people to use meaningful variable names we'll have done a great service to all of mankind.
@@TraneFrancks I follow "if it's hard to write, it should be hard to read" and my 5 year old code still looks readable...
(This is a joke, don't take this seriously)
That one Haskell programmer that has hooked up his entire program in lamda functions with x y z.
@@MasthaX yeah but then the important thing is function names. Still comes down to naming in the end!
This is the kind of channel I like to watch to distract me from my day job: coding...
Lol
I wish that I could study everything with physics without requiring the money or the time....
The great courses plus, brilliant, various University programs that are free online...
@@jerryplayz101 i wanna do that too 😭😭😭
"Learn to code" is pretty good advice for anyone doing anything even remotely technical.
Or anything.
But most people know what coding means. I mean if your interested in astrophysics, you probably do. Seems so very basic. Personally, I'd wish she would talk in more detail on how to code to process an image.
Yup! Even if you're not coding at anywhere near a professional level, even the basics to get rid of drudgery can be a force multiplier.
Learn to code for your use in your job is a good thing. Become a (professional) programmer isn't all that great though, you basically need to learn all the jobs you do projects for. That being said though I think in most academia programming is at least on the curriculum may it be in just statistics or more technical aspects.
Learning to code is a democratizer.
I coined a nearly relevant saying: "Computers will always do exactly what you tell them to do, and if you're lucky, they'll also do what you want them to do."
I know this one as "Computers don't do what you want. They do what you tell them to."
Fellow software developer I used to work with was known to say 2 + 2 = 4 under favorable conditions.
Also known as SISO, Sh*t in, Sh*t out.
@@Betacak3 Of course I prefer my phrasing, but it's not surprising that variations of this sentiment exist. I am crestfallen that I'm not as original as I thought -- great minds think alike, after all (not that I would ever claim that I have a great mind).
Seems like you need a bit of luck for computers to do exactly what you tell them to do. This seems to have gotten worse with modern operating systems, but even back in the late 1970s I remember compiling the exact same program 2 times and getting different error message.
4:18 "Messy, fresh off the telescope images like this:" _Shows fuzzy blob_
4:23 "Into useful scientific images like this:" _Shows Eye of Sauron_
The underdog meme.
The amount of time I've spent on stack exchange for work is unreal. The best thing about coding is that 99.9% of anything you need to code has been coded before and shared online.
And I am so grateful for those who contribute to stack exchange 😂
This is so true. When I teach people to code, once they know if, else, for, while, functions and arrays, then I teach them that almost all other coding is looking it up. Usually, the only time I outright code is when I become so comfortable with a language that I already know the optimal solution. In fact, in the most recent data analysis code I wrote I included the weblink for each line of code could have been looked up so I can use it as a future example to show to people how coding actually works.
It is true also about R. Sometimes there are packages created specially for the very set of data you want to use.
@@arctic_haze You should check out Pandas. I used to do most of my plotting and statistical analysis in R, but Pandas made me finally convert to Python. That said, R's standardization of package documentation is very nice, and I still love "->" over "=".
I've been lucky enough not to have to go through any technical interviews for programming jobs, but if I had to, I suspect most of my answers would be: "I don't know that off hand, but give me a minute while I look on Stack Exchange..."
When I was an Astrophysics student, we were told the most likely career for someone with an undergraduate astrophysics degree was computer programmer. There was even a local engineering company that specifically recruited physics and astrophysics students as programmers because they approached problems differently from comp-sci students.
What are the differences ? Are they "better" than CS students ? Most astrophysics students are doing master and PhD , are they not ?
@@papaburger in my experience, as a tech lead who was a physicist, we tend to be more practical and less theoretical. Computer Science teaches the science of computing and software, it’s not a training course. Although I do know theory of operating systems and so on, I don’t actually care why something has a big O value of X, just which is algorithm is best for a situation. Also we tend to be building systems. I worked on gravitational wave detectors before moving to the tech industry.
As someone who is now a tech lead, it was for me.
That's a nice way of saying that the job title for someone working in astrophysics with only an undergraduate degree is "grad student".
I wish more scientists shared how much of their work life is coding. A lot of people think coding is for making apps and that's it.
This is perfectly timed, I started learning python about a week ago because I want to study physics/astrophysics at uni (I’m year 12 rn) 😊
Nice! Keep at it - I found it hard at first but eventually it all clicked and it max everything so much easier 🤗
I'm also learning python its a struggle tbh but also rewarding when you finally get the code to do what you want to do
Wait ur 12 years or in 12 grade?!
@@vihashah5975 year 12 means its his last year of high school
@@vihashah5975 age 16/17, 1st year of college in the UK.
Year 7-11 (age 11-16) high school, Year 12-13 (age 16-18) college/ sixth form, 18+ university
Thank you so much for this! I was confused between pursuing astrophysics and comp sci.(leaning more towards astro ofc) until I watched your day in the life vlog and I realised I could pursue astrophysics and get the best of both worlds! I would have never been able to make the decision if it wasnt for the videos you make! Your such an inspiration!! I hope I can study at oxford one day.(I like cambridge a lil more though😂)
Thanks Kiara! Glad I could help :) I'll forgive you if you go to the "other place" - haha!
Saaamee!!
As a CS coder person, your description of code was brilliant, "a language that both you and the computer understand."
This is perfect. You're writing something that has two very different audiences. A very dumb, pedantic but very fast savant - the compiler. Most people know that, but the other audience for code, and arguably the most important, are other people. Be it you six months later or someone else tomorrow. You have to communicate ideas to them. Comments are a crutch to that, but the code itself should do that.
Really well done video. Love it.
In other words, don’t bother commenting on the very low-level stuff that anyone who has used the same language recently should be able to figure out by reading it, but _do_ make comments of a more “high-level” nature? Is that correct?
Yes. Nowadays I'm more interested in readable code and decent commit messages than comments. I can tie commit messages in with git blame and other history commands.
I love seeing stuff from real astrophysicists working on simulations. I'm a programmer self-teaching astrophysics to make a live simulator, and these kinds of things keep me going.
I was using python and LaTeX for school as this notification popped up, really interesting topic!
Are you using python and LaTeX together or separately? I have never done so, but I heard it's possible to write LaTeX files from python. I have used LaTeX quite a bit over the last two decades but have no idea how python and LaTeX can be combined.
It's great to see that giant book, Feynman's Lectures on Physics, being put to good use as a laptop stand haha :D
Keep on coding and sciencing, Dr. Becky!
Haha! It’s the perfect height what can I say?!
Dyson The Feynman’s Lectures have been my prized possessions, but you can get a free version in MS Word format online.
@@dyson9422 but how would you use the Word version as a laptop stand!? :-P
@@Shadow81989 Transfer the doc file to your printer buffer, and set the laptop on the printer.
@@d.t.4523 that idea just made my day, so thank you! ;-)
At my first programming job I got to code in Assembler on the mainframe! I'm retired now but I still code, I find it relaxing.
Oof, you gave me a flashback. I did a lot of assembly back in the day myself. That's a rough rode to travel! Very intimate, though, it's just you and the processor, with you speaking its language, one level above raw 1's and 0's with no frills. I never did it on a mainframe, though. I'm guessing the instruction set is huge(?)
@@Videot99 you might enjoy this:
en.wikipedia.org/wiki/Supercomputer_architecture
Modern 'supercomputers' are actually clusters of untold thousands of relatively modest processors linked by fast data buses and wrapped in lots of control and cooling equipment.
@@Videot99 the instruction set was fairly simple, I've pasted a link to the student guide.
Did you have a load of macros available for the common tasks or did you have to write everything?
@@SlEasyTarget Interesting, thanks. I recently ran into an involuntary use of the networked clustering architecture via internet. I was running Adblock and noticed that my (6 times 2 core Intel) CPU usage would start climbing and get extremely high when I wasn't doing anything. After investigating I learned that Adblock was using people's idle computing power for cryptocurrency mining. Cute scheme! I switched to Ublock.
When your guest mentioned massive supercomputing calculations, I immediately knew that the implementation language was FORTRAN.
C or Assembly will also perform just as robustly. But that lady is a scientist and thinks like an engineer -- so FORTRAN it is.
@@gregf9160 it's mostly related to the fact that those code-bases and libraries they use literally started over half a _century_ ago; before C existed, and when assembly was much, much different
One of my favorite software bugs of all time is from FORTRAN. At one point, early in one of the compilers history the constants for the numerals 0-9 were actually just stored in memory like any other variable. So if you weren’t careful you could assign a value to the numeric (not so) “constant”. This means you could assign the value 3 to 1 and then forever after in your program 1+1 would equal 6.
I’m not sure but I think this is the origin of the phrase:
“2+2=5 for incredibly large values of 2.”
@@megan_alnico That is still true in SQL and PL/SQL today. You can redefine anything which isn't a reserved word.
@@gregf9160 These days with modern tools there’s no need for assembler (compilers are damn good at optimisation) but yes, C or FORTRAN. I haven’t coded it since I left uni, but I did leave knowing both languages.
Doing a PhD in CS and really looking forward to learning to code. Been doing it for a solid 10 years now.. look forward to figuring it out anyday now 😌
About ten years ago a friend asked me to help tutor him in FORTRAN as he was studying climatology in college. As a general computer programmer I’m quite rusty in that language, but we muddled through it. In principle so long as you understand what the capabilities of any computer language are, the rest is just making sure you are using the correct syntax to express your instructions.
Yay, my area of experience! Well coding in FORTRAN but haven't yet learnt Python. I first learnt FORTRAN at school back in the 1970s and my first job was going to be a simulation engineer in aerospace, but I ended up writing real-time code in assembler instead. PS love the use of "Feynman Lectures on Physics, boxed set" as a laptop riser!
To be clear, much power that Python is known for comes from the libraries that the community accumulated over time. The language itself is not as performant as any other lower-level languages (some python libraries are actually C/C++ binaries with a python wrapper for better performance). Python's strength as a language comes in flexible type system and syntax, making it easy to write some crazy data jugging in Python without dealing with a lot of conventions like other lower-level (or established) languages, thus people can spend time on the actual logic rather than typing semicolons or converting floating point numbers to integers.
Thank you for not having me type this up. Python is commonly used for data science purposes, but that doesn't mean it's the "best" tool for the job. Most all languages can do amazing things. Sometimes the right one is the one you know, or other times the one with the libraries. Other times you need a low level language to eek out the best performance.
I was going to comment this :) For example that image processing example from the beginning of the video would be horribly slow if implemented in pure Python.
Agreeing with most of what's said here, I've often heard python mentioned as the second best language for anything which makes it a very powerful language. One comment on python's performance. Because of the community support, packages like numpy, and pandas are quite fast if used smartly. Additionally using packages like Numba and their just in time compiler, python can be nearly as fast or faster then C code (hand crafted well optimized C code can still beat Numba but you can get huge performance gains just using Numba). murillogroupmsu.com/numba-versus-c/
Sure, but this does not change the fact that it makes sense to learn to code. Most programming languages today do not require in-depth knowledge of structured programming as was the case in the past. As you point out, the actual coding has become easier with, among other things, extensive use of libraries and a minimum of conventions. This in turn has also made coding more efficient in that one can spend much more time on the logic itself than on writing the correct syntax (as you point out).
Type systems are there to help prevent errors. Python's flexible type system means errors that could have been caught are not being caught. By errors, I mean errors that arise from things like using incorrect units, incorrect domains and other mathy errors.
Type systems are there for you to encode all these kinds of mathematical rules as types so that they are checked at compile time. How many hundreds of millions of dollars have we lost because of "simple" things like the use of correct units and conversions? And how many bad results are there from people not understanding why they need to convert between floating point and integers?
"The actual logic" is useless unless it is correct, and the time you spend on the "actual logic" would be significantly reduced if you learned how to use type systems properly to generate code that is correct by construction.
Thanks for this! Just the inspiration I need for another day learning Python. I did the Brilliant course & it was a good start, but only takes you so far. I followed with the excellent 'Python Crash Course' book by Eric Matthes. Now working through 'Automate the Boring Stuff in Python' by Al Sweigart which is also very good. Oh, the hours I could've saved over the years if I'd known this stuff before.
Learning how to code is as important as learning a second language nowadays! The great thing about coding (and learning a second language) is that the fundamental principles (algorithms / grammar) repeat and once you're proficient in one programming language, it's so much easier to learn others. :)
I really think there's nothing more mind blowing than using a computer to convert analogue signals from sources such as the spin of protons into actual quantitative images!
Also, nowadays there is sooo much awesome free content (Python is free) available on the interwebs!
Happy coding everyone!
A thing most people don't realize is, that modelling, programming and algorithmic thinking is and always has been part of their daily life. Now that computers are ubiquitous and easy to learn programming langauges such as Python exsist, one can effectively practice and put those skills to use.
@@ArgoIo Python is the slow brother of C++. You trade errors is all and for some solutions you have better libraries. But you are ALWAYS slower. I would not hire a Python programmer if that is all they knew. I regularly find articles about how much faster it is to write python code and then I write the same code in C++ and find it is almost the same size. Like within 5 lines and those are declarations. The thing I then learn is that the person critiquing the C++ side of things can't code in C++. :) So obviously its faster in Python when you are a Python guy. I could prove that Python is way slower to code if I was the test subject! :)
@@buddysnackit1758 Get off your high horse. It's exactly those declarations which look daunting to any beginner. I do enjoy coding in C++, but I would never use it to explain an algorithm to ie. a family member.
@@ArgoIoTypical answer from someone who can't take their ideas being challenged. I'll let people judge if variable declarations are "hard". Another guy was talking about all those semi-colons. How much darned time you must save in Python by not typing them. He also said you waste time converting floats to integers. Funny stuff!
print("Hello Universe!") ;-)
You young whippersnapper you! All the old timers know the real code is:
10 PRINT "Hello Universe!"
20 GOTO 10
@@EnglishMike In reality I'm more of a All the universe stuff goes inside here kind of guy :P
@@randylejeune 😮😮
#include
int main () {
std::cout
"... people us HTML and programming languages like..." you just won the nerds' hearts :D
Because HTML isn't a programming language?
@@no_mnom HTML is a markup language - it looks at data within HTML tags. It doesn't really 'do' that much on its own and doesn't have if/else statements, so technically isn't a programming language.
She had already won the nerds a long time ago.
JavaScript is barely a programming language lol
@@Danielbignuts So ... Apache Pig isn't a programming language?
"If I can't code it, I don't understand it." ~Professor Phil Moriarty
I think it was " If I can code it, I can understand it"
When coding a universe simulation, be sure to initialize all variables. An uninitialized Cepheid variable can crash the whole system!
Underrated comment
When you know someone's making a joke but you don't know what a cepheid variable is
@@josephcohen734
It’s “a type of star that pulsates radially, varying in both diameter and temperature and producing changes in brightness with a well-defined stable period and amplitude,” according to Wikipedia.
Are you certain the crash isn't a problem with your scope? ;-)
I'm retired now, but I used to LOVE learning code languages and cobbling together commands to take care of otherwise tedious analyses. I always found it challenging to know when to declare it "good enough" and get on with it. There was always a more clever, efficient, quick way to get from A to Z. One can waste gobs of time tweaking code. :-)
I do not use coding in any part of my current job. Playing with Python keeps my brain both clear and sharp on my own time.
Yep. The first 80% of the job takes the first 80% of your time and the last 20% of the job takes the other 80% of your time.
OK boomer. :)
Shared this with my math-crazy daughter. She has taken Geometry and is now in Algebra II. In our schools, the very first introduction to formulas in science class is eigth grade, and she attended virtual python day camp this past summer.
This was my chance to show her that math is fun, and here are real scientists putting all the foundations she has been learning recently to work at understanding the universe.
No real knowledge of Fortran though, so always more to learn.
Thank you I needed this. I’m applying for PhD positions for Astrophysics and Cosmology rn, and other than my research looking for candidate ultra faint dwarf galaxies using Jupyter Notebooks, I’m super intimidated by code. I’ve heard from people in the field that we tend to take bits and pieces from other code to build our own… it’s just scary when we focus on classes in undergrad and are expected to teach ourselves how to code at the same time.
You're one of the inspirations to become an Astrophysicist! It's very rare in Bangladesh but I hope to work under you someday!
I'm a retired software engineer and this was a really good high-level description of what code is for. I programmed in 13 different languages in my career and after seeing this, I have decided to take a look at Python for some private system utility needs I have. Thanks for another excellent vlog!
Thank you!
11:15 - and another person discovered the beauty of free software. Welcome to the Light side. ;)
@@barryomahony4983, I’m pretty sure you intended to reply in another thread.
@@mina86 Oops, yes. danger of trying to do 2 things at once.
Wow, FORTRAN -- that was my main language in 1978. Impressive it's still being used. Wonderful bringing her in on this one.
Heck, COBOL is still in active use…
I loved this video! Every week I confirmed that this is what I want to do the rest of my life with your videos and it amazed me that I already do 3 of the 5 things you mentioned so that means that im on the right row to become an astrophysicist, thank so much Dr Becky!
P.S. Loved your sweater😊
I look for a video like this for so long, thank you very much, I´m a 17 yo chilean, and I wanna be an astrophysicist, I always wanted to know why and how a scientist use codes and how they actually work, the more I learn about this career the more I fall in love with it. Hope someday I can dedicate my life to science, I think I finally found the youtube channel that I was looking for.
Glad I could help! And best of luck with all your studies - Chile is definitely the perfect place to become an astrophysicist
I was a bit lost about the usages of coding for physics related matters until now. Thanks so much!
I am a mechatronics/aerospace engineering student, really helped!
So they're still using Fortran, over 60 years after the language was introduced!
I believe that astlib and slalib are both written in fortran, and are widely used still today. I know :)
Yup. Though for most "new" codes C++ has become the standard, mainly for its object-oriented features. Fortran is now primarily the domain of "dinosaur codes", which were started decades ago and are so massive it would be unthinkable to rewrite them in a more modern language.
With close-to-metal languages, there really isn't anything about them that would make you pick one over the other or force you to switch once you picked one. Pretty much the only consideration is compatibility with work of your colleagues. That's why Fortran is alive and well in its niche of science. That's why C is alive and well in its niche of systems. That's why C++ is alive and well in niche of AAA gaming.
There used to be a joke that went, "I don't know what programming language will be used in fifty years, but I know it will be called 'Fortran'."
@@ToadalChaos An advantage Fortran has over C++ is that things like exponentiation and complex numbers are built into the language, instead of being handled by function calls. That can be significant in a large-enough problem.
Hi Dr. Becky, I absolutely love your parsaltogue joke I will have to reuse it.
So I did a physics and astronomy degree. Back when I did it all the maths libraries were FORTRAN. One of the projects was a colliding galaxy simulator. The systems were slow so it was small galaxies and took days to generate the animation. By the time I finished that degree I had learnt FORTRAN, C and Pascal. A few years later I ended up returning to uni, doing a masters in machine vision and becoming research assistant where as I was basically a coder. Now, I”m a tech lead in a embedded device consultancy.
I have been a techy nerd for over 45 years. I love coding and appreciate that you use Python for data analysis. Keep up the good work on these very interesting videos.
I just started to learn python by stacking many Fits images together in order to maximise the signal to noise ratio. I’m just an amateur astronomer, but hope to code something that helps me to be more conscious of the discovery we all read about every day and maybe catch a little asteroid waving us now and then. :) Thanks for sharing your experience with so much inspiring enthusiasm.
Check out the astropy library - it will be a lifesaver for you!
@Peter Mortensen I’m not using public data yet (except in the last period, I needed files to test my code and radio signals from pulsars seems pretty interesting for that purpose, but I know there are many other survey projects out there from exoplanets to galaxies). Till now I used Fit files collected by OnlineRemote telescopes. I focused on Near earth Asteroids just to perform some observations. There’s already Astrometrica to do most of the things an amateur may need and Find_orb to analyse residuals and their orbit.. but I feel python can open up new opportunities. Right now I’m more concentrated on techniques rather on a specific field of research (cross-matching objects with optical catalogues for example)
I am currently studying Geology at university and just got started learning Python, I am really excited to see all the possibilities that this language can offer.
I noticed the big box holding your laptop up with Feynman written on the side. Richard Feynman, another great communicator of science. Check out his lectures and talks. Especially, Los Alamos From Below. A true passionate genius, who was a gentleman and a wonderful human being who changed the face of physics. RIP Prof. Feynman.
As a Computer Scientist/Bioinformatician you can do these things in any language you like. The most important thing is what libraries are easy to use. Python is my main language in biology. It has lots of nice scientific libraries. But I could do any of the things I do in several languages. Python is super nice though, the other language for scientists is often R. You can find some really powerful, cutting edge statistics libraries and plotting libraries in R. Python is actually still behind R in this case. Also if you're doing huuuge dynamics, weather, or orbit simulations, the kind you would usually need a supercomputer for, you would probably use FORTRAN, C, or C++.
Good point - astronomy and astrophysics are all python - astropy is such an incredible resource for us all.
@@DrBecky Yep the equivalent for Bioinformatics it probably BioPython.
I have been writing code for science tasks for almost 40 years. First Pascal and Fortran then C and recently R. When I had to improve someone's Python code I called my son-in-law to ask him: "Have I got crazy or do they really use whitespace for formatting in Python?" For someone working long in C and C++, it is a heresy.
But surely you indented blocks of code in C? Formatting in C and Python is pretty similar, just with and without the { and }.
@@caw25sha I do. But the code I was supposed to improve has been formatted with a mixture of spaces and tabs with a different lengths than that used by my editor. I lost a lot of time before I realized what the problem is and corrected it replacing all tabs with the correct number of spaces. In C++ such mishap happens often and makes the code look ugly but it still compiles fine.
I have to agree about the semantically-significant whitespace. Badly-indented code can be a pain in other languages, but at least it doesn't affect the meaning of the code. And I have seen professional programmers produce randomly-indented code. And physicists produce not-indented-at-all code (not only in Fortran).
@@michaelsommers2356 we learned not to indent when punchcards were only 80 characters wide. Semantically meaningful whitespace broke my mind when i first encountered it.
@@RickBoat Yeah, but there was no excuse for not indenting when we moved away from punch cards.
I am a computer programmer professionally meself. But I prefer the term "computer whisperer" :D
I am an amateur visual astronomer and also physics enthusiast. Presently learning JavaScript,newbie in coding . Thanks very much for the video ... 👍👍 It opened my mind of coding applied in physics
Thanks for sharing 5 ways an astrophysicist's uses code. I've coded orbital mechanics (satellite control), image rectification for stereoscopictry, radio direction finding (interferometry) and more using about 9 different coding languages. How the giants of the past did physics without computers really causes admiration for the tenacity. Your encouraging call for new astrophysicist to become coders is spot on!
Small tip for all you programming learners out there: *Comment your own code.* Always. Everywhere.
Well written code is usually easy and quick to read. But not as easy and quick as a short string at the top of the function. And if the code is a bit on the complicated side (which you should try to avoid), a comment can really help you (and others!) out.
Heresy! Real programmers don't need comments. Good code documents itself!
(I must have been told that more than a dozen times during my time as the lead on various projects throughout the years. Of course, in reality, most coders just hate writing comments, and worse, keeping them up to date!)
@@EnglishMike
One should only comment things that are not logical from the context. For example a hack to get around a problem with a library you're using.
I have been coding for over 30 years. I have written code with and without comments. The problem with comments is they can get out of sync with the code. So you have to read the code to find out if the comments are current. I go with self documenting code these days. Intention declaring method and variable names. Of course hacks are always a good time to document with comments. Especially when some code is counter intuitive.
as a software engineer I would say find a good friend who knows how to code :D
As a developer myself I can only agree. Two sets of eyes see more than one and explaining to someone else how your code works (or is supposed to work) can very well help you realize what you could improve. Code reviews and pair programming are such useful tools for preventing and fixing bugs.
also, just talking to someone who knows what you're talking about can literally let you talk yourself into a solution... some talk to rubber duckies... I prefer a human with a little extra insight
YES
@@scifino1 I'm not a fan of pair programming but apart from that agreed. Many hands make light work, many eyes make shallow bugs, but not every way of getting many hands onboard and many eyes looking works well for everyone.
@@MechanicaMenace to each their own. Obviously pair programming is a technique that isn't always feasible. At my firm we only use that in certain situations. For example when someone who is new to a certain framework could use help from someone with more experience in working with that framework.
Fortran still kicking. The king of science no one ever will dethrone. High five to the people who design it 70 years ago, if there's any survivor around. I'm still amazed on how well was it designed for the specific purpose. The first fortran release did a monte-carlo simulation of the code on compile time to find the better memory assignment strategy. Just a detail on how hardcore it is
As a particle physicist (who really loves this channel filling me in on the other side of physics, that I almost picked, so you know, thanks Becky!), I use code for pretty much the exact same things, swapping out image processing for something like triggers and particle track reconstruction.
Me : * sees Becky's notification*
Me : Yesss !!!
Thanks Becky. It's very interesting 👁️👁️ I love it
To me, coding is like giving a constructive proof of some result, that way of thinking clear the path to write better and thinking better ways of coding something.
What a breath of fresh air! A dialogue between two scientists who know their stuff, are enthusiastic about their stuff, and know how to communicate their stuff to a lay-audience. Thanks to both of you!
I am a math, computer guy and would like to say that your presentation is excellent.
Started studying a Master's in Space Science and Technology this year, with a focus on Astrophysics, and I knew Python was coming. I did some tutorials in my own time, some Udemy courses etc. But was I ready? I was not ready. The "buh-ding" noise of my code not working is seared into my eardrums. My desk is falling to bits under the onslaught of my frustrated fists. My software-savvy friends no doubt look at my pleading pathetic requests for help with no more pity, as I have annoyed them beyond their continued caring.
Still really good fun though
“Hot, young, big stars.” Like Dr. Becky?
This is an awesome episode! I'm 53yo and just started to learn Python to build a working Star Trek tricorder. It's never too late and it's fun!
Ambitious project. I learnt it just to get away from bloody Excel!,,
Coding and database, Dr. Becky talked about my field! So cool!
Wants: a language that's fast.
Suggests: python
Me: Hold up python for speed? LOL!
Fast to program and iterate in, yeah. And the performance can be tuned up where needed as it's all just written in C/C++ in the end. But as her friend said in the video, they use FORTRAN for the really performance heavy stuff.
NUMPY can process data on a single core faster than most other programming languages since it calls assembly written to be hyper effcent.
@@Almost3331
So assembly does the work by your own admission. :)
@@Invalid571 yes. The point is kind of lost unless you build the standard library from scratch. Python is used to call libraries from other languages. You don't do anything computationally intensive in python.
@@Invalid571 for example I could say on any compiled langue that "hehehe it is the compiler that does the work" or "hehehe the standard library does the work", but is really just splitting hairs and doesn't really make sense. You use cpp to do a thing it work. You use python to do a thing it works.
Oh my. I had no idea Dr. Becky was so in to hot young galaxies 😲
Wow, I’ve been looking for your explanation for years. Thank you.
as someone doing computer science engineering but actually wanted to do astrophysics- good to see I'm still connected :,)
Technically, python is actually very bad at handling large arrays of data. However, you use modules like numpy, pandas and OpenCV to do this, which are written in C, which is muuuch faster than python.
And even if you use numpy and the like, you need to reduce the amount of native python as much as possible to keep your code fast.
Basic rule: Whenever possible, do not use for loops but numpy/pandas indexing instead!
All the heavy lifting in your code should really be done in C, so in numpy. Numpy is mighty. Use it.
And for gods sake, don't write your own data tables to textfiles with for loops (I have seen that in simulation code). Pandas is mighty. Use it.
So python is basically... usable or at least more accessible C ^^'
The command "import antigravity" is an Easter egg in Python.
Nicely stated. I have been a business dev for 20+ years and you did a nice job of giving an easily understandable way for people to understand how/why to deal with the basics of code.
In the early 1970s, I began a career as a computer programmer, and I was *very* good at it. BASIC, FORTRAN, COBOL, and to a certain degree assembly language, they all were my bailiwick. They were all linear languages, of course, but who knew anything could replace them? Well, in the 1980s came C, C+, and C++ (and Python), "object-oriented" languages, and I simply could not make the leap from the old to the new. I tried several times, but it was no go. I could handle & got my degree in multimedia languages like HTML & Javascript, but it was not enough. So my career as a computer programmer came to an end. But I started another career as a bus driver and loved it just as much. But kids these days are learning to code! Amazing.
Let me guess before I watch: writing it. debugging it, compiling it, running it and finally losing it on a failed disk drive?
Version control is utilized. Failed hardware is less likely than human error.
@@ShainAndrews Nowadays, yes. But I started in the times when you had to hope the diskette with code is still readable.
Losing it?! We have GitHub and versioning these days!
@@DrBecky True but then BT come along and put a pickaxe through the cable and your internet is gone for a week. It happens more often than you think.
Don't just rely on cloud back-ups, take some hard copies too. If it is important, secure it.
@@DrBecky That's true but I've heard my colleagues complaining that they lost their old code that I wonder if they subconsciously want the old code to vanish. After all it is sometimes easier to write it anew than to understand what exactly it was supposed to do.
When she said "efficiency" I was expecting her to use assembly language :D
I've been waiting for something like this!
Thanks a bunch!
Good to hear that Fortran is still in use.
Am I the only person who likes C\C++ more than python?
Yes. Yes, you are. ;)
Perhaps, perhaps not, but you're almost certainly the only C/C++ programmer who uses the wrong slash between them.
Yes of course you are. I'm the only person who prefers LISP to any other programming language. I don't know why we are the way we are but it's definitely weird.
@@clickrick Wrong? Or just rebellious? :P
Java and C++ :)
Does anyone else think it's cool that Dr. Becky is using a Richard Feynman lecture series to prop up her Mac?
Leaning the library pandas in python changed my life. One line to import a .csv of data into a dataframe that I can manipulate is game changing. Pandas dataframes are essentially numpy arrays so they are directly convertible.
Pandas is cool. Astronomy standard data format is .fits though - it can handle both images and tables in one file, so thankfully the astropy module wrote up a way to handle those like pandas and it's a game changer
Fantastic, Becky! I teach CS and have shared your video with my students on how coding skills can be applied in natural sciences.
I did not expect illicit affairs to be the bloopers song haha. forgot you were a swiftie so it caught me off-guard
"You fit your model, then off you toddle, and do some science!" -Dr. Becky
PURE JOY 😂 , I think i WILL toddle with my fitted model!
Love this! ❤️ Hope there are more contents about astrophysics and coding to come. 💫
I am working as a research astronomer but then I quickly realized the need of coding in Astrophysics and I learned python and ML algorithms. Enjoying it to its fullest now.
It's lovely the way you manage to transmit enthusiasm along with information: that's a rare gift. Also good to hear FORTRAN being praised for its efficiency!
Dr. Becky, you are a total genius.
Thank you so much @Dr. Becky
I was really in search of such video
Who are these 13 people who disliked the video
You explained it so well🤘🏻
Dr. Becky. Enjoyed this discussion! As an atmospheric scientist, I have used Fortran to run complex, atmospheric dispersion models. As you may recall, Fortran was the primary language of NASA's space program throughout much of its early years. I didn't hear it mentioned in your discussion. Fortran has evolved A LOT, but now seems rarely taught much anymore. Seems as though Python has sort of supplanted it. But Fortran still "screams" speed and multi-processing capability. But, alas, it's fading in popularity, which has puzzled me, and also sort of makes me sad, because it really is an easy language--and less cryptic--even than python.
My love for space science is why I enrolled in a coding bootcamp, and I just got my Python certification too. I graduate May 28. Soooooo happy I found this video, I was wondering what language would be best for being an astrophysicist.
well we all know Cody is the best coder...he is made from code
This is so interesting! I am a plain old software engineer, and I know firsthand it takes time to master the skills to write good software. I didn’t realize astrophysicists write their own code on top of the extensive skill set they already have in their field. Very impressive!
Hey Dr. Becky, I just stumbled upon your channel and find it both interesting and hits close to home. I took astrophysics as my major in my undergrad, planning to pursue grad school but have not found a scholarship yet. Watching your videos bring me back to my years as a student where we were usually engaged in discussion about astrophysics, from the science to technical aspect such as finding the best way to do something in python (most of the students use it). My field of interest is studying interstellar matter detected in stellar spectra to trace the Milky Way's large-scale structure.
P.S.: Sorry for my bad English :')
As a cosmology student, it is nice to see that astrophysics has a similar methodology. For me, simulations in clusters is the hardest part of the job. Thanks for the video!
Absolutely top notch video!! Would love deep dives on astropy stuff and going from raw images to science images on this channel, Becky!
Love your videos.....
Kinda gives a perspective for aspiring students who are basically driven for their love of the stars and separate out the ppl who hate the math, or say, coding.......
Every time I watch your video I'm amazed. The depth of your knowledge is unbelievable. I really hope to be as devoted as you are about science. You are an inspiration 💙💙
great stuff Dr. Becky! great to hear about coding from quite possibly the coolest people slinging it around!
One of the most useful of all of your very informative uploads
Wonderfully informative. I first learned Fortran in 1969, but never thought it might still be used. My last languages were machine code and assembler.
I love your VIDEOS BECKY!! Thank you for them!
Just discovered your channel TODAY! So glad I did!
I studied physics and I went from university directly to a software company and I am pretty happy with it. I also think I have acquired a relatively good understanding of programming practices in my time in university where I used it daily - though I learned most of it in my spare time...
I can totally support Becky when she says that you should learn to code if you are in science (and I can only add: do it even if you are not going into science - it is a universal tool to fix problems!)
I’m a Computer Scientist who actively works every day with Data Scientists; with our two points of view, we use Python to create Machine Learning models. It’s so much fun!
This is amazing video. I had no idea astrophysicists use code to this extent.