I've completed "Gear Ratios" - Day 3 - Advent of Code 2023
I used OCaml 🐫 for this one.
[Part 1 Solution] [Part 2 Solution]
I used OCaml 🐫 for this one.
[Part 1 Solution] [Part 2 Solution]
🔥2👏1
Frectonz
I've completed "Gear Ratios" - Day 3 - Advent of Code 2023 I used OCaml 🐫 for this one. [Part 1 Solution] [Part 2 Solution]
|> is the bestevery language should have some way of composing functions by passing the output of one function as an input to another.
Resources for learning a Functional Programing Language
Elm
https://guide.elm-lang.org/
OCaml
https://dev.realworldocaml.org/
Haskell
http://learnyouahaskell.com/chapters
Elm
https://guide.elm-lang.org/
OCaml
https://dev.realworldocaml.org/
Haskell
http://learnyouahaskell.com/chapters
👍5
Forwarded from KiNFiSH Farms
https://www.youtube.com/watch?v=iSmkqocn0oQ what is your guys think of this @frectonz
YouTube
Simon Peyton Jones - Haskell is useless
Simon Peyton Jones talking about the future of programming languages
KiNFiSH Farms
https://www.youtube.com/watch?v=iSmkqocn0oQ what is your guys think of this @frectonz
The video shows a bunch of language designers discussing their craft and talking about the tradeoffs various languages make.
The video is not meant to be a damnation of Haskell despite the click-bait title "Haskell is useless".
The definition of "use" Simon is talking about here, is actually being able to perform side effects, which one can define as modifying state outside of your program or depending on state outside your program.
Examples of side effects are IO operations, like
- Reading and writing to disk
- Opening network connections and making requests
and also things like random number generation, which make functions non deterministic.
Haskell is considered "useless" in this video because it doesn't allow you to make this side effect operations, because it's trying to be fully deterministic. The realization the peeps are talking about is that actually side effects are the whole point people write programs for, like you wanna make some request to server and show the response or you wanna read data from a file and do some computation on it, and Haskell by disallowing those things, it has made itself "useless"
But that's not really right in the current situation, because Haskell does allow you to do side effects but they do have their own structure of how one handles side effects which are called monads.
And btw Simon is one of the people that actually created Haskell.
And another note
Rust is actually the result of C/C++ folks trying to move closer to the Nirvana land he described in the video.
PS: I am not really a haskell guy, the last time I wrote haskell, is probably more than 2 years ago. I just thought I would share my views since you mentioned me.
The video is not meant to be a damnation of Haskell despite the click-bait title "Haskell is useless".
The definition of "use" Simon is talking about here, is actually being able to perform side effects, which one can define as modifying state outside of your program or depending on state outside your program.
Examples of side effects are IO operations, like
- Reading and writing to disk
- Opening network connections and making requests
and also things like random number generation, which make functions non deterministic.
Haskell is considered "useless" in this video because it doesn't allow you to make this side effect operations, because it's trying to be fully deterministic. The realization the peeps are talking about is that actually side effects are the whole point people write programs for, like you wanna make some request to server and show the response or you wanna read data from a file and do some computation on it, and Haskell by disallowing those things, it has made itself "useless"
But that's not really right in the current situation, because Haskell does allow you to do side effects but they do have their own structure of how one handles side effects which are called monads.
And btw Simon is one of the people that actually created Haskell.
And another note
Rust is actually the result of C/C++ folks trying to move closer to the Nirvana land he described in the video.
PS: I am not really a haskell guy, the last time I wrote haskell, is probably more than 2 years ago. I just thought I would share my views since you mentioned me.
👍2
Frectonz
I completely agree. [the tweet]
Capitalism is the only economic system that ensures human progress. It is one of the true super powers of humanity.
It holds societies together.
It even aligns nations to prosper together.
It is magnificent.
It holds societies together.
It even aligns nations to prosper together.
It is magnificent.
👎7🔥6
I've completed "Scratchcards" - Day 4 - Advent of Code 2023
I did this one in golang. Part 2 took me way too long to figure out.
[Part 1 Solution] [Part 2 Solution]
I did this one in golang. Part 2 took me way too long to figure out.
[Part 1 Solution] [Part 2 Solution]
Frectonz
I've completed "Scratchcards" - Day 4 - Advent of Code 2023 I did this one in golang. Part 2 took me way too long to figure out. [Part 1 Solution] [Part 2 Solution]
Notes
1. Don't use
2. If you are iterating over an array while you are modifying it, do not use ranges, just do a regular for loop and use indexes.
1. Don't use
strings.Split() to split white space, instead use strings.Fields(), read more about it in the golang docs.2. If you are iterating over an array while you are modifying it, do not use ranges, just do a regular for loop and use indexes.
🔥4
Here is another tech telegram channel for yall.
I think he mainly does ios stuff,
Checkout his channel
@storyOfXcode
I think he mainly does ios stuff,
Checkout his channel
@storyOfXcode
Frectonz
Photo
In my experience golang is a pretty meh language but no variable shadowing thing annoys me a lot.
Go needs to implement variable shadowing.
While you are programming you have some mental model of the data you're working on, let's say it's a list of numbers and you wanna sum them up.
Ok so the flow of the program is
1. You ask the user to provide the numbers. Let's say that the numbers are separated by commas.
You store the numbers in a variable you called
2. You split the input you got on commas, to extract the individual numbers you got.
Here's where things go wrong in a programming language that doesn't have variable shadowing. Ideally you would be able to do this
That's why variable names are helpful, they name the higher order way we think about the data.
If go had variable shadowing we would still be able to call the array of strings we got after splitting it,
There is a reason why I am using the word "shadowing" here. You might be asking why not just re-assign the variable, like what we do in dynamic languages. That's not what I am talking about, re-assigning the variable would only change the data it's holding on to, shadowing would let you change both the data and type.
In vscode terms when I hover on
3. At this point you would iterate over the
With variable shadowing, you would still call this
Without variable shadowing, you would be forced to come up with a new variable name like
4. In the last step you would just sum up numbers.
Go needs to implement variable shadowing.
While you are programming you have some mental model of the data you're working on, let's say it's a list of numbers and you wanna sum them up.
Ok so the flow of the program is
1. You ask the user to provide the numbers. Let's say that the numbers are separated by commas.
You store the numbers in a variable you called
numsnums := getInput()This will be holding our numbers as a comma separated string.
getInput is not a function in go, I just forgot how you read from stdin in go.2. You split the input you got on commas, to extract the individual numbers you got.
Here's where things go wrong in a programming language that doesn't have variable shadowing. Ideally you would be able to do this
nums := getInput()Instead you have to do this
nums := strings.Split(nums, ",")
nums := getInput()So what's the big deal, notice when I was talking about the "numbers" I was calling them "numbers" all the time, no matter what kind of data type they happen to be at the current stage. Notice how they were transformed from a comma separated string, into an array of strings, but we would still refer to them as "numbers".
numsSplit := strings.Split(nums, ",")
That's why variable names are helpful, they name the higher order way we think about the data.
If go had variable shadowing we would still be able to call the array of strings we got after splitting it,
nums and we wouldn't have needed to come up with the name numsSplit.There is a reason why I am using the word "shadowing" here. You might be asking why not just re-assign the variable, like what we do in dynamic languages. That's not what I am talking about, re-assigning the variable would only change the data it's holding on to, shadowing would let you change both the data and type.
In vscode terms when I hover on
nums from the first step, I should see string, in the second step nums would be []string.3. At this point you would iterate over the
nums and convert them from a string to an int. With variable shadowing, you would still call this
nums but now it would be holding on to a []int (an array of ints).Without variable shadowing, you would be forced to come up with a new variable name like
numsArray or even numsAsInts or sth like that.4. In the last step you would just sum up numbers.
Frectonz
Capitalism is the only economic system that ensures human progress. It is one of the true super powers of humanity. It holds societies together. It even aligns nations to prosper together. It is magnificent.
Telegram
Frectonz
This is especially true in Ethiopia, this notion is strongly woven into our society. I think the main source of this sentiment is this phrase from the Bible.
“Blessed Are the Meek, for They Will Inherit the Earth"
Screenshot from a Paul Graham article called…
“Blessed Are the Meek, for They Will Inherit the Earth"
Screenshot from a Paul Graham article called…
Frectonz
I've completed "Scratchcards" - Day 4 - Advent of Code 2023 I did this one in golang. Part 2 took me way too long to figure out. [Part 1 Solution] [Part 2 Solution]
Only manged to do part 1 today.
I couldn't get part 2 to work, maybe i will try it again in the weekends or sth.
I did today's puzzle in Rust.
[Part 1 Solution] [Unfinished Part 2 Solution]
I couldn't get part 2 to work, maybe i will try it again in the weekends or sth.
I did today's puzzle in Rust.
[Part 1 Solution] [Unfinished Part 2 Solution]
👍1