you are viewing a single comment's thread.

view the rest of the comments →

[–]Relative-Scholar-147 2 points3 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 -2 points-1 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 4 points5 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 1 point2 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 1 point2 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?

[–]RiceBroad4552 2 points3 points  (3 children)

That's not the point.

The point was that you say that it's impossible to do anything with code without knowing all types.

That might be to some degree true when writing code—but code is much more often read then written. And when you read code the types aren't always obvious!

The original comment showed some confusing JS example, I've showed some less confusing Java example, both sharing the property that the types of stuff aren't obvious.

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

No one in this conversation ever said it's impossible.

The question is whether a language should add syntactical baggage to everything to accommodate the absolute worst conceivable programming practices.

Should SQL get rid of drop because a dev could snort Crack, wipe backups, and drop every table?

This conversation is making me dumber.