Programmatic Interpreted and Compiled Languages

Episode Notes

On this episode of the podcast, Michael discusses the differences. between interpreted and Compiled programming languages.

Challenge results from episode 2.

Swift

// Ask for the user’s name and age
print(“What is your name?”)
let name = readLine() ?? “”
print(“What is your age?”)
let ageString = readLine() ?? “”
let age = Int(ageString) ?? 0

// Print a statement based on the user’s age
if age < 0 {
print("Invalid age!")
} else {
print("(name), you are a minor.")
}

JavaScript

// Ask for the user’s name and age
let name = prompt(“What is your name?”);
let ageString = prompt(“What is your age?”);
let age = parseInt(ageString);

// Print a statement based on the user’s age
if (age < 0) {
console.log("Invalid age!");
} else if (age < 18) {
console.log(name + ", you are a minor."); }
else {
console.log(name + ", you are an adult.");
}

Python

Number Sign Ask for the user’s name and age
name = input(“What is your name? “)
ageString = input(“What is your age? “)
age = int(ageString)

Print a statement based on the user’s age

if age < 0:
print("Invalid age!")
elif age < 18:
print(name + ", you are a minor.")
else:
print(name + ", you are an adult.")

Machine Transcript

Programmatic 3 Interpreted And Compiled Languages 3:11:23 10 43 Am

Edit TranscriptRemove HighlightingAdd Audio FileExport…?

[0:00] Music. 

[0:09] All right, hi everyone. Welcome to another episode of the Programmatic Podcast. 
My name is Michael Dois, and while we’re on episode three of the show, really exciting stuff, and I’m glad that we’re back. 
This is really a great show, and we’re going to do even more great episodes. 
I have a treat for you guys today, so I’m very excited to be here. 
We wanna start off today with our typical challenge results. 

[0:36] So last time I asked you guys to create a program that would let you get input and use a conditional based on that input. 
So like if you’re you know you ask for an age or whatever you do something based on that variable. 
So as we did last time we’re going to have 11 labs go ahead and read the different languages. 
So first up we have the Swift. 
Slash, slash, ask for the user’s name and age. 

[1:11] Print left parentheses, double quote, what is your name? Question mark, double quote, right parentheses. 
Let name equals read line left parentheses, right parentheses, question mark, question mark, double quote, double quote. 
Print, left parentheses, double quote, what is your age? Question mark, double quote, right parentheses. 
Let age string equals read line left parenthesis. Question mark, question mark, double quote, double quote, let age equals int, left parenthesis, age string, right parenthesis, question mark, question mark, zero, slash slash, print a statement based on the user’s age. 
If age is less than zero, left curly brace, print left parenthesis, double quote, invalid age. 
Exclamation mark, double quote, right parenthesis. Right curly brace, else if age is less than 18, left curly brace, print left parenthesis, Double quote backslash left parenthesis name, right parenthesis, comma. 
You are a minor. 
Double quote right parenthesis right curly brace. Else left curly brace print left parenthesis double quote backslash left parenthesis name, comma name. You are an adult. 

[2:16] Double-quote right parenthesis write curly brace javascript slash slash ask for the user’s name and age let name equals prompt left parenthesis double quote what is your name double quote right parenthesis semicolon let age string equals prompt left parenthesis double quote what is your age double quote right parenthesis semicolon let age equals parsant left parenthesis age string right parenthesis semi colon slash slash print a statement based on the user’s age if left parentheses age is less than zero right parenthesis left curly brace console dot log left parenthesis double quote invalid age double quote right parenthesis semi colon right curly brace else if left parenthesis age is less than 18 right parenthesis left curly brace console dot log left parenthesis name plus double quote comma, you are a minor, double quote right parenthesis, semi colon, right curly brace. 
Else, left curly brace, console dot log, left parenthesis name plus double quote comma, You are an adult. Double quote write parenthesis. Semicolon, write curly brace. 

[3:27] And Python. Hash. Ask for the user’s name and age. 
Name equals input, left parenthesis, double quote, what is your name, double quote, right parenthesis. 
Age string equals input, left parenthesis, double quote, what is your age, double quote, right parenthesis. 
Age equals int left parenthesis, age string, right parenthesis. 
Hash print a statement based on the user’s age. If age is less than zero colon, indent level one, print left parenthesis, double quote, invalid age, double quote, right parenthesis. 
Elif age is less than 18 colon. Indent level one, print left parenthesis, name plus double quote, comma, you are a minor, double quote, right parenthesis. 
Else, indent level one, print left parenthesis, name plus double quote, comma, you are an adult, double quote, right parenthesis. 
All right, thanks 11 Labs for providing these voices to us to use for this. 
It’s been very interesting working with the 11 Labs website as they require, it requires you to use punctuation to, you know, spell out the punctuation to get everything written correctly. 

[4:44] So that’s kind of crazy just spelling every parentheses, left parentheses, all of that out. 
And something that Taylor told me to try to do is to take all of the code in ChatGPT and tell it to spell out all of the punctuation in the code. 

[5:02] And I thought that was a brilliant idea. So I wanted to mention that here. 
So whenever I put the results on episode four’s video or audio and for, well, I guess for the podcast, the audio, you guys will be the first to see how that works. 
So I’m pretty excited to see if that works well or not. So I’ll report back then. 
OK, so we have a great topic today that I thought was very interesting, and I wanted to talk to you all about today. 
And that is the difference between an interpreted programming language and a compiled programming language. 
And believe it or not, there are some of those that are mixed. 
And so it’s quite interesting. 

[5:50] So what is an interpreted language? An interpreted language is a programming language that is similar to JavaScript, Python, PHP, Perl, several of these others that will, that execute code line by line. 
They interpret what is written from the top down in each file. 
So the code is interpreted at runtime. 
So some people think that a lot of these languages are slower because all of the code is read from the top down and it has to go line by line and through the conditions to process all of that information. 
This is true. I mean, it really can slow things down depending on how many lines of code you have. 
Whereas compiled code is all converted to machine code binary and it’s all, you know, the code is presented in machine code at once. 
So the computer can read through the code much faster and process the information quicker than what it could with interpreted languages. 

[7:11] For example, if I’m writing a program in Python, I can use the Python interpreter to see what I’m doing before I do it. 

[7:23] So I can use the Python interpreter to write several lines of code before I even put it in my program. 
And when you run your code, you’re even running it with the Python interpreter. 
So it’s quite interesting to think about the differences between these languages, whereas like Swift, you know, I’m compiling that into machine code. 
But Swift also can be ran interpreted. So like Swift Playgrounds is an example of this, where it kind of interprets what you’re doing. 

[7:57] And I guess it’s kind of similar to how Java does the JVM, where it has the Java Virtual Machine, where it converts it to, I guess it’s called bit code, byte code. 
I’m not sure the term, but it converts it and then runs it in the Java Virtual Machine. 
So it’s kind of partway interpreted. 
So, you know, there’s always efficiency things there. You know, I feel like interpreted languages are much easier to learn than a lot of the compiled languages. 
But that’s not always true. But I do think that the compiled languages are a little more inflexible, I guess, on how things work. 
Swift is an exception to that, Kotlin, but those are both derivatives of their previous languages. 
So Swift is kind of a derivative of Objective-C. It runs on top of that, or Kotlin runs on top of Java. It runs in the Java virtual machine. 

[9:02] So it’s kind of interesting when you think about how these languages work and the speed performance that comes with that for each language. 
You know, the one advantage Python has is it can work with machine-native languages. 
So for example, if I build an app in WXPython, it’s actually using C libraries that are compiled, to actually make that work. 
Whereas JavaScript uses plugins that talk to native code. 

[9:38] Like in Cordova and other things, and NativeScript and React Native, but it’s still using JavaScript to do all that. 
So a lot of the code is still in JavaScript. 
So it’s very interesting how there’s such a difference on that. 
We’re gonna take a second here. I’m going to look up the… I have a chat GPT going. 
And in that, I had it tell me several languages that are interpreted and several that are compiled. 
So interpreted languages would be Python, Ruby, JavaScript, PHP, Perl, Lua, R, and Shell scripting, languages such as Bash Shell scripting and things like that. Some compiled languages are C, C++, Java, Swift, Objective-C, Rust, Go, Fortran, Pascal. 

[10:39] And one called Ada that I’ve never heard of. That’s all from ChatGPT. 

[10:45] And there are several languages that can be considered across that line because Java can be interpreted based on different things. 
So it really just depends on what you’re trying to do. And there’s also, you can compile.NET to native code and things like that. 
So there’s a lot of options that you have. So it’s really interesting to think about, when you pick a programming language, it’s very essential when you’re starting a project, what language you pick, because that will determine how you code for that project. 
So if you’re building Python, What is that going to be used for? 
If you’re using JavaScript, what’s that going to be used for? 
Will it be fast enough? Will it be efficient enough as an interpreted language? 
Or will it be too complicated as a compiled language? 
So those are all things that you have to consider when you’re starting to pick your language for your project. 
And I think all of those things are essential when you’re starting from scratch while building something. 
It also is kind of where you should decide where you’re going to learn when you start programming, right? 
Because if you just start and pick a language, you’re gonna go down a certain path and you can use the fundamentals to learn other languages. 

[12:14] But you’re typically gonna stay with the fundamentals of the language that you’ve learned. 
And so if you start with scripting, you’re gonna learn scripting for the most part. 
So. 

[12:24] You know it you just have to decide what’s the most most efficient thing for you when you start your your journey and learning to code and even as you get better you know you’re going to figure out what works best for you and things like that. 

[12:44] I guess I’d love to hear people’s feedback from chat if you’re in chat or what’s your feedback about that if you’re, you know, trying to or if you’re listening to the podcast afterwardsbecause I think that all of these things are, you know, very good topics and I think that they would make a good discussion. 
Do you prefer compiled languages or interpreted languages or do you still not know and want more clarification. All of that’s good knowledge, you know, for me to have so I can know what we should talk about on the podcast. I would like to go ahead and move on to our challenge of this episode and we’re going to make it a little more, we’re going to make it a littlemore advanced, I guess. 
And that is, if you are building an app, or you’re building a website, or even a console app, see if you can use a for loop. 
Make a list of items or an array and go through those items with that for loop. 

[13:55] And print all of them out on the screen, whether it be in an app, a list, or whatever it is. 
And I’ll show some examples of how to do that with SwiftUI. Yes, I’ll include that on this. 
How to do that on the console with JavaScript and in Python. 
So really cool stuff on the next challenge. 
And I think that will actually kind of be the topic for next time, talking about declarative and the different types of programming. 
So like declarative, what you have in SwiftUI and React Native and others compared to object-oriented programming, which is what you use in UIKit, and functional programming. 
I think it’d be good to talk about all those things. 
I know that there is a term for the UIKit style of development. 
I need to figure out what that is. If somebody knows, right in, right into the podcast. 
And you can email me at mikedowys.icloud.com if you’d like to leave that feedback. 
Again, it’s been really great doing this podcast, so I’m excited to bring it back for another week. We also now have a website, programaticpod.com
You could also find us on our hashtag on Mastodon and Twitter. 

[15:16] Just look for the hashtag hash programatic pod. 
I was really excited to get that when nobody else had that hashtag so nobody searched for nobody has used it so really excited about that and so it’s the same as our domain and the same as it is on the. 

[15:38] On the social networks. So really exciting news on that front. So we’ll be back with another episode next week. 
And maybe this next one will be a longer episode. We’ll see. But I have a feeling, you know, with all of the things that we’ve talked about, all of the information that will be in the assignment solutions from 11 Labs, it’s going to still turn out to be a pretty good lengthy episode. 
Episode. So, you know, again, we’d like to get your feedback. What do you think of the show? 
What would you like us to cover? And how can we make this better? And are there topics you would like us to talk about? And I would love to do a question and answer session as well during the show. So come to chat with your messages, with your questions, and we’ll put them up here. 
And, you know, it’s just great getting to talk to you guys and tell your friends, even if they’re they’re not in programming, tell them. 
Because I think the more we can get people interested and involved, the more we can grow this podcast into a community. 
And I think that’s always a good thing to spread awareness about programming. 
So… 

[16:50] Music. 

Transcript