[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]

FACT: JavaScript is the most useful language to know and with

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: 141
Thread images: 11

FACT: JavaScript is the most useful language to know and with TypeScript it is actually good.
Prove me wrong.
>>
If I could prove it wrong it wouldn't be a fact, would it?
>>
>>58897542
what do you do when you only have 8K storage and 1K SRAM?
>>
>>58897542
>JavaScript is the most useful language to know
No, I consider English to be much more useful.
>>
>>58897542
I begin to actually like ES6. Also Abitbol classes are nice
https://github.com/wanadev/abitbol
>>
Typescript is awesome.

If you have a background in any static-typed OOP language, you will feel at home
>>
File: 1486816433825.jpg (56KB, 312x312px) Image search: [Google]
1486816433825.jpg
56KB, 312x312px
>transcompilers
>>
>>58897542
Typescript makes it atleast usable yes
>>
>>58897783
>not using purescript
Kill yourself pajeet microshaft shill.
>>
>>58897542
Dodgy browser based applications, poor peoples web backends and blinking LED tier microcontrollers aren't the most useful things.
Done.

>>58897763
/thread
>>
>>58897908
.>purescript
literalaly who
>>
>>58897542
>TS compiles down to ES6
>ES6 has no private methods, no private properties, statics are only public methods
>ES5 has all of the above
You should all drink bleach at this point
>>
>>58897542
Can someone post me a wiki page with this font? I would like to try something new.
>>
>>58897542
>Prove me wrong.
can't TS is actually fucking decent
>>
>>58899388
font?
>>
types are garbage, for people who can't program or keep track of multiple things
>>
>>58902958
t. nigger
>>
>>58897542
That's not how philosophical burden of evidence works. You are the one making the claim. Any position other than skepticism needs to have verifiable evidence supporting it.
>>
>>58899370
You can set the transpile target in a config file, try harder next time.
>>
>>58897542

It's useful to know about all the things wrong with it in case you ever have to read or write it.


> '5' - 3
2 // weak typing + implicit conversions = headaches
> '5' + 3
'53' // Because we all love consistency
> '5' - '4'
1 // string - string = integer. What?
> '5' + + '5'
'55'
> 'foo' + + 'foo'
'fooNaN' // Marvelous.
> '5' + - '2'
'5-2'
> '5' + - + - - + - - + + - + - + - + - - - '-2'
'52' // Apparently it's ok

> var x = 3;
> '5' + x - x
50
> '5' - x + x
5 // Because fuck math

var PI=((++[+[]][+[]]+[]+ ++[+[]][+[]]+[])* ++[+[]][+[]])*(++[+[]][+[]]+ ++[+[]][+[]])/((+[+[]]+'x'+(![]+[])[[+!+[]+!+[]]*[+!+[]+!+[]]])/(++[+[]][+[]]+ ++[+[]][+[]]));

Fuck consistency and transivity:

'' == '0' // false
0 == '' // true
0 == '0' // true

false == 'false' // false
false == '0' // true

false == undefined // false
false == null // false

null == undefined // true
'\t\r\n' == 0 // true

Fuck sanity:

typeof null == 'object'; // true
typeof NaN == 'number'; // true
NaN == NaN // false

Here's a great idea: automatic semicolon insertion!

// guess what this function returns, I dare you:
function f() {
return
{
foo: 'bar'
};
}

If that didn't blow your mind, how about this:

(Number.MAX_VALUE + 999) == Number.MAX_VALUE; // true
(Number.MAX_VALUE * 1.1) == Number.MAX_VALUE; // false, Infinity

Speaking of numbers, all numbers are 64-bit, except if you plan to do
any bitwise operation at all, in which case they're silently converted
to 32 bits, than back to 64 again:

Math.pow(2,31) == 2147483648 // true, as expected
1 << 31 == -2147483648 // also true, because fuck you
>>
>>58904536
Have you maybe ever considered to not to retarded shit?
>>
>>58904562
I have, that's why I don't use Javascript.
>>
>>58904584
So you use C to calculate the value of ((++[+[]][+[]]+[]+ ++[+[]][+[]]+[])* ++[+[]][+[]])*(++[+[]][+[]]+ ++[+[]][+[]])/((+[+[]]+'x'+(![]+[])[[+!+[]+!+[]]*[+!+[]+!+[]]])/(++[+[]][+[]]+ ++[+[]][+[]]))?
>>
>>58897708
Seek help for my autism
>>
>>58904615
OH ok lol. you've never ACTUALLY had a job. My mistake. lol.
>>
>>58904626
>the only jobs available are writing shitty code for 5 cent microprocessors bought from Shenzhen
>>
>>58904536
>var PI=((++[+[]][+[]]+[]+ ++[+[]][+[]]+[])* ++[+[]][+[]])*(++[+[]][+[]]+ ++[+[]][+[]])/((+[+[]]+'x'+(![]+[])[[+!+[]+!+[]]*[+!+[]+!+[]]])/(++[+[]][+[]]+ ++[+[]][+[]]));

Please explain how this works
>>
>>58904664

google jsfuck
>>
>>58904626
>LOL XD XD
There are a thousand JS jobs for every job in C and Go combined
>>
>>58897542
JS is nice because it combines C-family imperative syntax with support for functional programming techniques. However, I would like it if TCO became standard, because as it is any non-trivial recursive function will run out of stack.
>>
>>58897763
They're called transpilers, doofus.
>>
>>58903341
>t. OOP apper who's terrified of gotos
>>
>>58904861
TCO is part of the ES6 spec you fucking idiot.
>>
>>58904888
Then why doesn't the Firefox JS interpreter support it?
>>
Transcrypt
>>
>>58904905
Stop using an outdated Javascript interpreter.
>>
>>58897542

typescript is definitely not good and a lot of the class shit in ES6 is retarded.

just accept that javascript's design and stop adding your cancerous bullshit to it.
>>
>>58904926
I'm using Firefox 51.0.1. Where exactly would I find an up-to-date JS interpreter?
>>
>>58904615
Autism gets the job done so I don't see why I should seek help when it's contributing to productivity and avoiding high costs by avoiding higher end microprocessors. Also get to play with Forth.

>>58904626
Are you retarded?

>>58904647
SD cards, keycard locks, ect... things that go everywhere and you use without even thinking about it.
>>
>>58904861
Recursion is functionally equivalent to loops, just like objects are functionally equivalent to closures.
>>
>>58904962
>SD cards, keycard locks, ect... things that go everywhere and you use without even thinking about it.

and funny enough most of them are complete garbage programmed by chinks and morons like you.
>>
>>58904958
Btw it doesn't work in nodejs either.

>>58904968
How would you implement the Ackermann function without recursion?
>>
>>58904958
Chrome, Safari, or node you fucking idiot.
>>
>>58904988
>implying you could do it any better
>>
>>58904994
https://gist.github.com/Sebbyastian/9bf5551f915b2694c77e
Literally the first fucking result.
>>
>>58904988
Be glad it works unlike most websites which require a bloody R7870 to render
>>
>>58904988
>SD cards, keycard locks, ect... are the only things that exist in the world that can be programmed
>>
>>58905000
Doesn't work in the latest version of nodejs or Chrome.
>>
>>58905039
You aren't enabling the right flags. But again if you were going out of your way to use recursion to do anything that exceeds the maximum stack depth you are too retarded to know what flags are anyway.
>>
>>58905010
Uses heap allocation, which makes it just as bad, if not worse than recursion. When people say "iterative function", what they really mean is a function with bounded memory usage.
>>
>>58905055
No they don't. They mean a function that does not call itself or any other functions that might call itself.
>>
>>58897542
Turing machine languages, context-free languages, regular languages.
>>
>>58905051
>talk about TCO
>if you were going out of your way to use recursion to do anything that exceeds the maximum stack depth you are too retarded
What did he mean by this?
>>
>>58905064
Yes, that's the literal definition. But when people say they NEED a non-recursive implementation, it's usually because they need to minimize memory usage.
>>
File: slide_3.jpg (61KB, 960x720px) Image search: [Google]
slide_3.jpg
61KB, 960x720px
>>58897542
>>
>>58905097
>hurr durr I need recursion to write my factorial function because I'm such a special snowflake!
>>
>>58905097
i don't know but if your node can't handle tco, you can just do setImmediate(() => your_func(x))
>>
>>58905127
(let fib ((n 1) (m 0))
(display n)
(newline)
(let ((n (+ n m))
(m (n))))
(fib n m))
>>
>>58905207
>fib function that takes 2 arguments
Again with the special snowflake shit.
>>
>>58897763
Wow, you shitlord
>>
So /g/, have you wrote anything in JS ever or recently?
>>
>>58905497
written*
>>
>>58904873
They're called cum pilers, doofus.
>>
>>58905497
yes.
>>
>>58905647
will you show us anon?
>>
>>58905497

I would say roughly 80% of my job is using vanilla JS, jQuery, React and a little Angular 1.

My spirit breaks a little each day.
>>
>>58897542
>JavaScript is the most useful language to know
Agreed.
>and with TypeScript it is actually good.
False.
>Prove me wrong.
Impossible, you provided opinions.
>>
>>58905677
I hate vanilla JS

Typescript makes it bearable
>>
>>58905761

Typescript is a bandaid. Javascript is a broken spine.
>>
>>58905782
I agree but there really isn't any alternatives for the browser
>>
>>58905815
Elm, Purescript, Dart, Clojurescript
>>
>take dynamic meme language
>add stronger typing to it

literally just use a statically typed language retards
>>
>>58897542
Typescript's really great, yeah.

I just wish it supported powerful compile time macros.

One thing I really want in JavaScript (or Typescript) is the cascade operator from Dart.
Being able to do something like

document.getElementById('bla')
..addEventListener('click', () => console.log('clicked'))
..textContent = 'hurr'
.classList..add('someClass')..remove('someOtherClass');


Would fix so many of my pain points.I don't want to include some huge crap like jQuery but the nativ e API, especially the DOM API is such a fucking pain in the ass to work with because it's not fluid.
>>
File: dart-logo.png (31KB, 1200x900px) Image search: [Google]
dart-logo.png
31KB, 1200x900px
>>58897542
>>
>>58907687
That compiles to absolute crap code. Needs a shit ton of helper functions to provide a runtime for dart code and the code it produces is unreadable, suboptimal and huge.

Prove me wrong.
>>
>>58897708
Just write a transpiler silly.
>>
>>58906139
Interesting idea. Why don't you go on github and propose it on the JS working groups. Anyone can contribute to JS on github, I think. If your idea is great it might stick.
>>
>>58908883
I keep thinking about it, but I don't want to be the person to formulate and fight for a spec. I know how exhausting that is.

There are some things to consider here, like if you want to set your cascade to some inner object like
document.getElementById('aaa')
..classList.add('irrelevant')..remove('alsoIrrelevant') // Note that only one dot is used on the first add
..click() // Won't work, click() will be called on the classList
.

So you have to make up some way to go back or scope the cascade, like with surrounding the part you want to scope in parentheses (which seems might have serious implications on JS implementations) or maybe even a ... operator that works like .. except that it reduces the "scope"?

And then there's the problem that .. can be valid syntax already, like with 5..toString(). So what's the solution here? ... for cascade, .... for cascade with scope narrowing?

I dunno.
>>
>ES6 looks bretty good
>node.js package in Debian Jessie is ancient shit that supports nothing fug.
>>
>>58897542
JavaScript is Lisp without any of the good parts and all of the bad.
>>
>>58909039
>tips )))))))
>>
>>58909044
Well memed
>>
>>58904536
what the fuck is going on
>>
File: 1443298267157.png (463KB, 625x469px) Image search: [Google]
1443298267157.png
463KB, 625x469px
>>58904536
What the fuck man, im scared
>>
File: scared 56456.jpg (32KB, 300x375px) Image search: [Google]
scared 56456.jpg
32KB, 300x375px
>>58904536
>>
>>58907687
>mfw even Google chose TypeScript instead of their own Dart for Angular 2
>>
>>58897763
>agreed

Also JS only has a single thread.

No fagatronic framework or language update will fix that.
>>
>>58907735
unreadable doesnt matter as long as the source is ok, as for it being suboptimal... well who cares about that nowadays lol
>>
>>58904536
And I thought bash was bad....
>>
>>58905064
Well then your SoL if the new super javascript memeory allocation manager uses Ackerman functions aren't you/
>>
>>58904536
JUST
>>
Javascript is a horribly shitty language that sadly ended up in the center of internet programming. I'm still hoping WebAssembly kills it in a timely manner, although 1.0 is still way too JS-focused.
>>
>>58897542
Java/Typescript as a language is pretty cool. It's the Silicon Valley hipster community that sucks.
>>
>>58897724
>https://github.com/wanadev/abitbol

Why would someone implement something like that and then deliberately not use the standard "constructor" name for constructors??? It uses an ugly "__init__" name instead. Bizarre.
>>
>>58908964
Thanks for posting that. I didn't know about the cascade operator in dart until just now. Seems like a nice feature.
>>
File: 1483214348508.jpg (141KB, 1000x1000px) Image search: [Google]
1483214348508.jpg
141KB, 1000x1000px
>>58904536
not even gnuplot is that fucked with it's implicit conversions
>>
>>58904536
the only correct behavior in this entire fucking thing is NaN == NaN yielding false.
>>
>>58897542
TypeScript actually makes it worse.
Types are useless and actually harm sometimes.
>>58897708
It's ++2016, get something better.
>>
>>58915391

You have types whether you like them or not.
What matters is whether they're static or dynamic.
>>
>>58897542

I'm happy that with Typescript, ES6 and React the js community have finally recreated Java.
>>
>>58915481
Yeah but it said just '- types' and not '- static types'
also
>there are always types
B > C
>>
>>58915503
Then why isn't Java dead?

If there's one thing JS could do right is kill Java. That would compensate for all its faults.
>>
>>58911909
The Angular team chose TS but wherever Angular 2 is used internally in Google, it's used as AngularDart. Google doesn't actually use TS.
>>
>>58915691
no, no it wouldn't. Not by a long shot.
>>
>>58915391
>actually harm sometimes
They are not mandatory, don÷t use them when they are harmful.
>>
>>58904536
Yeah everyone knows JS is weird when it comes to types. Only C autists care about that shit though. Everyone else just remembers to add some exception handling.
>>
>>58917580

>Have to account for exceptions whenever you try to add or subtract
See this is why nobody likes JS
>>
>>58917640
Same thing happens with a bunch of popular languages like Python and no one seems to care. JS hate is just a meme at this point.
>>
File: 1473023405335.png (97KB, 375x360px) Image search: [Google]
1473023405335.png
97KB, 375x360px
>>58917661
>no one seems to care about the weak typing issues of other langs
skewed perception, much?
>>
>>58904536
Are you just going to pretend that there are no other languages where you gotta learn what rules apply to basic operators and whatnot?
Honestly the biggest idiocy in that post is putting the object you implied the function would return in a new line after the return statement.
I'm not saying JS is a flawless language of course but goddamn
>>
>>58918047
It's just C autists. Learn to ignore them. The private sector sure does.
>>
>>58918047
Even then, aside from a few things that are arguable, the vast majority of those operations and how they are handled are a directionless, inconsistent mess free of a clear concept or design philosophy.
>>
>>58918208
Or you're simply too retarded to understand how simple type conversion works with binary operators.
>>
>>58918208
Will it kill if you read the specs instead of shitposting?
>>
>>58918260
Have I ever called the type conversion non-trivial? No. I called it terribly designed.
I have had the pleasure of working with code that allocated all memory disregarding of type on a long vector and let each subroutine operate on different segments interpreted as different data types and arrays of varying dimensions by operating on out-of-range memory which works solely because the author was aware of the details of the lang's technical implementation.
That was a standard programming style at the time, but may be considered bad design from a modern perspective nonetheless.
But no, I just must be too stupid to see the "genius" behind that.
>>
>muh types

It's literally 2017 and you autists are still freaking out about that? It's called fucking proofreading your code.
>>
>>58918567
it's called fucking killing yourself, you deserve webdev as much as it deserves you
>>
>>58918629
>I deserve a comfy six figure 10-5 programming job with free breakfast and lunch
Thanks.
>>
>>58918208
If you don't learn the language, of course it doesn't make sense.

Then you'd know about how different types are converted depending on which operators are used.

Usually, there is a priority for expressions to be converted to strings, but if the operator can't equate those types, further conversions are made. For example, the empty string can't really be equated with a number, but it can't convert to anything meaningfull as a string either, so it's converted to boolean false.
>>
>>58917661
>>58918047

>>> '5' - 3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'str' and 'int'

>>> '5' + + '5'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: bad operand type for unary +: 'str'

>>> '5' + - + - - + - - + + - + - + - + - - - '-2'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: bad operand type for unary -: 'str'

>>> '' == '0'
False
>>> 0 == ''
False
>>> 0 == '0'
False

>>> False == 'false'
False
>>> False == '0'
False

>>> '\t\r\n' == 0
False

>>> 2 ** 31
2147483648
>>> 1 << 31
2147483648
>>
>>58918842
>entire program crashes when you try to do '5' - 3
>>
>>58918887

Doing something bizarre when you enter an unknown state is not better than stopping when you enter an unknown state.
>>
>>58918887
Python really is the worst of both possible worlds sometimes.
>>
>>58918908
>unknown state
The behaviour is clearly defined in the spec.
>>
>>58918926

Do you know all the different cases where equality doesn't actually mean equality?
>>
>>58919001
== isn't the equality operator you fucking retard. At least try to learn the language.
>>
>>58919027

>== isn't equality but actually voodoo magic that never works quite how you expect it to
>=== is the real equality operator
>this is good design
>>
>>58919027
>== isn't the equality operator you fucking retard.
Have you read the spec, you fucking retard?

http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
>>
>>58919027

7.2.13 Abstract Equality Comparison

The comparison x == y, where x and y are values, produces true or false. Such a comparison is performed as follows:
1. If Type(x) is the same as Type(y), then
a. Return the result of performing Strict Equality Comparison x === y.
2. If x is null and y is undeᲪined, return true.
3. If x is undeᲪined and y is null, return true.
4. If Type(x) is Number and Type(y) is String, return the result of the comparison x == ToNumber(y).
5. If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x) == y.
6. If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.
7. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).
8. If Type(x) is either String, Number, or Symbol and Type(y) is Object, return the result of the comparison x ==
ToPrimitive(y).
9. If Type(x) is Object and Type(y) is either String, Number, or Symbol, return the result of the comparison ToPrimitive(x)
== y.
10. Return false.
>>
>>58919285
>>58919259
>abstract equality is the same thing as equality
>>
File: question girl450394850934.jpg (180KB, 945x945px) Image search: [Google]
question girl450394850934.jpg
180KB, 945x945px
>>58919027
>>
i'm new to javascript and other languages. can't understand what you guys are talking about, i'll come back in ten years
>>
File: equality-in-javascript.png (579KB, 854x853px) Image search: [Google]
equality-in-javascript.png
579KB, 854x853px
>>58919310
>language needs both abstract equality and strict equality
>>
>>58899388
It's Open Sans
>>
>>58918047
>expecting JS doesn't have meaningful whitespace is idiocy
The automatic semicolon insertion that will silently fuck shit up at runtime (which, BTW, can happen not with just return statements) is literally *the* most retarded idea in the history of programming languages. Anyone defending it should be placed in a gulag.
>>
>>58904536
Oh God. Is this all javascript or just one implementation?

Also, all CS graduates should be able to write interpreters, writing (hopefully sane) interpreters is a universal senior examination project. What went wrong?
>>
>>58920084
Some JSfags are just that delusional, apparently.
They just can't handle the shitness
>>
>>58921705
>>58920084
>I'm too retarded to use a formatter
>I manually format my own code
Get a load of this faggot.
>>
>>58921714
>he actually writes code instead of just typing one letter and then being able to hit TAB until you're done
plebs
>>
>>58921714
A language can either have meaningful whitespace or not.
If it does, then no auto-formatter should fuck with it.
If it doesn't, then no amount of formatting should change the way the code works.
If it's JavaScript, then HURR FUCKING DURR.
>>
>>58922538
This kind of braindead design is JavaScript's identity.

>Should we have null or undefined?
>Why not both?

>Should we have semicolons and braces or significant whitespace?
>Why not both?

>Should we have implicit type casting or strict type checking?
>Why not both?

>Should we have 32-bit int or 64-bit int?
>Why not both?
Thread posts: 141
Thread images: 11


[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.