[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Why is JS so shitty? Looks like some adderall adict kiddo was

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 69
Thread images: 6

File: js-logo-badge-256.png (12KB, 256x256px) Image search: [Google]
js-logo-badge-256.png
12KB, 256x256px
Why is JS so shitty? Looks like some adderall adict kiddo was behind the development of this attrocity
>>
Works for me and on my machine.
>>
>>59014254
Working shit still shit
>>
>type "manager."
>auto-complete gives me 50,000 options, none of them have anything to do with the object
This is why types were invented, Javascript. Why do you hate types?
>>
>>59014270
>Objects
>JS
>>
>>59014291
{}'s are called objects, though you can feel free to disagree with the name since they're basically just associative arrays.
>>
Because it was hacked together in 2 weeks, and grew organically from people in different tech cultures with little communication.

For a coherent language you really need a single vision.
>>
Is there a single scripting language which isn't an incoherent, inconsistent nightmare?
>>
>>59015607
Ruby, Python, Shell...?
>>
>>59015793
Python is so much worse than js
>>
File: consistency.png (36KB, 473x328px) Image search: [Google]
consistency.png
36KB, 473x328px
>>
File: 1452863444374.png (76KB, 420x420px) Image search: [Google]
1452863444374.png
76KB, 420x420px
>>59016347
You are so dumb.
you are in every JS thread making these dumb points.

First and foremost, if you code like that then you should kys.

the + operator can be either addition or concatenating depending on the type of the operands. The - operator can only be subtraction and nothing else.

If you use the + operator and the first operand is of type string, it will try to concatenate it with the other operand.

The + and - operators can also be used to be the sign of the following number. So if you already have an operator between your two operands, an additional + or - will be the sign of the following operand. So "5 + + 5" is adding five with positive five.
>'5' + + '5'
The second '5' becomes 5 (data type number) because of the 2nd +. string '5' will be concatenated with the number 5 to become '55'.
>'foo' + + 'foo'
Once again, the 2nd + tried to turn the 2nd 'foo' into a number, but it is not a number so it become NaN. Then you try to concatenate 'foo' with NaN, which gives you the expected 'fooNaN'.

Sure you poke fun at it, and you genuinely think it is not consistent. But you really just have not learned the language obviously.

See you in the next thread friendo.
>>
>>59016483

>it doesn't matter if they're completely unintuitive and arbitrary if they're deterministic
What is law of least surprise?
>>
>>59014245
>>
>>59016631
It isn't unintuitive nor arbitrary.
If I start working with a string, of course I'd expect the + operator to behave as concatenation.
>>
>>59014245

Works better than your 0.2% language
>>
>>59016850

Or you could just have a separate operator for concatenation. Even PHP figured that shit out.
>>
How is it shitty?

It's probably one of the best scripting languages of all time.
>>
>>59014245
import { foo } from "some-module";
const { map } = [];
const { log } = console;

Promise.all(
document.querySelectorAll( ".foo" )::map( elem => async () => {
const text = foo( elem );
await const response = fetch( `https://foo.bar/${text}.json` );
await const data = resonse.json();
return data.foo::map( item => item.bar );
})
)
.then( ::log );


tell me one language / api that makes this example task less verbose and more elegant.
protip: you can't
>>
>>59016880
Or you can just use template literals and say fuck addition concatenation.
>>
>>59016880
It's just different. Phps . Operator can be similarly weird
>>
>>59016954

PHP is just weird on the whole. The point is that if you're going to have this kind of automatic type conversion then you better not overload a single operator with multiple completely different functions.
>>
>>59016919
C#
>>
>>59017001
You know if you're really that concerned about adding strings with numbers you can use the unary plus operator right?
>>
>>59016329
Are you retarded or blind or both?
>>
>>59017127
Are you?

Python has way to many statement directives.

Python lacks language feature x in another?
New statement.

It's to the point where the Python grammar just gross.
>>
>>59017028
Please provide an example
>>
>>59017313
He can't
>>
Reminder that anyone who complains about typing in JavaScript is literally just shit at JS.
>>
>>59014245
>Looks like some adderall adict kiddo was behind the development of this attrocity
It's not though, it was a trans- and homosexual hating glorious white male who intended to make a Scheme for browsers with a C-like syntax.
>>
at least JS uses . as method accessor and not that '->' retarded sperm of php
>>
>>59019015

agreed
>>
>>59019015
>>59019060

>dereference notation comes from PHP

Fucking plebs
>>
>>59019111

nobody is saying that
>>
>>59019151
You're right nobody said that, it was implied (in written form).
>>
>>59019172

I guess you also think it was implied that JS invented . notation for accessors.
>>
>>59019207
No, I don't think that was implied because it wasn't.
>>
>>59019217

Just like it wasn't implied that PHP invented -> notation.
>>
>>59019243
But it was....

I'm starting to suspect that you are legitimately autistic.
>>
>>59019111
>>59019286
Are you retarded? That wasn't implied at all
>>
>>59016919
Promises originally came from C#. Now they are copying async and await? I bet Observables are going to be the next shit they copy.
>>
>>59015607
Lua
>>
>>59014291
>>59014311
The JavaScript language specification explicitly calls them object.
The word combination "associative array" is never used in the language specification.
>>
>>59019411

That's what they're called but it's not what they are.
PHP hashmaps are called arrays but that's not what they are.
>>
stupid("all",function()[
async("love",function(){
ifyou("js",function(){
FUCK="don'tneedit"
}}])
>>
>>59019351
Lol whatever this shit isn't funny any longer. Enjoy your severe autism.
>>
>>59014270
And that's why Typescript is so insanely popular right now.

Since JS lacks named parameters, we always have these fucking configuration objects with random string keys everywhere.
The JS using peasant needs to switch between the documentation and his code over and over again because he can't know what arbitrary words the developers of the other library used, while the TS using masterrace developer gets autocompletion and even errors if he types a wrong key.

Typescript's type system is incredibly mature and can express almost everything you can imagine. You should honestly try it.
>>
>>59019377
observable properties have been added long time ago. among with proxies and other stuff
>>
>>59019377
At least they're doing that.
Realizing that other languages have done much better and learning from them.

Just take a look at shit like PHP, where the core devs get 100% anal when someone tries to suggest merging a useful feature from hacklang.
And yet PHP's fanbois hype up its shitty and worthless 1 type only runtime checked scalar typehints and return types (which only work if you explicitly delcare them valid at the top of the file) that came in PHP 7 as if they somehow brought PHP on the same level as C#.
>>
>>59019492
t. 12yo retard who doesn't know what he's doing
>>
>>59014245
>>59016919

The problem with the elegance of JS such as this is simply the overhead and setup required. I mean can you honestly tell me that any other language couldn't be as good with the amount of things thats been done to JS to reach the level shown there?
>>
>>59019754
So what you're saying is JS sucks, every other language sucks substantially more, but JS still sucks?

Do you program or do you just discuss languages on /g/?
>>
>>59016919
This may look nice as code, but the things this code actually has to do in the background to accomplish its task is some of the nastiest shit you can imagine.
>>
>>59019792
nice bs comment, retard...

https://v8project.blogspot.de/2017/02/v8-release-57.html
>>
>>59014245
I had to use "node.js" which is some kind of piece of shit compiler of some sort for native javascript code. Jesus fucking christ it almost gave me javascript cancer. Now that I know how cryptocurrencies work and all that I wanted to use it for, I can safely delete it off my life and never see it again.
>>
A literal hitler-republican tried to make Scheme user-appaling in 10 days.

/thread
>>
File: jsbingo.png (6KB, 674x633px) Image search: [Google]
jsbingo.png
6KB, 674x633px
>>59020051
>>59016919
I'm pretty sure javascript auto-coercion rules which can't be avoided for most of binary operators started as a bingo card at netscape.
>>
>>59020192
You're using the wrong operator.
>>
Anyone else here think that javascript really shouldn't be used for servers? I hear things like node.js and socket.io and all these weird shit and all I can think is, "Javascript was originally just a neat way to run some scripts on a machine locally through the web browser... wtf?"
>>
>>59020254
It originally took off because it's natural support for asynchronous IO made it extremely simple to write fast concurrent applications.
>>
>>59020254
Being able to run the same code on the server and the client brings some advantages.
Server rendering for libraries like Angular or React wouldn't really be possible otherwise.

Unlike crap like PHP, JS also has an event loop implemented into the language. Disk operations, database queries etc. no longer completely block everything else while waiting for a response, and those pointless waiting times quickly add up in those synchronous languages.

Other languages that could fill the webserver niche like Go, hack, python or C# are either not popular enough (hard to find developers for) or require more expensive hosting.
Remember that that (and WordPress) are pretty much the reason PHP is still the most used language for the backend despite being the worst possible language for it.
I'm not a huge fan of node.js either, but... it happened. We have to accept it. It puts food on the table.
>>
>>59020103
>which is some kind of piece of shit compiler
>compiler

What?
>>
>>59019787

I was unclear. This is very basic stuff.

But since it seems that ES6 is trying add functional elements lets compare it to Scala.

Scala is better than this straight out of the box and is less verbose. And furthermore does not suffer from the ambiguously of dynamic typing.

And of the prettification on top of JS wont change the stupid way in which it handles strings yada yada.

At the end of the day even the way it is I would never use JS from any non-browser based project.

The 20,000+ line JS tat we have takes almost 6 minutes to be properly bundled/rendered/polyfilled etc meanwhile a similarly sized project in Scala compiles in roughly 1 min 30 secs and ofc will catch WAY more problems at compile time.

So we're right back where we started with JS: browsers and quick and dirty projects.
>>
JavaScript is hilarious though
['10', '10', '10'].map(parseInt)
>>
>>59022315

WHAT
>>
>>59022315
Why is that funny?
>>
>>59022315
>passing index from map as radix of parseInt
Of course you're going to get nonsense. What else would it do?
>>
>>59022315
parseInt expects more than one parameter and map passes 3, dummy

> ['10', '10', '10'].map(Number)
[ 10, 10, 10 ]
>>
>>59015607
BASH
A
S
H
Thread posts: 69
Thread images: 6


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.