Fork me on GitHub
#clojure-uk
<
2023-10-31
>
maleghast08:10:55

Morning Everyone 🙂

maleghast08:10:43

I know it's a bit off-topic, but have any of you done anything with Rust-Lang? I am experimenting with it and I am wondering if I am being overly precious in the way I am resistant to some of the aspects of the type system and in particular the way strings work... I can rationalise all of it in the context of type-safety and the compiler, well up to a point anyway, but I keep coming back to the issue that if we can have convenient, uncomplicated Strings in Clojure, why can't they exist in Rust..? I mean is it JUST the compiler / typed axis or is there something else my non CompSci educated ass is simply not grokking..?

Ben Hammond08:10:07

you need to be a bit more precise https://doc.rust-lang.org/rust-by-example/std/str.html doesn't make it look too bad, what is the specific bit that is bugging you?

Ben Hammond08:10:12

the big difference is probably garbage collection; Java/Clojure has it Rust does not

Ben Hammond08:10:32

which means it needs to be Obsessive/Compulsive about not leaking memory

maleghast08:10:56

The fact that Strings have to be properly typed as String or &str depending on the operations that you want to perform and then possibly re-cast in order to be outputted correctly or match a declared return type. or to be fed into another process / function.

Ben Hammond08:10:08

so, &str is just a reference into somebody else's string? and you therefore need to take care • that it really IS a string • that it does not get yanked whilst you are still looking at it?

Ben Hammond08:10:29

whereas a a 'String' is mine and mine alone, to dispose as I see fit?

maleghast08:10:44

so, slightly pseudo code:

let mut x: String = String::from("Bananas In Pajamas");
x.replace("Pajamas", "Lederhosen")
instead of:

maleghast08:10:59

(clojure.string/replace "Bananas in Pajamas" #Pajamas "Lederhosen")

Ben Hammond08:10:22

oh, BTW is your job title correct and up-to-date?

maleghast08:10:29

But yeah, you've answered my question for sure @U793EL04V - it's what I thought, the compiler and the typing and the lack of Garbage Collection are all acting together to make it necessary to have extremely precise definitions of things...

👍 1
Ben Hammond08:10:00

and rust wants to be as performant as possible, whilst maintaining security

Ben Hammond08:10:18

whereas java is not so fussed about blinding speed

maleghast08:10:21

Oh well, I guess I will just have to adapt / lump it if I am going to use Rust at all. 🙂

Ben Hammond08:10:29

oh strange, maybe Slack was showing me a cached version of your user profile...

maleghast08:10:37

Thx for the heads up about my job title - I just changed it

😅 1
Ben Hammond08:10:28

Clojure -> Rust seems like a big jump what would drive that change?

Ben Hammond08:10:40

the restless search for knowledge?

maleghast08:10:04

Er, kinda...

maleghast08:10:09

I am working as a Tech Principal, so part of my job is to explore new (to AND) tech and encourage my fellow ANDis (colleagues) to do the same. I ran a poll amongst the Software Engineers in my Club (office) and the most sought after knowledge was Rust, so I am familiarising myself with it a little before launching a Code Dojo focusing on learning Rust that will be a kind of mutual aid / group learning initiative.

maleghast08:10:05

I did want to push Clojure, and I am giving a Lightning Talk about Clojure in a week or so, but I also didn't want to ignore the existing enthusiasm for something else 🙂

Ben Hammond08:10:38

is rust fully portable? Its billed as a spiritual successor to c++ which makes me think that you have to recompile a program for every architecture you want to run on

Ben Hammond08:10:59

presumable threading and i/o is properly standardised

Ben Hammond08:10:35

definitely I'd like to learn Rust if I get a suitable gap between jobs

maleghast08:10:06

Yeah, like Go-Lang you do need to compile again for the environment that you want to run on, but the received wisdom is that you don't need to alter source code in order to do that, so the hurdle is one of pipelines and infra, not coding.

maleghast08:10:21

My early stage take on it is that it's frustratingly precise, coming from Clojure / Python as I am, but it is coherent and as you learn new bits they slot into place with a satisfying "clunk" and the whole language feels very designed without being over engineered.

maleghast08:10:41

I will report back once I've actually got past initial learning and actually built something with it.

👍 2
pithyless09:10:36

> if we can have convenient, uncomplicated Strings in Clojure, why can't they exist in Rust As someone not familiar with the language, I've heard Swift has one of the better String implementations. And by that I don't necessarily mean performance-wise, but actually surfacing that Strings are hard (due to extended graphemes, multiple byte representations, logical vs byte comparison, etc). Just a cursory read over https://docs.swift.org/swift-book/documentation/the-swift-programming-language/stringsandcharacters/ shows that they've thought a lot about this and tried to surface it at the API level so that the developer is forced to have an opinion about how they want to deal with it. I think it is interesting from a Rich-style argument of "simple made easy", that the Swift API looks simple while the Clojure API (depending on the host platform implementation) looks complected. This thread is obviously more about the nuance of memory management and safety, so my reply is OT, but this remark about "uncomplicated Strings" reminded me of the problem that Strings are just hard. :)

👍 1
mario-star 1
thomas09:10:03

I have been using Rust for the last year or so and slowly getting used to it... I just depend on the editor/IDE to tell me what to do when it is wrong.

thomas09:10:11

and string are weird indeed

creeper 1
schmalz08:10:48

Morning all.