Skip to content

Commit

Permalink
convert and use always webp
Browse files Browse the repository at this point in the history
  • Loading branch information
AngeloChecked committed Oct 4, 2024
1 parent bab4789 commit 93781a6
Show file tree
Hide file tree
Showing 137 changed files with 107 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const philosophicalRamblingsAboutEcologyProgrammingLanguagesAndOOPNotJava
],
date: "2024-04-13T13:00:00.000Z",
thumbnail: {
src: "/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/toomanyspiderman.small.png",
src: "/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/toomanyspiderman.small.webp",
},
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![too many oop languages](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/toomanyspiderman.png)
![too many oop languages](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/toomanyspiderman.webp)

## Premise

Expand Down Expand Up @@ -27,7 +27,7 @@ When I start thinking about "the evolution of programming languages," my mind
sails, travels, surpasses the sky, and crosses space... then a planet appears, a
planet of strange creatures...

![Programming Languages Logos](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/languages_logo.png)
![Programming Languages Logos](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/languages_logo.webp)

This topic sparks my imagination. I ponder the vague similarities between PLs,
ecology, [food chain](https://en.wikipedia.org/wiki/Food_chain), and
Expand Down Expand Up @@ -70,7 +70,7 @@ shaping our software concepts. At this juncture, solving a particular use case
forces us to use a specific PL, which can sometimes lead us into what resembles
an [echo chamber](https://en.wikipedia.org/wiki/Echo_chamber_(media)).

![echo chambers in programming](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/chamber.png)
![echo chambers in programming](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/chamber.webp)

**Why did you start playing a particular instrument?**

Expand All @@ -88,7 +88,7 @@ languages, you might find the following resources useful:

## Object-oriented programming is not so obvious!

![oop influences](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/oopinfluence.png)
![oop influences](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/oopinfluence.webp)

Today, OOP is one of the most fanatical taboos in my small programming
experience.
Expand Down Expand Up @@ -343,7 +343,7 @@ class Father {

class Child {
has Father $.father handles <do-fizz>;

method do-buzz {
self.do-fizz;
say "different";
Expand Down Expand Up @@ -394,7 +394,7 @@ either.

### Guidelines for Addressing Entropy and Power

![coupling and cohesion](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/couplingcohesion.png)
![coupling and cohesion](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/couplingcohesion.webp)

[GRASP](https://en.wikipedia.org/wiki/GRASP_(object-oriented_design)),
[SOLID](https://en.wikipedia.org/wiki/SOLID),
Expand Down Expand Up @@ -498,7 +498,7 @@ approach poses a dilemma for the

### ok

![object good part](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/objects_good_part.png)
![object good part](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/objects_good_part.webp)

I'm arguing that OOP is not as obvious. If I haven't convinced you try with:

Expand All @@ -510,7 +510,7 @@ I'm arguing that OOP is not as obvious. If I haven't convinced you try with:

## Functional programming is not so obvious, either!

![fp languages influence](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/langfamilyFP.png)
![fp languages influence](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/langfamilyFP.webp)

### Programming languages are experiments

Expand Down Expand Up @@ -538,7 +538,7 @@ while its principles act to circumvent issues originating from OOP itself.

<a href="https://www.youtube.com/watch?v=srQt1NAHYC0">

![scott wlaschin about fp desing patterns](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/functional_design_patterns_scott_wlashchin.png)
![scott wlaschin about fp desing patterns](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/functional_design_patterns_scott_wlashchin.webp)
</a>

I have mixed feelings about this statement and agree that OOP isn't so obvious
Expand All @@ -550,7 +550,7 @@ many of these guidelines remain super valuable!

<a href="https://twitter.com/ID_AA_Carmack/status/989951283900514304">

![jose valim about polymorphism](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/josevalim_about_polymorphism.png)
![jose valim about polymorphism](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/josevalim_about_polymorphism.webp)
</a>

### Functional Programming! what?
Expand Down Expand Up @@ -649,7 +649,7 @@ pretty inevitable.

<a href="https://twitter.com/ID_AA_Carmack/status/989951283900514304">

![Jhon Carmack about tools](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/johon_carmack_about_tooling.png)
![Jhon Carmack about tools](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/johon_carmack_about_tooling.webp)
</a>

In the end, what matters most is agreeing on what works for us and making
Expand All @@ -665,7 +665,7 @@ unnecessary solutions.

<a href="https://twitter.com/isaac_abraham/status/1417122528607227906">

![years of programming and complexity](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/compexity_and_years_of_programming.png)
![years of programming and complexity](/img/philosophical_ramblings_about_ecology_programming_languages_and_OOP_not_java/compexity_and_years_of_programming.webp)
</a>

[The perfect programming language doesn't exist](https://www.youtube.com/watch?v=yiiDFRs62lQ),
Expand Down Expand Up @@ -701,14 +701,14 @@ Programming Languages Evolution:
- Band family trees: https://www.reddit.com/r/ClassicRock/comments/wtkumq/the_yardbirds_family_tree_how_all_these_bands_are
- A Brief, Incomplete, and Mostly Wrong History of Programming Languages: http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html
- Sketchpad: A Man-Machine Graphical Communication System: http://www.bitsavers.org/pdf/mit/tx-2/Sketchpad_TR296_Jan63.pdf
- Towards a conceptual history of programming languages - Types: http://www.cs.unibo.it/~martini/TALKS/martini-LIP.pdf
- Towards a conceptual history of programming languages - Types: http://www.cs.unibo.it/~martini/TALKS/martini-LIP.pdf
- The Next 700 Programming Language: https://www.cs.cmu.edu/~crary/819-f09/Landin66.pdf
- Guido van Rossum about biological systems metaphor of languages: https://youtu.be/-DVyjdw4t9I?t=1528
- Programming languages genealogical tree: https://github.com/stereobooster/programming-languages-genealogical-tree?tab=readme-ov-file
- Genealogical tree of programming languages by wikipedia: https://upload.wikimedia.org/wikipedia/commons/2/25/Genealogical_tree_of_programming_languages.svg
- A History of Programming Languages for 2 Voices(David Nolen and Michael Bernstein): https://www.youtube.com/watch?v=J3C79CDqeW4
- Dictionary of Programming Languages: http://cgibin.erols.com/ziring/cgi-bin/cep/cep.pl
Object Oriented Programming:
- A Solution to the Square-Rectangle Problem: https://aip.vse.cz/pdfs/aip/2016/01/03.pdf
- Object-Oriented Thinking in the Data-Centric World: https://www.schibsted.pl/blog/object-oriented-thinking-in-the-data-centric-world/
Expand Down Expand Up @@ -744,22 +744,22 @@ Object Oriented Programming:
- People Don’t Understand OOP - https://blog.sigma-star.io/2024/01/people-dont-understand-oop/
- Why is Object-Oriented Programming Bad? https://ovid.github.io/articles/why-is-object-oriented-programming-bad.html
- Object-Oriented Programming is Bad: https://www.youtube.com/watch?v=QM1iUe6IofM
- Is Inheritance That Evil?: https://thevaluable.dev/guide-inheritance-oop/
- Is Inheritance That Evil?: https://thevaluable.dev/guide-inheritance-oop/
Functional Programming:
- Functional Design Patterns - Scott Wlaschin: https://www.youtube.com/watch?v=srQt1NAHYC0&t=251s
- Functional Design Patterns - Scott Wlaschin: https://www.youtube.com/watch?v=srQt1NAHYC0&t=251s
- OOP vs Typeclasses - Ideology: https://alexn.org/blog/2022/05/13/oop-vs-type-classes-part-1-ideology/
- 8 months of OCaml after 8 years of Haskell in production: https://dev.to/chshersh/8-months-of-ocaml-after-8-years-of-haskell-in-production-h96
- The essence of functional programming by Richard Feldman: https://www.youtube.com/watch?v=l0ruvPCQh9I
- The Roc Programming Language with Richard Feldman (and what FP is) - https://adspthepodcast.com/2023/11/24/Episode-157.html
- Why Isn't Functional Programming the Norm? – Richard Feldman: https://www.youtube.com/watch?v=QyJZzq0v7Z4
- Are Design Patterns Missing Language Features: https://wiki.c2.com/?AreDesignPatternsMissingLanguageFeatures
- Are Design Patterns Missing Language Features: https://wiki.c2.com/?AreDesignPatternsMissingLanguageFeatures
Other:
- The Rust I Wanted Had No Future - https://graydon2.dreamwidth.org/307291.html
- A decade of developing a programming language: https://yorickpeterse.com/articles/a-decade-of-developing-a-programming-language/
- The Mess We Are n: https://www.youtube.com/watch?v=lKXe3HUG2l4&t=1925s
- Is Software Engineering Still an Oxymoron? • Alan Kay: https://www.youtube.com/watch?v=D43PlUr1x_E
- A decade of developing a programming language: https://yorickpeterse.com/articles/a-decade-of-developing-a-programming-language/
- The Mess We Are n: https://www.youtube.com/watch?v=lKXe3HUG2l4&t=1925s
- Is Software Engineering Still an Oxymoron? • Alan Kay: https://www.youtube.com/watch?v=D43PlUr1x_E
- Features of a dream programming language: https://magnemg.eu/features-of-a-dream-programming-language-3rd-draft
- The World's Most Maintainable Programming Language: http://lambda-the-ultimate.org/node/1483#comment-17093
- The Perfect Programming Language: https://www.youtube.com/watch?v=yiiDFRs62lQ
Expand Down
5 changes: 3 additions & 2 deletions blog/resize-img/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
image = { version = "0.24.7", features = ["webp-encoder"]}
regex = "1.10.2"
image = { version = "0.25.2"}
regex = "1.11.0"
webp = "0.3.0"
15 changes: 15 additions & 0 deletions blog/resize-img/src/img_to_webp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use image::{DynamicImage, EncodableLayout, ImageReader};
use std::fs::File;
use std::io::Write;
use std::path::Path;
use webp::{Encoder, WebPMemory};

pub fn image_to_webp(file_path_png: &Path, file_path_webp: &Path) -> Option<()> {
let image = ImageReader::open(file_path_png).unwrap();
let image: DynamicImage = image.with_guessed_format().unwrap().decode().unwrap();
let encoder: Encoder = Encoder::from_image(&image).unwrap();
let encoded_webp: WebPMemory = encoder.encode(65f32);
let mut webp_image = File::create(&file_path_webp).unwrap();
webp_image.write_all(encoded_webp.as_bytes()).unwrap();
Some(())
}
15 changes: 15 additions & 0 deletions blog/resize-img/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use std::{
path::{Path, PathBuf},
};

mod img_to_webp;

fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 1 {
Expand All @@ -26,6 +28,19 @@ fn main() {
};

for file in file_paths {
let mut file = file;
if file.extension().map_or(false, |ext| {
["png".to_string(), "jpg".to_string(), "jpeg".to_string()]
.contains(&ext.to_str().unwrap().to_string())
}) {
let filename_original_image = file.file_stem().unwrap().to_str().unwrap();
let webp_file_path = file.with_file_name(format!("{filename_original_image}.webp"));
if !webp_file_path.exists() {
img_to_webp::image_to_webp(&file, &webp_file_path);
file = webp_file_path;
}
}

let Ok(img) = image::open(&file) else {
continue;
};
Expand Down
Binary file modified blog/resize-img/test.large.webp
Binary file not shown.
Binary file modified blog/resize-img/test.medium.webp
Binary file not shown.
Binary file modified blog/resize-img/test.small.webp
Binary file not shown.
Binary file added blog/resize-img/test.tiny.webp
Binary file not shown.
Binary file added blog/resize-img/test2.large.webp
Binary file not shown.
Binary file added blog/resize-img/test2.medium.webp
Binary file not shown.
Binary file added blog/resize-img/test2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blog/resize-img/test2.small.webp
Binary file not shown.
Binary file added blog/resize-img/test2.tiny.webp
Binary file not shown.
Binary file added blog/resize-img/test2.webp
Binary file not shown.
53 changes: 53 additions & 0 deletions blog/static.tsqauzYE.bck
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { StaticServerRouter } from "./main.ts";
import { traverseFilesFlat } from "./utils/utils.ts";
import { Buffer } from "node:buffer";

export class StaticFiles {
constructor(
private staticServerRouter: StaticServerRouter,
private buildPath: string,
) {}
async build() {
try {
await Deno.remove(this.buildPath, { recursive: true });
} catch {
console.log("dist folder not found")
}
for (const route of this.staticServerRouter) {
if (route.type === "static") {
const files = await traverseFilesFlat(route.folder);
for (const file of files) {
if (route.condition(file)) {
const folder = getFolderFromPath(file);
const targetPosition = this.buildPath + file;
console.log({ log: `creating: '${targetPosition}'` });
await Deno.mkdir(this.buildPath + folder, { recursive: true });
await Deno.copyFile(route.folder + file, targetPosition);
}
}
}
if (route.type === "generate") {
const targetPathFileName = this.buildPath + route.relativeFileNamePath;
console.log({ log: `creating: '${targetPathFileName}'` });
const data = new Uint8Array(Buffer.from(route.content()));
await Deno.writeFile(targetPathFileName, data);
}
if (route.type === "html") {
const fileName = route.relativeWebsitePath.endsWith(".html")
? ""
: "index.html";
const targetPathFileName =
this.buildPath + route.relativeWebsitePath + fileName;
const folder = getFolderFromPath(targetPathFileName);
console.log({ log: `creating: '${targetPathFileName}'` });
await Deno.mkdir(folder, { recursive: true });
const data = new Uint8Array(Buffer.from(route.content()));
await Deno.writeFile(targetPathFileName, data);
}
}
}
}

function getFolderFromPath(file: string) {
return file.split("/").slice(undefined, -1).join("/");
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.

0 comments on commit 93781a6

Please sign in to comment.