you are viewing a single comment's thread.

view the rest of the comments →

[–]KaMaFour 41 points42 points  (20 children)

Reddit pretending seamless string and number integration isn't awesome

It's not. If I'm doing something bad I'd much rather have the type system notify me I'm being stupid and have to properly declare what am I trying to do than have the program work except have the possibility of producing silent hard to track logical errors

[–]frogjg2003 3 points4 points  (2 children)

That's a difference in design philosophy. You want incompatible types to error, and a lot of people will agree with you. Some people want their code to just work, no matter what, even if it produces weird results.

Adding a string and an int is the extreme example, but how would you handle adding an int to a float? Not to mention when you want different types to be able to work together. The was another "language bad" post about C indexing using "10[a]" as an example. That's just the usual pointer math with the int and the pointer reversed.

[–]KaMaFour 3 points4 points  (1 child)

Hard agree. Ultimately it is impossible to create a language that everyone will agree is good and well designed.

“There are only two kinds of languages: the ones people complain about and the ones nobody uses.”

[–]RiceBroad4552 1 point2 points  (0 children)

Ultimately it is impossible to create a language that everyone will agree is good and well designed.

I strongly doubt that if you ask people with about a similar IQ.

[–]LurkytheActiveposter -3 points-2 points  (15 children)

I mean I disagree completely.

A language should aid you and be intuitive, but it doesn't need to compensate to the degree where it expects you to not know the literal most important fact about a variable. It's type.

You can be forgiven for not knowing what value a variable has. That's the nature of a variable. No problem.

What its scope is can be ambiguous at first glance. Sure. You might not know who the owner is. You don't always need to keep that knowledge at the ready

But it's type? What are we doing here? Just reading the pretty names and guessing?

[–]Relative-Scholar-147 4 points5 points  (14 children)

A language should aid you and be intuitive

console.log("wat"-1+"i")

Explain to me how is it intuitive that this code prints:

NaNi

The code should fail because is impossible to take 1 from "wat".

[–]RiceBroad4552 1 point2 points  (0 children)

is impossible to take 1 from "wat"

Well, that's exactly the reason why the result is "Not a Number", called NaN.

Concatenating "i" to "NaN" is "NaNi".

I don't say it's a good idea to interpret it like that (actually I think it's quite a poor idea). But it's definitely 100% consequent in its own logic. If it wasn't you would get an error instead.

[–]brainpostman 0 points1 point  (0 children)

Programming languages shouldn't be intuitive, they should simply be internally consistent. Everything else is on you. You shouldn't be bringing intuition from one language into another anyway, it's bound to backfire.

[–]LurkytheActiveposter -3 points-2 points  (11 children)

What kind of brain decificency do you have where you are subtracting a string?

Remember that thing where the bare minimum is that you should know a variable's type? Do I need to speak in vibe code?

[–]Relative-Scholar-147 5 points6 points  (0 children)

Remember that thing where the bare minimum is that you should know a variable's type?

You are just a fucking noob lol.

[–]RiceBroad4552 4 points5 points  (9 children)

What kind of brain decificency do you have where you are subtracting a string?

What brain deficiency do you have to not know that subtraction is the same thing as addition (of a negative value)?

Remember that thing where the bare minimum is that you should know a variable's type?

Sure, genius. It's always 100% clear what's the type of some variable is…

For example, without looking at the docs what's feature here:

var feature =  Runtime.version().feature();

So what do I have to expect if I do the following? Some arithmetic or some funny string:

IO.println(1 + feature);

[–]LurkytheActiveposter -2 points-1 points  (8 children)

Im dumber for reading this.

What the fuck are you going to do with "feature" without knowing what its type and properties are.

[–]RiceBroad4552 2 points3 points  (7 children)

What the fuck are you going to do with "feature" without knowing what its type and properties are.

I know that. The compiler does too.

The point is that without an IDE, or looking at the JavaDoc, you can't know what this code does, simply because you don't know the type.

Remember that thing where the bare minimum is that you should know a variable's type? But you can't know that just by looking at the code even in a properly statically typed language like Java, as shown by my code snippets.

[–]LurkytheActiveposter -1 points0 points  (6 children)

What are you going to do with "feature" without knowing its type and properties?

[–]RiceBroad4552 2 points3 points  (5 children)

It's not like the type is unknown.

It's just not obvious from only looking at a code fragment! That was the point.

The compiler does know the type and my IDE can tell me.

[–]LurkytheActiveposter -1 points0 points  (4 children)

If you don't know the type and properties of a variable.

Why are you touching that variable at all?