Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Perestroika
Apr 8, 2010

Antigravitas posted:

s/===/a sane language instead/

You're not the boss of me. :colbert:

Because my actual boss makes me use JavaScript. :negative:

Adbot
ADBOT LOVES YOU

LifeSunDeath
Jan 4, 2007

still gay rights and smoke weed every day

Stoatbringer posted:

"10" - 2 = 8
"10" + 2 = "102"

lol wtf

Armitag3
Mar 15, 2020

Forget it Jake, it's cybertown.



+ is simultaneously the addition operator between two numbers or the concatenation operator between a string and something that can be coerced to a string.

Javascript

LifeSunDeath
Jan 4, 2007

still gay rights and smoke weed every day

Armitag3 posted:

+ is simultaneously the addition operator between two numbers or the concatenation operator between a string and something that can be coerced to a string.

Javascript

how do you choose which one it does? also this reminds me of french counting.

Armitag3
Mar 15, 2020

Forget it Jake, it's cybertown.


LifeSunDeath posted:

how do you choose which one it does? also this reminds me of french counting.

It chooses for you depending on the operands. If they're both numbers, it adds, if not it tries to concatenate by turning what isn't a string into a string.

Sentient Data
Aug 31, 2011

My molecule scrambler ray will disintegrate your armor with one blow!
Whichever is the more inconvenient operation for your situation is what'll happen. No, that rule probably doesn't guarantee it'll be consistent across all browsers

Armitag3
Mar 15, 2020

Forget it Jake, it's cybertown.


"10" - 2 = 8 does the opposite, the subtraction operator will try to turn what isn't a number into a number, effectively coercing that "10" into a 10.

Mr. Fall Down Terror
Jan 24, 2018

by Fluffdaddy

LifeSunDeath posted:

how do you choose which one it does? also this reminds me of french counting.

it assumes. items contained within quotes "" are a string, otherwise they have an unspecified datatype, probably a number

string + number? = well, i'm guessing these are both strings, so i will concatenate them, "10" and "2" is "102", just like "fro" + "gs" = "frogs"

string - number? = well, we can't subtract one string from another, so these must both be numbers. 10 - 2 = 8

what it SHOULD do is bark a clear syntax error at you to be more specific about what you want to do. do you mean "10" + "2" or 10 + 2?

LifeSunDeath
Jan 4, 2007

still gay rights and smoke weed every day

Armitag3 posted:

It chooses for you depending on the operands. If they're both numbers, it adds, if not it tries to concatenate by turning what isn't a string into a string.

Gross

Armitag3
Mar 15, 2020

Forget it Jake, it's cybertown.



JavaScript was famously designed in 10 days, a lot of shortcuts were made

fartknocker
Oct 28, 2012


Damn it, this always happens. I think I'm gonna score, and then I never score. It's not fair.



Wedge Regret

Perestroika posted:

And that's why you always use === :colbert:

:hmmyes:

8===D~~~

gbut
Mar 28, 2008

😤I put the UN🇺🇳 in 🎊FUN🎉


The good ol' "shaft" comparison.

Antigravitas
Dec 8, 2019

Die Rettung fuer die Landwirte:
Meanwhile:


>>> "10" - 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'str' and 'int'
>>> "10" + 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate str (not "int") to str
>>>


However


>>> "10" * 2
'1010'

Milo and POTUS
Sep 3, 2017

I will not shut up about the Mighty Morphin Power Rangers. I talk about them all the time and work them into every conversation I have. I built a shrine in my room for the yellow one who died because sadly no one noticed because she died around 9/11. Wanna see it?

Armitag3 posted:

JavaScript was famously designed in 10 days, a lot of shortcuts were made

It was probably all the caffeine

Data Graham
Dec 28, 2009

📈📊🍪😋



Stoatbringer posted:

"10" - 2 = 8
"10" + 2 = "102"

https://www.destroyallsoftware.com/talks/wat

Turpitude II
Nov 10, 2014

someone drew a reverse version of this with a big titty anime woman proudly holding her weird little old man figure. i would not know how to find it though

ChubbyChecker
Mar 25, 2018

Antigravitas posted:

Meanwhile:


>>> "10" - 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'str' and 'int'
>>> "10" + 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate str (not "int") to str
>>>


However


>>> "10" * 2
'1010'


but 1010 is just a different way of writing 10

END OF AN ERROR
May 16, 2003

IT'S LEGO, not Legos. Heh


Turpitude II posted:

someone drew a reverse version of this with a big titty anime woman proudly holding her weird little old man figure. i would not know how to find it though

Reverse image search

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



END OF AN ERROR posted:

Reverse image search

:hmmyes:

Splicer
Oct 16, 2006

from hell's heart I cast at thee
🧙🐀🧹🌙🪄🐸

Armitag3 posted:

JavaScript was famously designed in 10 days, a lot of shortcuts were made
And renamed "Javascript" deliberately to confuse people who were getting excited about this cool new "java" thing.

PittTheElder
Feb 13, 2012

:geno: Yes, it's like a lava lamp.

Armitag3 posted:

JavaScript was famously designed in 10 days, a lot of shortcuts were made

lol god drat that explains a lot

Code Jockey
Jan 24, 2006

69420 basic bytes free

Antigravitas posted:

Meanwhile:


>>> "10" - 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'str' and 'int'
>>> "10" + 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate str (not "int") to str
>>>


However


>>> "10" * 2
'1010'


I was going to come in here guns blazing about how strongly typed languages are the only good ones but I see this and my brain is like yeah that makes sense

and then I realize I've been pythonpilled

Scratch Monkey
Oct 25, 2010

👰Proč bychom se netěšili🥰když nám Pán Bůh🙌🏻zdraví dá💪?
All weakly typed language inevitable comes up with a half assed scheme to introduce types on some level. Language devs never seem to remember why that is

Hyperlynx
Sep 13, 2015

The worst part about JavaScript is that it's inextricably part of the modern web. We're never going to be able to get rid of it and replace it with something better.

(The next best thing is more sane languages that turn into JavaScript when you compile them.)

Antigravitas
Dec 8, 2019

Die Rettung fuer die Landwirte:

Code Jockey posted:

I was going to come in here guns blazing about how strongly typed languages are the only good ones but I see this and my brain is like yeah that makes sense

and then I realize I've been pythonpilled

Pathlib is what pythonpilled me. They overloaded the / operator.

Observe.

>>> from pathlib import Path
>>> Path('/') / 'var' / 'lib' / 'foo'
PosixPath('/var/lib/foo')


:sickos:

5TonsOfFlax
Aug 31, 2001

Hyperlynx posted:

The worst part about JavaScript is that it's inextricably part of the modern web. We're never going to be able to get rid of it and replace it with something better.

(The next best thing is more sane languages that turn into JavaScript when you compile them.)

Agree, but wasm is a shining ray of hope. Javascript and all its warts will still be there, absorbed like mitochondria into the new, more advanced web ecosystem.

Data Graham
Dec 28, 2009

📈📊🍪😋



Hyperlynx posted:

The worst part about JavaScript is that it's inextricably part of the modern web. We're never going to be able to get rid of it and replace it with something better.

(The next best thing is more sane languages that turn into JavaScript when you compile them.)

https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript

(yes it's the same guy from the last link)

PittTheElder
Feb 13, 2012

:geno: Yes, it's like a lava lamp.

Antigravitas posted:

Pathlib is what pythonpilled me. They overloaded the / operator.

Observe.

>>> from pathlib import Path
>>> Path('/') / 'var' / 'lib' / 'foo'
PosixPath('/var/lib/foo')


:sickos:

Dear god no


Static types are where it is at. That and static analysis tools that bitch at you if you try and do that kinda nonsense.

Dewgy
Nov 10, 2005

~🚚special delivery~📦
Meanwhile I’m over here in Lua, redefining what operands do on every individual table object, cackling with glee as my syntax becomes completely incomprehensible.

Blue Footed Booby
Oct 4, 2006

got those happy feet

Dewgy posted:

Meanwhile I’m over here in Lua, redefining what operands do on every individual table object, cackling with glee as my syntax becomes completely incomprehensible.

I haven't tried in other languages, but C# will let you use Unicode crap for variable names. You can absolutely use Norse runes or zalgo text to take your obnoxiousness to the next level.

Hyperlynx
Sep 13, 2015

Blue Footed Booby posted:

I haven't tried in other languages, but C# will let you use Unicode crap for variable names. You can absolutely use Norse runes or zalgo text to take your obnoxiousness to the next level.

So will C++. This works fine:

#include <stdexcept>
#include <iostream>

int main()
{
try
{
throw std::runtime_error("oh no");
}
catch (std::exception& 🤮)
{
std::cerr << 🤮.what();
}
}

Son of Thunderbeast
Sep 21, 2002

ChubbyChecker
Mar 25, 2018


thats a jif thats made with a computer :smuggo:

The Demilich
Apr 9, 2020

The First Rites of Men Were Mortuary, the First Altars Tombs.




I'm upset there's not a grandma holding a bae-fu statue of some hammer cocked beefcake.

Someone with AI art powers get on it!

Dewgy
Nov 10, 2005

~🚚special delivery~📦

Blue Footed Booby posted:

I haven't tried in other languages, but C# will let you use Unicode crap for variable names. You can absolutely use Norse runes or zalgo text to take your obnoxiousness to the next level.

Lua tables have a hidden declaration called metamethods, so if you redefine a table’s “.__add” method, for example, you can change your syntax in very dumb ways.

Say you have a table foo_devourer, and you define foo_devourer.__add to be :

function(t)
t = nil
end

Then “foo_devourer + any other object” just nulls out the second object and returns nothing.

Lua’s kind of stupid that way and I love it.

syntaxfunction
Oct 27, 2010
I overload every method when I start a project with custom ones that work how I think they should.

For starters, the + method? Takes two ints and then turns them into strings and then adds them together. You want maths? Use Add(int, int) ya dummy.

I make these global overrides in every project I touch. I also do a lot of work for public githubs.

Large Testicles
Jun 1, 2020

[ASK] ME ABOUT MY LOVE FOR 1'S
go post in YOSPOS nerds, no one fuckin cares about coding in the pictures thread

Phy
Jun 27, 2008



Fun Shoe

Dewgy posted:

Meanwhile I’m over here in Lua, redefining what operands do on every individual table object, cackling with glee as my syntax becomes completely incomprehensible.

Meanwhile I'm over here trying to swallow my shame at briefly thinking "strongly typed" means you hammer it into the keyboard like Sean Connery is sitting there yelling at you

marshmallow creep
Dec 10, 2008

I've been sitting here for 5 mins trying to think of a joke to make but I just realised the animators of Mass Effect already did it for me

Phy posted:

Meanwhile I'm over here trying to swallow my shame at briefly thinking "strongly typed" means you hammer it into the keyboard like Sean Connery is sitting there yelling at you

"PUNCH THE KEYS!"

*Puts thumbs through phone screen.

Adbot
ADBOT LOVES YOU

Arivia
Mar 17, 2011

Phy posted:

Meanwhile I'm over here trying to swallow my shame at briefly thinking "strongly typed" means you hammer it into the keyboard like Sean Connery is sitting there yelling at you

sadly this went out of style with the buckling spring keyboard, everyone's got weak baby fingies now

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply