Programmatic Web Hosting and Programming Styles

Episode Notes

On this episode, Michael discusses the following topics.

Challenge

Swift

struct ContentView: View {
// Declare the array with elements to display in the List
let names = [“John”, “Jane”, “Alice”, “Bob”]
var body: some View {
// Use the List view to create rows for each element in the array
List(names, id: .self) { name in
Text(name) }
.navigationTitle(“Names”)
}
}
}

Python

hash Declare the list with elements to display
names = [“John”, “Jane”, “Alice”, “Bob”]
Hash Iterate through the list and print each name
for name in names:
print(name)

Discord Bot

import discord
from discord.ext import commands
client = discord.Client(intents=discord.Intents.default())
@client.event async def on_voice_state_update(member, before, after):
if before.channel is None and after.channel is not None:
channel = client.get_channel(123456789) hash Replace with the ID of the text channel where you want to post the message
message = f'{member.mention} has joined {after.channel.name}’
await channel.send(message) hash Replace ‘YOUR_BOT_TOKEN’ with your actual bot token client.run(‘YOUR_BOT_TOKEN’)

Topics

  • Pick a good Web hosting provider with good tech support. Use Michael’s DreamHost Referral.
  • We also discuss the different styles of programing from Object Oriented programming to event driven programming, and declarative programming.

Transcript

Web Hosting And Programming Styles

Michael Doise
Programmatic

Edit TranscriptRemove HighlightingAdd Audio FileExport…?

[0:00] Music. 

[0:19] And hello everybody, welcome back to Programatic. My name is Michael Doeys and it’s good to be back with you all this wonderful week. 
We recorded a day late because there was just a lot to get done to publish the last episode. 
We had a lot of code that we had in the results. 
So something that we thought about was if you could basically take your code that you have for a solution and throw it through chat GPT and tell it to remove, the extra text or the punctuation, could it do that? 
And it does not seem to do it. 

[1:02] It wants to keep it all as code and try to remove, it’s trying to be smarter than we are and remove the punctuation from the actual string. 
So like if there’s a print statement, it would go in and remove the parentheses or punctuation and put them as words in the strings. 
Now, one thing that I did get it to do, is I said replace all semicolons in this code with the word semicolon, and it did that. 
So that was helpful for JavaScript. Unfortunately, that’s the only language we do our examples in that are using semicolons. 
So yeah, that didn’t help. When I tried to do parentheses, I was like, nope, not gonna do it, won’t do it. 
So that was not very effective there. 
So unfortunately, I still have to do those by hand. So it takes a good little while to do that. 

[1:51] It takes an editing project that really shouldn’t take very long, quite a bit longer to convert all of that to text, then throw it through 11 labs, and then have that converted to audio, and then put that into the tracks. 
But I think it really sounds great, And I haven’t gotten any feedback so far, so I’m curious what people think of how we’re doing our code snippets in the episodes. 
And in fact, I will have. 
Snippet in here today. And I will talk about that after we do our solutions. Our last challenge was to use an array, to build an app or a, console application that could have a list of names or items and. 

[2:43] Basically the results that will be in the full version, sorry YouTube folks, that will be in the full version of the podcast will be of SwiftUI and, of other possible UI frameworks showing a list. 
I think I’m going to mainly focus on SwiftUI, so we may not have a JavaScript. 
Or if we do have a JavaScript in Python version, it might be console applications because it’s easy to generate a SwiftUI list because it’s so short. 
But making a whole Python UI that has a list would be a little more difficult in a JavaScript application. 
So we’re gonna probably just have one programming solution for this lesson or this challenge result this time. 
So maybe two showing a Swift or Python array. 

[3:40] So we’ll see, we’ll see what we get. So the other snippet, so well, let me back up. 
So here’s gonna be the results of that challenge. 
We have the Swift. 
Struct content view colon view left curly bracket. Slash slash declare the array with elements to display in the list. 
Let names equals left square bracket John comma Jane comma Alice comma Bob right square bracket. 
Var body colon some view left curly bracket. 
Slash slash use the list view to create rows for each element in the array. 
List left parenthesis names. Comma ID colon backslash dot self right parenthesis. 
Left curly bracket name in text left parenthesis name right parenthesis right curly bracket dot navigation title left parenthesis names right parenthesis right curly bracket right curly bracket,and now we have our python result hash declare the list with elements to display names equals left square bracket John comma Jane comma Alice comma Bob right square bracket Hash iterate through the list and print each name. 
For name and names colon, indent level one. 
Print left parenthesis, name right parenthesis. 

[4:56] So we’ll have one of each and we may have to make some edits and things like that based on what we have. 
So I want to thank 11 Labs for providing that again. 
And also I want to talk about one of my projects that I just worked on, which I’m going to use 11 Labs and have it read the project because it’s very short. 

[5:19] And what that is is a Python script that is a Discord bot. And you’ll be able to find this in GitHub. 
I have to make a few edits to make that ready to go. 
But you’ll find it in GitHub on my repos that will send an alert to a channel when somebody joins voice. 
So I’m going to have the Python voice that we use from 11 labs. 
Go ahead and read that source snippet right here. 
Import Discord. From discord.ext import commands. Client equals discord.client left parenthesis. 
Intents equals discord.intents.default left parenthesis, right parenthesis, right parenthesis. 
At sign, client.event. 
Async def on underscore voice, underscore state, underscore update, left parenthesis member comma, before comma, after right parenthesis colon. 
Indent level one. If before dot channel is none, and after dot channel is not, none colon indent level two, channel equals client.get underscore channel left parenthesis, 123456789 right parenthesis. 

[6:25] Hash replace with the ID of the text channel where you want to post the message. 
Indent level two, message equals F single, quote, left curly bracket member, dot mention, right curly bracket has joined left curly bracket after dot channel, dot name, right curly bracket, single quote. 
Indent level two, await channel dot send left parenthesis message, right parenthesis. 
Hash replace, your underscore BOOT underscore token with your actual bot token. 
Client.run left parenthesis, single quote, your underscore bot underscore token, single quote, right parenthesis. 

[7:01] All right, so that’s really exciting stuff. And it’s working now. 
And this brings up one of the first topic I’m gonna go through today. 
And that’s how to pick a good web host. 
I think I’ve, people that know me have known that I’ve gone through the list of web hosts. 
I’ve gone from Bluehost to NameHero to, let’s see, so many others. 
I’ve even built my own through Linode using cPanel and DigitalOcean using cPanel and all kinds of others. 
And I’ve never really been happy with any of them that use cPanel. 
I’ve tried DreamHost and I used a small VPS there, but it didn’t have enough RAM, so I thought it wasn’t working. 
So, how do you pick the right web host for your website? Whether you’re programming your website as a Node.js application, or it’s a WordPress site, Drupal site, any of these things, it’s important to know how to pick a good web host. 

[8:05] So, there’s a few factors here. It depends on, one, how your website’s going to scale. 
Is it going to be a small website that you and just a few people are going to use? 
Or will it be a bigger website that everybody will be like e-commerce website, all those kind of things, right? 
I use cPanel because that’s what I always knew to be the best, right? 
It’s what has always worked for me and I don’t know of any other, I never knew of any other panel that would really provide what I needed to do. 
And so that’s why I’ve always used it. 
I’ve never used Plesk, I’ve never used all of those things, but I know for some people it works really, really well. 
So those things are, you know, some things that people use that I’ve never messed with. 
I went back to DreamHost because I know a lot of people use it and it’s fantastic. 
I’ve set up a faster VPS and everything works so much better, no RAM issues, no CPU problems. 
It just works well. And then I got to playing with some of the enhanced virtual private server, VPS features. 

[9:20] And I determined that one of the neat things about it is you do have shell access. I logged in through SSH and it’s fantastic. You can install applications. I put the Discord bot on a folder outside of the iAccessibility.net folder and I ran a I set it up and saved it there and then I set up what you can set up cron jobs inside the DreamHost panel. 
It is so fantastically easy. 
And I was able to set this discord bot up and it runs on server start. 
I just told my server to restart and Hey, the discord bots running. 
It’s just that easy. You know, the, the bot doesn’t do anything. 
It doesn’t take up much memory. 

[10:08] So it’s very nice. You know, the customization that you have on a place like DreamHost. 
And one of the aspects of cPanel that is a pain, if you want to use Node.js or Python with Django, which is one of their web services, Flask is another, if you want to use those on cPanel or others, you have to set up what’s called Passenger. 
And that’s not the easiest thing to do. You have to know where to do it. 
And in DreamHost, it’s just a checkbox that you go and find. 
So, you know, if you want a VPS with DreamHost, it’s gonna give you the most support for what you’re trying to do. 
They do have shared hosting as well, and that’s for like smaller websites, but you can scale your sites with the VPS or have multiple websites and manage them from one place, and that’s fantastic. 

[11:00] They also set up multiple, like each individual account has its own user and it’s not cPanel, so it’s not as easy for that account to get hacked as it is on cPanel. So another thing is cPanel is now enforcing a user limit. 
So I don’t know that I could recommend that based on, you know, if you want 30 websites, you know, you could do that on cPanel with like certain number of users, but it’s more difficult. 
With DreamHost, it’s just that easy. So I highly recommend checking out DreamHost. 
There’s other resources out there. 
So just pick the one that works best for you. 
And one thing that is important when picking a web host is technical support. 
If something goes wrong, because inevitably, it’s not a matter of if something goes wrong, but when something goes wrong, can you fix it? 
Do you know how to fix it? 
And will the people that are at technical support be there to support you or do they not know their job? 
When I was working with my last hosting provider, they did not know how to do, I tried to do something, it broke email, they didn’t know how to fix it. 
Because they didn’t understand what they needed to do. So. 

[12:15] I have to recommend that you go with a place, and DreamHost has been a good place for me, for technical support. 
If I have a question or an issue, they’re on chat always ready to help. 
They’ve always understood my questions. 
Keep those things in mind when you’re looking for a place to put your website, especially if you’re putting a WordPress website up, it’s important to really, Find a place that’s gonna be a good home and that’s secure. That is my spiel about, finding a good web host because I feel like that’s important, you know, you could be building a project and. 

[12:56] You’re looking for a place to put the website for the project like you’re building an app and you need a, Place to host that app a website. That’s a good place to do it. I, Will put myreferral link in the show notes, so be on the lookout for that. 
All right, so on to the topic that I told you guys that we’d be talking about in the last episode. 
It’s really interesting because we’ve talked about different programming languages interpreted and compiled, and so, you know, a lot of podcasts you could just dip your toes in no matter what what episode, but I highly recommend that you listen to all of our episodes. 
And I know that’s like a lot of time, but I hope these are fun and engaging. 
So I would recommend that you listen to our last one about interpreted and compiled languages, because this kind of goes from that. And this is about programming styles, right? 
What are the different styles of programming out there and which one will work for what you’re trying to do? 
And if you’re in iOS land, we have two big frameworks. 
We have UIKit on the Mac, we have AppKit, and now we have SwiftUI, which kind of combines both of those into one. 

[14:20] Well, it combines UIKit, AppKit, and WatchKit, and all those things into one programming paradigm. 
And SwiftUI is using something that a lot of people are not familiar with, and that’s called declarative programming. 
And so what is declarative programming? What is and what are the other ones out there? 
You know, a lot of people are very used, much used to object-oriented programming. 
And, you know, when you build iOS apps, you’re using object-oriented programming and event-driven programming. 
So I’m using a bunch of terms, declarative, object-oriented, event-driven. 
There’s functional programming, all these other styles. 
Today, we’re gonna focus mainly on the ones that relate to building apps with UIKit and SwiftUI. 

[15:22] And that’s three main types. And that’s declarative programming for SwiftUI, event-driven programming and object-oriented programming for UIKit. 

[15:37] I stick with these because these are my wheelhouse. This is the areas of development that I’ve worked with the most. 
But I’d be curious to hear other people’s talk. What do you use with C-sharp and, different UI elements in programming for building Windows applications? 
I know React and things like that use declarative as well. How is that different? 
I think we need to have a whole episode at some point on the JavaScript libraries out there, Svelte, React, React Native, what is all that? 
And we’ll do that, but I think we’re kind of doing more fundamentals and things like that here for now. 
So SwiftUI is declarative and then we have UIKit, which uses the other methods. 

[16:29] Object-oriented programming is where you have objects that have properties and methods or functions basically. 
So, my name is Michael. I’m an instance of a human, which is an object, also known as a class. 
And I have properties like skin color, I would say hair color, but I don’t have any hair, so that doesn’t really work. 
I have skin color, eye color. 
There’s things that define me. I have hands with five fingers, and I have functions or methods like walk, talk, eat, sleep. 
Those are all methods. And when we. 

[17:19] Look at all of our classes, you know, we have tables, like, and I’m not talking about like a table on the web, I’m talking about a table that we sit at and eat. 
A table has its own properties, it has legs, number of legs, right, and then we have instances of the table, right. 
So you, going back to humans, you’re an instance of the human class, but you have, you’re an instance of that, but you have your own methods and values. 
So when we build an application in UIKit, we create a new instance of a view controller, for example. 
So like if I want to show a screen with certain items on it, I create an instance of the view controller class and override different functions and methods that it has and set my own properties on that instance. 
So it’s an instance of the view controller, but it’s not the original class, if that makes sense. 
So that’s object-oriented programming on a very, very high level. 

[18:24] When we talk about declarative programming, though, it’s a little different. 
Declarative programming, and I’m very new to this, so if one of you guys that are experts hear this and you’re like, no, no, Michael, that’s totally wrong, please call me out and say, yeah, no, man, that’s wrong. 
Declarative programming, as I see it, is programming where you’re writing out your user interface. 

[18:53] By declaring all possible states. 
So, for example, as an example, I could write a text, which is a label, with some static text, it will never change. 

[19:08] But I could create a text label with a variable that is a state variable. 
So the variable will look at what’s in it, and then the text field will change based on the contents of that. 
So if I have a image and I change the image after tapping a button, I’m not making a new image or I’m not changing the property on the image that I’ve already created. 
It basically redraws the image very quickly with the new thing, with the new image inside. 
So it’s looking at all possible states and conditions at create time instead of you telling it at certain times to do things. 
The term for this is also the, for UIKit, when this happens, it’s called event-driven programming. 
And that means that buttons and other UI elements in our application change based on events. 
If I click the button, it will do this, right? 
So that’s the big difference between declarative and event-driven and object-oriented. 
With declarative, I’m saying, here is this text field or this button, and here’s what it will do. 

[20:34] This is this button, text field or label or button, and this is what it will do, no matter what. 
And so we’re declaring how this stuff works when we declare the item at create time. 
So if I have a, if I’m loading data from the web, then I’m already going to say, if there’s no data, show this, if there’s data, do this. 
And so it already knows how it should display no matter the conditions. 
So that’s why it’s declarative. we’re declaring how this thing should be. 
Now, I think a lot of people are very used to object-oriented and event-driven programming. 
And it’s very difficult to change how you look at these things. 
So I really am a big fan of learning all of these. 
But I would pick one and start with it and then learn the other before you really go into another thing. 

[21:39] If that makes sense. So if you’re picking declarative, go with that. 
If you’re picking functional programming, go with that. If you’re picking event-driven and object-oriented programming, go with that and learn those things before you learn something else. 
So that’s my big talk on that. And it’s very interesting. So, you know, a lot of languages support multiple programming styles. 
Swift can support declarative through structs, and it can support functional through closures and other things, but it also supports…