Different types of Programming

Jeremy Keith

14-Mar-2024

To Blog!
Jeremy Keith

 

About Jeremy

Jeremy Keith is a man of many talents and large intellect. He focusses mostly on the ways people create websites and why they do what they do.
He is a website builder, book writer, podcast host and event speaker. Currently he works for Clearleft.

 


 

Declarative Design

The topic Jeremy talked about was the different types of programming. He compared it to music. for example:

 

Programming

Programming languages can be divided in 2 types.

 


 

Imperative programming

Imperative programming works with step by step instructions. You need a good understanding of the code to work with it. Here is an example of the logic of imperative programming.

  1. create an array of items
  2. Loop through each item
  3. Test if a condition is true
  4. Return the result

Imperative programming is a lot harder compared to declarative programming, but it does come with a lot more options. They are strict so your life is easier, for example in debugging it shows you where the problem is.

 

Declarative Programming

With declarative Programming you need to specify the outcome you want in simple language. For example some SQL:

 

This is way simpler to do but also comes with some limitations. This way works for almost everyone but cannot be used to be as specific as imperative programming.

Declaratie languages are forgiving making it easier to learn and friendlier. but dont give you as much power.

 


 

What we use

In our study we mostly use Html, CSS and Javascript. Jeremy explained to us what types these languages are.

 

Mindset

Even in a declarative language you can have an imperative mindset, and also the other way around.

“JavaScript should only do what only JavaScript can do”

 

The question Jemery asked himself and others was: Why do people use javascript when it can be done with html

 

Usability

 

Giving up some control for usability isnt a bad thing. For example:

Using this on your whole page can make a good looking responsive website.

/* Good: */
font-size: calc(0.5rem + 0.666vw);

/* Better: */
font-size: clamp(1rem, 0.5 + 0.666vw, 1.5rem);

We design the big and the small viewport sizes, The computer does the middle part.

Calc()
Clamp()
min() and max()
fit-content()
min-content and max-content()

“Be the browsers mentor, not it’s micromanager”

Jeremy also gave us a site to look at. It shows the best practices: utopia.fyi

 

declarative > imperative ?

Is declarative better than imperative? Well that depends on a few things:

 

Thinking:

There are 2 ways people think:

Css has grown significantly. It works very well with a declarative mindset

 

Reflection

The lecture Jeremy gave was at the beginning a little boring because i didn't see what he was trying to say. But the longer it went on the more i understood. When he started talking about how the different mindsets work in the workfield it really sparked my interest. He knew what it was like to work for a company that had a different mindset to his. When he was talking about declarative vs imperative thinking i also thought about it myself. I see myself as more of an imperative thinker. I like to take my thoughts and divide them up into their parts.

 

For my selfimprovement

The things i will be using from this lecture are: