this post was submitted on 19 Jun 2025
322 points (90.5% liked)

Programmer Humor

24425 readers
100 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

Made with KolourPaint and screenshots from Kate (with the GitHub theme).

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 46 points 4 days ago (5 children)

You're encoding more information in the typescript one. You're saying it's a string that will get updated.

[–] [email protected] 1 points 1 day ago

Meanwhile if it's rust it's the opposite. (Variables that can change must specify that they are mutable)

[–] [email protected] 33 points 4 days ago (1 children)

Yeah, it's explicitly distinct from const a: String which says it won't change, and var a: String, which means this is legacy code that needs fixing.

[–] [email protected] 10 points 4 days ago (2 children)

If there's only two options you only need one keyword

[–] [email protected] 1 points 2 days ago

Ah, but this is JS, so there are three options! And they all function entirely differently. And your assumptions don't apply, either. :D

[–] [email protected] 5 points 4 days ago* (last edited 4 days ago)

True, but var and let are not same in js, so there is three.

if(true) {

var a = "dumdum"

}

console.log(a)

Is valid and functioning javascript. With let it is not.

[–] [email protected] 17 points 4 days ago (1 children)

You aren't though. In most languages that use the latter declaration you would prefix the declaration with final or const or the like to specify it won't be updated.

[–] [email protected] 11 points 4 days ago (2 children)
[–] [email protected] 14 points 4 days ago (2 children)

It's also valid rust syntax.

But if it were rust, this meme would not make sense, since you would just type let a and type inference would do its thing. Which is much more ergonomic.

[–] [email protected] 8 points 4 days ago (1 children)

let a = String::from(“Hello, world!”).into()

I’ll see myself out.

[–] [email protected] 4 points 3 days ago (1 children)

At least be fair and cut out the .into()

[–] [email protected] 3 points 3 days ago

And bow to the compiler’s whims? I think not!

This shouldn’t compile, because .into needs the type from the left side and let needs the type from the right side.

[–] [email protected] 1 points 4 days ago (1 children)

Type inference is a pretty big thing in TypeScript as well though. In fact it's probably the biggest thing about it, IMO.

[–] [email protected] 1 points 3 days ago (1 children)

I don't know typescript. But if that's the case, this meme doesn't make much sense.

Who writes the types of variables in a language with type inference unless forced by the compiler?

[–] [email protected] 1 points 3 days ago

Maybe it's a language without type interference?

Either way, it sometimes makes sense in TypeScript to help the type system out a little bit.

let array: string[] = [];

In this situation, the type system can't infer that the empty array should be a string array, because there are no items to go by.

[–] WhyJiffie 5 points 4 days ago (1 children)

I was thinking the same thing. who would write typescript if they could just do Rust?

[–] [email protected] 1 points 4 days ago (1 children)

I would because I know TypeScript and I don't know Rust.

[–] WhyJiffie 1 points 2 days ago (1 children)

ok but then you can't do Rust, so this does not apply.

but if you did.. !

[–] [email protected] 1 points 2 days ago (1 children)

Probably would still use TypeScript, because I use that for work. 🤷‍♂️ Rust just seems like... a lot. Regarding Rust, I've seen a lot of praises and a not so insignificant amount of complaints that make me very hesitant to take the plunge. Can't remember off the top of my head what it was, specifically, but it was enough for me to write it off, that much I remember.

[–] [email protected] 2 points 2 days ago (1 children)

People really overstate it, it's not that hard. It has a reputation of being difficult because people use it for difficult, low-level tasks, OS stuff, parsers, cryptography, highly optimised serialisation, but those things would be hard in any language. For a newcomer it's, IMO, way easier than say C++, because it doesn't have a mindbogglingly huge std lib with decades of changing best practices to try to figure out. To do simpler things in it is really pretty straightforward, especially if you're already comfortable with a robust type system.

[–] [email protected] 1 points 2 days ago* (last edited 2 days ago) (1 children)

This contradicts what I've heard others say about it. I have a feeling it is quite subjective, and this might just be an anecdotal recommendation because you have an easy time with it. Maybe I will too! But maybe I won't.

Either way, one part of me really wants to try it, but one part has very little time in life. 🥲

Also comparing it to C++ might not be the flex we think it is. 😅

[–] [email protected] 2 points 2 days ago (1 children)

Well sure, I guess you're right, it's definitely a bit subjective and some people have an easier time with some languages and ways of thinking than others for sure. And I didn't really mean to say that it was totally super easy, but... no kind of programming is really super easy. It is quite different and that in itself has a learning curve.

My recommendation is for sure anecdotal, but I think the point about it seeming more difficult than it really is because people often use it for difficult stuff is actually true.

[–] [email protected] 1 points 2 days ago

Take my up vote. I agree with everything in that comment. 👍

[–] [email protected] 3 points 4 days ago

C# has const string a = "Hello, World";

var in js is legacy, and default should be let, but changing that would break everything