« first day (3156 days earlier)      last day (2014 days later) » 

00:00
Ill take that as a no.
hey guys
hi?
hey do you know anything about coloring canvas elements
content* not doms
is it safe to create a API that retrieve sensitive data from mongodb using a function on SERVER, and deliver the data to WEBSITE using es6 fetch (my server Access-Control-Allow-Origin only allows requests from WEBSITE)
or could someone bypass Access-Control-Allow-Origin?
JBis did you read my messages from before?
00:17
Hey could someone help me attach my color plot on dat.gui to my color slot in my canvas?
I want to be able to change the color with dat.gu
but it doesnt seem to affect it
type RowInfo = {
  /* visibility */
  hidden?: boolean; // if true, the row is hidden

  /* row height is specified in one of the following ways: */
  hpx?:    number;  // height in screen pixels
  hpt?:    number;  // height in points

  level?:  number;  // 0-indexed outline / group level
};
Do the question marks after the object represent ternary expressions? I'm also seeing that the can represent a null conditional operator too?
Rob
Rob
It represents an optional value
That is... hpx is either a number or undefined
Which is just syntactic sugar for hpt: number | undefined
ahhhh interesting. Thanks for breaking that down. Man, reading libraries as a noobie is hard...
Rob
Rob
No problem
00:58
I need to learn Typescript in a hurry - any suggestions?
Hmm am I doing something totally wrong when on "reviewing" I tend to get a lot of inline styles. And specifically only inline styles for "margins/paddings". Where after building the a site first I notice "this specific divs should have a smaller margin, or larger left margin while keeping the standard other margins".
I could make a class for each div of its own, but that quickly pollutes the namespace.
@-me if you're responding or I might miss it...
@AaronHall it isn't much different from javascript. If you know javascript and a typed language, just combine the two with the variable definition on the right side. The type declaration reminds me of golang
@DavidKamer Specifically java/c# like typing system.
@DavidKamer I don't have hardly any experience with JS, and I think TS may well keep me out of trouble there.
01:08
I find python or c++ type systems quite different from typescript.
fuck
episode number 2 was only slightly better
@AaronHall the thing is you have all the features of JavaScript, so you're almost as likely to run into code that you don't understand.
damn it
So, uh, what's typescript?
I don't mean to be negative
@JennaSloan javascript that has stuff like function foo(bar: string) {}
01:10
I "prefer" flow though, it is easier on non cooperating libraries and easier to write stubs for said libraries "as you go".
@DavidKamer I have no idea what that means.
I know some Haskell, and I know how to google and I understand that Mozilla's a good reference for JS (right?) with the less reputable W3 schools likely to show up in the search results too...
Might change in the future as flow seems to start losing momentum a bit :/
yeah, MDN will tell you everything you need to know about JavaScript. That's not an exaggeration.
@JennaSloan TypeScript = Types + JavaScript
I consider myself a Python expert, any weird syntax I should be aware of?
01:12
Just that it feels simplistic :P
With javascript you'll need to be aware of the spread operator
spread operator is cool
Each time I go from python to javascript I feel "oh we're stepping back a decade in syntax"
@DavidKamer python has that for ages.
@DavidKamer Well that sounds unnecessary.
!!> [...[1,2,3], ...[4,5,6]]
01:13
@DavidKamer [1,2,3,4,5,6]
But the most difficult thing to "grasp" is the innate async/await structure of javascript and how tightly that is coupled into the language.
@JennaSloan I would agree with you but it seems people overall like statically type languages.
@JennaSloan oh yeah, totally is
Ok, so spread is like unpacking?
but almost everything is unnecessary if you look at the world that way. People will have code with the spread operator, so it helps to understand it
yeah
01:14
yup
You can do the same thing with objects
A bit less powerful though
@AaronHall There is a great discussion in this room that explains async and await pretty well. once you get that concept it will be very helpful
Unpacking in python is more powerful
>>> [*[1,2,3], *[4,5,6]]
[1, 2, 3, 4, 5, 6]
01:14
easier than using Object.assign and Array.prototype.concat
can you do that with function arguments?
Well what javascript misses are indeed function argument unpacking.
It is often emulated by "just using an object single parameter anyways".
!!> ((a, ...b) => b)(1,2,3,4)
01:15
@DavidKamer [2,3,4]
(See my comment of feeling to step back a decade in syntax)
@AaronHall Also get used to everything being an object.
arrow functions and scope are probably the most important. Well scope is
@JBis as opposed to Python? :)
Async is most simple explained with this:
01:16
functions are () => {} or the normal function () {}
@AaronHall I don't really know python other than basic stuff
async function getData(url) {
    const data = await fetch(url);
    console.log(data);
}
you can assign it to a variable either way or declare it with a name with the function syntax
@paul23 I would explain it with promises first
What is difficult to grasp (for me) at start is that if you want to "use" that function all uses also need to use async/await.
01:17
@paul23 no it doesn't
yeah, async/promises are a little advanced, but neccesary with JS
@JBis I wouldn't - promises are actually much harder to understand than just saying "await makes sure the function continues after the call has returned succesfully".
basically JS is single threaded and .then lets execution continue before the promise being evaluated finishes
// sync context
getData("https://example.com").then((resp) => { // code})
@JBis yes it does - otherwise the code might never run at all.
01:18
makes fetching and I/O easier
async/await are just sugar for promises
but scope is probably the most important concept in JS
which includes hoisting
@AaronHall Why don't you start building something?
like () => {} has no scope but function () {} does
so () => {} can be really really useful
oh the problems with this that's one annoying thing with js for sure.
01:20
if you use normal functions you'll end up binding a lot from my experience
I mean you can avoid it, but I see people ask about binding mostly when they don't know how to use ()=>{}
yeah the original documentation on scoping and how this is set is just a failure.
I call it the lambda function but it's not called that in JS
No other language has these problems at all as far as I know.
I call it lambda also
easier than explaining to non js people
@JBis lol, JS devs will yell at you and tell you that it's wrong lol
It's an "arrow function"
bc that's a more descriptive technical term lol
"... Arrow function expressions are ill suited as methods, ..." -- Frankly I think mdn is wrong here.
like you can get away with using less JS "features" by using the arrow function effectively.
Hey Paul, what do you make of this: https://codepen.io/SkylerSpark/pen/ELwmoa
I think its pretty good so far, still trying to research how to connect that color tab to the color of my cloth ctx in the canvas config...
I make methods most certainly always out of lambdas. Due to lambdas adopting this and super from the place where they are created. - Thus this and super are set to the object itself.
01:25
@paul23 yeah that's a complicated topic
this.method = this.method.bind(this) isn't always needed is it?
@AaronHall as you can see there is not much of consensus in js XD
like that's more with React bc of how thigns are setup, isn't it?
but js is my favorite language!
most of the time, iirc, if you do const c = new Something() the methods will have the this of that instance
Not complicated, just silly. One can understand it easily, but it's silly. Just like how you should not use mutable objects as default parameters in python: it's not that difficult to understand but from a programmers point of view it's silly.
01:27
I have a lot of example code I can follow, but I want to be able to recognize where they've made mistakes (if any).
oh yeah, that brings up a good point
I might like typescript if I learned it. but you have to compile it. thats seems soooooo ollddddd.
@AaronHall const is a lot different
const obj = {}
obj is just a reference
@DavidKamer It's a problem with callbacks. - When you use a member method as a callback the this during that callback will not be the original object's this. Rather it is the this of the object issuing the callback.
@AaronHall also get used events.
01:28
so you can still do obj.whatever = something
const means no reassignment, right?
something.on("event",(e)=>{//handle event});
@AaronHall yes
but let does too
well not really
is assignment usually called "binding"?
let blah = 'blah'
01:29
!!> const foo = 5; foo = 2;
that means you can't redeclar blah but you can change the value
Never heard that.
@JBis "TypeError: invalid assignment to const foo'"`
you can't change the value with const
!!> let foo = 5; foo = 2;
01:29
@JBis 2
but objects and arrays are references
not values
!!> const foo = {a: 5}; foo.a = 6;
if I use const to point a name to a mutable object, I can still mutate that object, right?
Obviously
01:30
just making sure.
@AaronHall yes, you just won't be able to mess with the reference. So you can't reassign it
sounds good.
Btw I hardly ever use let nowadays. Most of the time I can use const and better " structured" code.
@AaronHall why do you need to learn it quick?
Let I only use for mathematical "calculations" really.
01:31
(OPINION ALERT) most good code will have most variables, ESPECIALLY objects set to const
@paul23 even then if you do a one liner you only need const
OLDER CODE will use var
I need to extend some libs and my group doesn't have a lot of JS'ers... we have an intern that claims to know it, but I've seen a lot of people claim to know Python who didn't know it to my satisfaction...
oh yeah, you'll see a lot of var in older code. var declares the variable in the current scope
@AaronHall ooo boy. thats not gonna be an easy task.
@DavidKamer I find that with mathematics it's sometimes clearer to actually split the calculation up.
01:33
Everybody thinks they know JS, well mostly people who don't really know it think they know it lol
@paul23 true, but I'd just use functions and chain the functions
@paul23 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (if it wasn't clear, I agree with you)
fuck off comp sci'ers. How did you get these random numbers?
@AaronHall is it front end or node stuff?
(or something else like electron or chrome extensions)
And here comes the "a foolish consistency is the hobgoblin of little minds" paradigm into play
hopefully not react native lol
You may also see var for new code for compatibility reasons.
01:34
Well, luckily Typescript is kinda new, so there probably aren't a lot of others who would be better to do it... I do have some old JS pros I can get to review my code, however, but since they're not in my group, it will be really one-off reviews...
yeah, I mean JS is that thing every "fullstack" dev needs to know, so you can't do anything that terrible
Front end, using Phosphor, as I understand it. phosphorjs.github.io
what I mean is probably something like 90% of JS in the wild is trash
bleh. front end.
Backend is more fun.
Why use JS for backend when you can do Python, Haskell, C, C++, or Java?
01:36
Async nature :P
@AaronHall I think node has better performance than Python, better I/O paradigm than the rest
Because Java sucks. C is too low level. and C++ I have heard sucks.
To be honest I tried doing similar in python - I failed due to libraries badly interoperating with the various flavours of asynchronous code. (Async, greenlets, threads - some libraries expect one or the other)
I mean if I was doing CPU intensive stuff I'd just write that in C++ and have JS call it async
JS has a monopoly on the frontend, so you have no choice, except to use preprocessors, and Typescript is probably the way of the future for that...
01:38
^^ maybe not, but that seems better than a whole site in C
WEBASSEMBLY FOR THE WIN
In node all libraries "expect" asynchronous mode anyways, thus they all work well with async.
@AaronHall yeah webassembly will likely replace JS on the front end (at least partially) at some point, but I doubt node.js is going anywhere anytime soon
@JBis Web Assembly + Rust!
@DavidKamer kind of annoyed about that. Cause I don't want to have to learn it.
01:39
async make sense when you're dealing with databases or file delivery or anything like that
Yeah, node is there for front-enders who need to do backend without learning a new language.
@AaronHall not really
@JBis lol, you won't have to learn it. People just implement stuff in it for you to use so you don't have to use JS if you don't want to
@AaronHall Node is really nice on the back end. It's really fast and you don't need to worry about threads.
Keeps everything really lean.
@AaronHall oh yeah partly, but it has separate benefits over other solutions (I'm looking at you PHP)
01:40
@AaronHall You gotta get your head around the fact that you never want to stop execution of JS. If its gonna take a while, async it. Don't sit there processing shit thats gonna take awhile.
And Python, although it's nice and I like it, is kind of slow (by default)
Python is going to be my personal back-end go-to because I'm an expert in it. But the little I've used node it seems kinda cool.
If I have a lot of time to learn, I'm going to use Haskell for the learning experience.
Node is cool and fun to use. Python is fun too
I have used python for small stuff. I like it a lot but the libraries seem a bit inconsistent.
I've never used Haskell. I've been doing a lot with Golang recently
01:41
Python is way way faster than javascript for manipulating data btw.
Golang is... opinionated, but it's fun
ok, I need to hit some books. Thanks for the discussion on Typescript! :)
Well python is great for anything data related. Thats why so many ML libs use python.
@paul23 idk about that. I thought I saw benchmarks where just manipulating data JS is almost always faster (I could be completely wrong)
In python it is also "logical" to write functions that optimize for data evaluation (lazy executing generators etc).
01:43
most python things that are "fast" are because the libraries are using C
By the way, has anyone heard of or used PhosphorJS?
The docs are thin.
No, but it looks like something that might be fun to dive into
Some guy in JS chat mentioned it a min ago
@DavidKamer Of course, but that's part of the language, it's easy to interoperate with C, I've written several times such tools.
ask him
01:43
It looks modular, so odds are it would be easy to contribute
@paul23 that's fair, but I'd wager async with node could make such things run even faster
and increase orthogonality.
I'm really missing the generators and ability to just move data around.. In node it's really slow when you have (say) an array of key, value pairs. Need to do some dictionary operations on it and then export a slice of the data.
Those things I can't beat python with.
like building a tool in C and calling it externally (not in the way that the node docs tell you to call c/c++ code). I'm talking about something I've never done that I want to experiment with
And in node the code looks ugly too.
can you share an example?
Well do you know python?
01:46
yes
but I meant the JS code. Either would work
JS has generators btw
Python is fast for data analysis because numpy (and other libs in the data stack) use LAPACK and BLAS, which use specialized processor directives and are written in C and Fortran.
I've never really used them, but it has them
Yes but theyre NOT lazy.
they're greedy thus operating the moment you create them.
Exactly what Aaron said. And honestly Python isn't the best for external language plugins. It's probably pretty good, but Julia is supposedly better.
Once again, I love python
way more than any other backend langauge
And obviously you can create everything in javascript - it's turing complete after all. It's just not nice and the language doesn't promote structuring code in such a way that they're optimized.
01:49
@paul23 I'd wager that's an experience thing
could be wrong, but generally you can optimize if you know how
and if you're doing functional programming, JS (CommonJS and ES6 notation) makes that really easy
Still using sets in javascript is a pain.
I often long for itertools and the random library when using JS.
Like you can't iterate over sets directly, you have to first copy them into an array and iterate over those.
copy is a strong word I think
I'm not talking about numpy things, I'm talking about set & dictionary (map) things.
01:52
!!>Array.from(new Set([1,2,3,3]))
@DavidKamer "TypeError: calling a builtin Set constructor without new is forbidden"
@DavidKamer [1,2,3]
Sets are iterable: for (let x of new Set([1, 2, 3, 4, 5]))
Array.from isn't that bad, especially if you want all the functional stuff map, forEach, etc
Oh you can iterate them manually, but I mean functions like map and join etc. In python those just work on any "sequence".
01:54
yeah, but like I said, It's only like 10 characters to turn it into an array
idk about performance on that tho
not something I've felt the need to do often
That's what I mean where javascript is slow/unwieldy. In javascript I'm constantly using new set(Array.from(set).algorithmicoperation)
instead of set.algorithmicoperation
yeah, but that kind of forces people to take a step back and ask "why am I doing it this way" 9/10 times it's logically much simpler than doing something like that
but that's really just an opinion
Hi All, I am a newbie for angularjs and im currently using fullcalendar. Im facing issues in rendering eventRender function in mouse hovering. can you please look into this stackoverflow.com/questions/56472588/…
@tharindu Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
I disagree: I feel that due to this most libraries not use sets/maps where they should, and instead just use arrays as input.
01:57
The thing that really bugs me about js sets is that set.add can't add multiple items after it's created.
It's similar to how 'async is part of python' but due to bad syntactical support few libraries make use of it - where more should.
@paul23 fun fact: you can use object keys as a set and increase performance in some cases.
Oh I miss most normal set operations, like union and difference.
As well as the noticible slow initialization of sets compared to arrays
"seems unnecessary"
@paul23 I'm telling you use Object keys to make a set lol
Thus ['option_a', 'option_b'].includes(mypick) is faster than new set(['option_a', 'option_b']).has(mypick)
Even though using a set is in theory the right thing to do (I don't care about the order, I only care whether or not the chosen pick is in the sequence of options).
02:00
JS arrays aren't really arrays. They're just like a catch all container type
Thus javascript becomes "messy" and less expressive than it should be.
why not just create a library or superset language like typescript (or a plugin) to fix it?
Like you don't have to do it that way
Time
you can do it that way and make it look "expressive"
or you can just create a couple of functions
And no, you cannot beat python's speed in switching between different "views" of data.
02:02
a custom set object if you want, or override the prototypes
@DavidKamer The problem is: you'd always have the awkwardnes of the language structures not supporting it.
IE I can't extend the operators to support set theory calculations. Thus infix is not even thinkable.
I mean python is nice to use, but if you care about containers, python isn't as good as Java
well containers and types. I'm kind of lumping together for some reason
I care about expressiveness.
see... that is one of those phrases I have a hard time understanding. I think it is one of those things that has too many meanings
My code should look readable and should be easily written back to the underlying algorithm (scientific notation).
02:05
okay, that makes more sense to me
Like Set Theory isn't complicated though
Not on frontend, but on backend stuff that is sometimes something I greatly care about. And both java and javascript fail me big time there.
Classical example is linear algebra.
what makes python better in your opinion?
Ability to overload operators for one thing. Using of "magic methods" to overload most operations for another. Better more complete generators to help lazy evaluation...
I like function overloading in C++. That's something that I miss...
I think TS supports it
IE to calculate a rotation using 3 matrices: rot = A <dot> B <dot> C you'd have to do something like: A=[]; B=[]; C=[]; rot = matrix.matmul(matrix.matmul(A, B), C)
02:11
Never actually had to do this until now, but whats the best way to do static class variables in js?
MDN proposes this:
> Rectangle.staticWidth = 20;
Rectangle.prototype.prototypeWidth = 25;
SO proposes this:
const constant1 = 33,
      constant2 = 2;
class Example {

  static get constant1() {
    return constant1;
  }

  static get constant2() {
    return constant2;
  }
}
While in python I can do: A = matrix([]), B = matrix([]), C = matrix([]); rot = A @ B @ C
yep, probably. TypeScript is probably better for that.
Typescript doesn't allow operator overloading I think?
@paul23 but see would another dev be happy to find stuff like that in production code?
Uh yes? Since it's expressive? (@ is a well defined operator, and you can look at a glance the operands are matrices, thus anyone with a background in linear algebra knows what is being done there).
@ is defined as the "matrix multiplication operator", or "other multiplication where * should be used for memberwise operation".
That's part of the language definition. The actual calculation would hence be part of the matrix() class definition. Using the __matmul__ method.
02:16
I agree that the operator overloading is really nice. Being able to use '-' and '&' with sets makes the code very readable, for another example.
@paul23 okay, but would you ever do that in an application that doesn't need a background in linear algebra to create/maintain?
If you do matrix operations you would need it. Simple as that, I most certainly would not ever "comment" "we're doing a dot product here to get the lenght of a vector along another vector".
Those things one should know, or look up when you see a dotproduct happening.
right, but I didn't see dot product when I saw that syntax
Why not?
02:21
because that isn't a library and it isn't standard to the language
that's like you don't see appending when you notice "a" + "b"
so I saw someone making something up, and when I see that in someone else's code I call it "genius" code lol
that @ symbol isn't synonymous with dot product with anything I'm familiar with.
I never really used Matlab tho
Wait you see a "multiplication symbol meant for non element wise operations" - and you also see that it happens on 3 matrices (part of the type). How do you not connect the dots?
@DavidKamer It is in python 3.5
Literary definition in the language.
You're 5 years behind, that's saying that you're unfamiliar with "async and await"
"A new binary operator"
omg go home lol
I swear binary operations w/o abstraction are the devil
Hmm how would an editor be with "markdown rendering in javadocs/start of function comments?
02:26
@paul23 I'm a person who doesn't use python all the time and hates binary operations
or better: latex/mathjax
Like every development in computer science is to avoid direct binary manipulation (THIS IS AN OPINION)
???
Again how do you comment your code?
Quite often mathematical notation is the cleanest way to write comments.
But point being: operator overloading really clears up a lot of "boilerplate" code, that distracts from actual problem level code. And from experience context always makes it clear, and since it's often used a lot if you start using it. It's also easy to understand if you didn't beforehand.
yeah idk, I was just trying to give another perspective of why it can be bad
I would have used the same argument for any example
like I'd rather see dot(dot(a, b), c)
if I didn't speak english as a first language I wouldn't like that though.
unless it was dot product in my langauge (but maybe not even then
The problem with polish notation is that it is non intuitive if function lenght increases. And thus it doesn't align well with the mathematical "explanation".
I recon it would actually require more understanding of mathematics to decode polish back to infix notation than to just notice 'special' operators.
02:38
nah, but it would take a skilled software engineer, and they woudn't have to know any math
(actually functions are written in reverse polish notation)
yep
I was wondering where you were going
It's not even really "reverse polish notation" from what I know
I know it looks like something lispy, but it's pretty simple
It would if you really remove all infix operators.
Then you'd have reverse polish notation.
the inner most fucntion is figured first. It basically ends up being left to right I think
you'd be able to accomplish it easier with recursion or iterators with the same effect
*, +, 2, 3, 4 ==> (2+3)*4
02:41
tries to figure out what everyone else is talking about by looking at history
yeah lisp uses polish notation
thats how I know what it is
dot(dot(dot(a,b), c), d)
huh, yeah never thought of it that way, but I think you're right @paul23
idk tho, I'm inclined to say "that's just how functions work" lol
"that's how we notate functions" is the correct wording.
How functions work is an abstract thing.
@paul23 the question is can you write a proof that I'm wrong
About what?
That the logic of "that's just how functions work" is not logically correct
02:50
Easy, you do note that a function that does X is still the same function independent of the language right?
Say I have a function that 'takes two values and returns the largest' of the two?
you're making an assumption
You read "that's just how mathematical functions work"
Or say a function that "sums two values".
I could real "that's how we notate javascript functions"
which has a few false values
02:52
it has no notion of "order", only inputs and outputs.
(the triangle bit is the notation for a function).
@paul23 really? All diagrams I've seen before I think that's like and or something
I'd have to check, but not a function it's usually a logical operator. what am I looking at?
An operator IS by definition a function.
that's a something new to me, but I see the operators now
It is a function that operates on two values that are notes before and behind it.
"that's something new" as in that diagram format
02:55
Labview is a full fletched language.
yeah, I just have never used it, just like I'll never use Latex lol
The triangle "+" is just the most simple function (with image) I could find on google fast.
sorry LATEX
LaTeX
Most functions are squares :P
oh, yep, sorry. I guess it doesn't matter because I'll never use it
02:56
But they're difficult to explain here.
and it would be pointless to explain it to me. I'd never use a tool like that
It's mainly used to write programs for peripheral measurement equipment. As being visual it is inherently truly asynchronous. (each function operates the moment it has received all inputs), and then pushes the outputs.
Lines are like "immmutable variables/values".

« first day (3156 days earlier)      last day (2014 days later) »