What's your favorite language Jow Forums?

what's your favorite language Jow Forums?

Attached: javascript.png (680x680, 274K)

+ operator is overloaded, - isn’t.

English

kotlin

>overloaded
What dis mean?

based retard

english

what do you think should happen if you try to subtract 1 from a string? adding to a string logically appends that to the end of the string

Julia

First for Lua!

In a really high level language, I can imagine string subtraction resulting in removing substrings.
Example:
"abcdefgabcdefg" - "ef" => "abcdgabcdg"

The image is wrong, "11" - 1 returns 10, not "10"
Subtraction is only valid for numbers, so both sides are coerced to a number before subtraction
However, addition means concatenation if at least one side is a string

no, in a high level language it should give an invalid argument exception or similar because its not a supported / defined functionality
then if you wanted to you could overload the operator and define what it should do for a given class

It means the same as when you search a word in a dictionary and has various meanings.

No, I disagree. A high level language is allowed to have built-in operator overloads.

but even youre example shows how dumb it is to just pick something like that
should it remove all instances of that? the first instance? the last? only remove it if its the end of the string? youve created something which isnt clear what it will do as well as only being useful in few limited circumstances

>string concatenation concatenates strings
>subtraction subtracts numbers
Wow.

And this is where regular expressions come into play. Particularly the g flag.

So yeah, subtracting just a string should remove all instances, although you're right that it's not entirely clear what it should do. But subtracting a regular expression would have better-defined behavior, particularly if the g flag is allowed. Additionally, you could have the subscript operator overloaded by default so that if you subscript a string with a regular expression, you get matches, and if you assign a value to a regular expression subscript of a string, it does a replace.

lua is great

This

Nim

RUST

The Black Speech

Crystal

>all these posts defending javascript retardation
Webdevs get out

Oh that's cute, it's trying to be Lisp

>youve created something which isnt clear what it will do as well as only being useful in few limited circumstances
hmmm

Javascript is ok. Probably the easiest language to hack things with at the moment.

Haskell, because I'm goddamned civilized

Java. It was my first language a decade ago and its just kino

Haskell obviously, Rust is just too verbose, linear types are good though and I wish they get implemented by default.

It means that the + operator has too much work to do so it fucks up a lot, but -'s load is lighter so it can do things slower and more meticulously.

Este y español.

kek, Spanish is broken, not as bad as french but still, that's why even a monkey can learn English

japanese I guess

javascript

PHP 5.2

Green.

+ is the only exception where if either operand is a string the other is converted to a string. which explains why "11" + 1 leads to string concatenation. the behavior isn't hard to explain but admittedly its stupid, javascript has too much implicit conversions.

C++

1 isn't a string

Everything is a string.

What JavaScript gets wrong is that "11" isn't a number.

lmao

Attached: js.png (180x115, 1K)

Finnish
C++

ERLANG

Attached: eric-s-raymond-is-da-man.jpg (500x333, 32K)

>"11" + (0 - 1)
>"11-1"
JESUS CHRIST