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.
 
  • Locked thread
gonadic io
Feb 16, 2011

>>=

cinci zoo sniper posted:

re &&: oh, i see. what is the difference between logical and bitwise OR then?

logical works on boolean values (and many languages will silently coerce ints to bools where 0 is false and anything else is true).
it returns true or false (again, 1 or 0 respectively)

bitwise works on the individual bits in a number. so
0b001100 || 0b111000 is just true i.e. 0b000001
but
0b001100 | 0b111000 compares each bit and you get back 0b111100.
if you pretend that true is exactly 0b000001 and false is exactly 0b000000 then they give the same results.

HOWEVER a big difference in reality is that logical OR also short-circuits, it won't evaluate its second arg (or perform any of its side effects) if the first is true (since true || _ is true)

Adbot
ADBOT LOVES YOU

cinci zoo sniper
Mar 15, 2013




gonadic io posted:

logical works on boolean values (and many languages will silently coerce ints to bools where 0 is false and anything else is true).
it returns true or false (again, 1 or 0 respectively)

bitwise works on the individual bits in a number. so
0b001100 || 0b111000 is just true i.e. 0b000001
but
0b001100 | 0b111000 compares each bit and you get back 0b111100.
if you pretend that true is exactly 0b000001 and false is exactly 0b000000 then they give the same results.

HOWEVER a big difference in reality is that logical OR also short-circuits, it won't evaluate its second arg (or perform any of its side effects) if the first is true (since true || _ is true)

:eng99: im not sure what did i expect from logical or short-circuiting behaviour

gonadic io
Feb 16, 2011

>>=

cinci zoo sniper posted:

:eng99: im not sure what did i expect from logical or short-circuiting behaviour

what do you mean sorry? || is basically the dual of && so everything said there applies here too.

Fiedler
Jun 29, 2002

I, for one, welcome our new mouse overlords.

rjmccall posted:

C++ code:
bool values[8] = { in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[0], in[1] };
for (int i = 0; i < 6; )
  if (values[i++] && values[i++] && values[i++])
    return true;
return false;
Array of size 8 assigned 9 values. :sad:

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Fiedler posted:

Array of size 8 assigned 9 values. :sad:

I don't write C, please tell me that's a compile error and not a "lol guess I'll just overwrite the next byte in memory #yolo" scenario

cinci zoo sniper
Mar 15, 2013




gonadic io posted:

what do you mean sorry? || is basically the dual of && so everything said there applies here too.

what im saying is that for some reason (e.g. im dumb) i did assume that logical or would in some place behave like logical and and drop whatever it is doing once it has fulfilled a certain condition (e.g. first false statement in "&&" chain). but then i wonder if there is any high level difference be between logicals, other than the length of evaluation chain i guess?

also drat it's really annoying to talk about this from phone, i can't post examples

gonadic io
Feb 16, 2011

>>=
First false value halts a && chain and first true value halts a || chain.

cinci zoo sniper
Mar 15, 2013




gonadic io posted:

First false value halts a && chain and first true value halts a || chain.

yeah that makes sense if we exclude (semantically) things like

Foo == Bar && inctement_baz()

that i couldn't reconcile

gonadic io
Feb 16, 2011

>>=
Increment_baz may well not get called in that code.

It's what lets
if (foo != null && foo.bar())
Work instead of throwing a null pointer exception when foo is null.

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


NihilCredo posted:

I don't write C, please tell me that's a compile error and not a "lol guess I'll just overwrite the next byte in memory #yolo" scenario

well these days I think it segfaults instead, but I dunno if that just applies to when you exit application heap or if you can overwrite other parts of your application's heap without causing a segfault

deffo not a compile time error though

edit:https://ideone.com/3lZQxw

not even a runtime error lol

Condiv fucked around with this message at 14:30 on Oct 30, 2017

cinci zoo sniper
Mar 15, 2013




gonadic io posted:

Increment_baz may well not get called in that code.

It's what lets
if (foo != null && foo.bar())
Work instead of throwing a null pointer exception when foo is null.

these function calls are really loving with my mind but the null pointer example is good, ty

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

NihilCredo posted:

I don't write C, please tell me that's a compile error and not a "lol guess I'll just overwrite the next byte in memory #yolo" scenario

the extra initializers are just ignored. there's warning in every major compiler, and c++ fixes this to be a compiler error

MrMoo
Sep 14, 2000

What is server side react.js, because :lol:

https://twitter.com/NetflixUIE/status/923374215041912833

Shaggar
Apr 26, 2006
Netflix must be making so much money to just throw it away on hardware to run slow rear end javascript

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
lol if you ever have to touch javascript in your work-life at all

akadajet
Sep 14, 2003

Shaggar posted:

Netflix must be making so much money to just throw it away on hardware to run slow rear end javascript

Reminder the Ruby and PHP are still popular choices.

Shaggar
Apr 26, 2006
php can probably be made pretty fast on the right runtime since its just a template language, but ruby and js probably would fight for worst performance title.

akadajet
Sep 14, 2003

Shaggar posted:

php can probably be made pretty fast on the right runtime since its just a template language, but ruby and js probably would fight for worst performance title.

nah, it's not even close
https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=node&lang2=yarv

Chalks
Sep 30, 2009

Just reviewing some typescript code

code:
this.$parent.$emit("closeMakePublicModal", this.value == "true" || this.value === "true" || this.value === true);

MrMoo
Sep 14, 2000

CRIP EATIN BREAD posted:

lol if you ever have to touch javascript in your work-life at all

I spent all Friday converting a single threaded webapp into a co-operatively scheduled app and binge watching Stranger Things 2. Just look at this masterpiece,
JavaScript code:
requestIdleCallback(() => {
        fetch(json.data)
        .then(response => {
                return new Promise(function(resolve, reject) {
                        const paint = (deadline) => {
                                if(deadline.timeRemaining() < 10)
                                        return requestIdleCallback(paint);
                                response.blob()
                                .then(blob => resolve(blob))
                                .catch(error => reject(error));
                        });
                       requestIdleCallback(paint);
                });
        })
        .then(blob => {
                return new Promise(function(resolve, reject) {
                        const paint = (deadline) => {
                                if(deadline.timeRemaining() < 10)
                                        return requestIdleCallback(paint);
                                createImageBitmap(blob)
                                .then(imageBitmap => resolve(imageBitmap))
                                .catch(error => reject(error));
                        });
                       requestIdleCallback(paint);
                });
        })
        .then(imageBitmap => {
                return new Promise(function(resolve, reject) {
                        requestAnimationFrame(() => {
                        	draw();
                                imageBitmap.close();
                                resolve();
                        });     
                });
        })
I spent all Saturday converting that app into a multi-threaded app whilst binge watching Wanted. Go figure it simplifies the code a lot.
JavaScript code:
ASYNC_IMAGE.createImageBitmap(json.data)
        .then(imageBitmap => {
                const paint = (timestamp) => {
                        draw();
                        imageBitmap.close();
                };
                requestAnimationFrame(paint);
        })
All because some random PNG takes 30ms to decode :bang:

MrMoo fucked around with this message at 16:43 on Oct 30, 2017

Sapozhnik
Jan 2, 2005

Nap Ghost
why aren't you using async/await

MrMoo
Sep 14, 2000

Only just starting to rollout Chrome 55+ to support it. I'm already lucky to be beyond 52 so I can call imageBitmap.close, 1GB/s garbage otherwise :lol: All the desktops are stuck on Chrome 46 to support Java and IDC's applet MarketQ.

MrMoo fucked around with this message at 16:41 on Oct 30, 2017

motedek
Oct 9, 2012

actionjackson posted:

Hello I'm a biostatistician and I don't know any "real" languages, just SAS and R. Am I confined to the #datascience thread or can I post in YOSPOS tyia

greetings, almost all code in these langs is terrible

akadajet
Sep 14, 2003

Sapozhnik posted:

why aren't you using async/await

why is he using more than 2 spaces for indentation?

Main Paineframe
Oct 27, 2010

CRIP EATIN BREAD posted:

lol if you ever have to touch javascript in your work-life at all

javascript is like the least bad thing I have to work with

tef
May 30, 2004

-> some l-system crap ->

honest answer: something like this from 2009

http://web.stanford.edu/~ouster/cgi-bin/papers/fiz.pdf

the long and short of it is that a lot of how we approached mvc was kinda bunk, and applet like apis, or building a component tree and calling render() is much better for re-use than keeping your html, and your sql in different directories

but javascript wasn't fast enough to do components client side at first, and trying to write your own dom api server side, on the other hand, is a total pain in the rear end. everyone gives up and concatenates strings or uses templates. your component library kinda has to be in javascript too, or you have to be able to compile your widget's logic down to javascript to do it.

now react exists, and sure enough, it was built for doing more interactive components client side

but components are great, here's enough of a dom in serverside javacript that you can render, and send the html over the wire.

in some ways, we have always been doomed to reimplement X11

the shadow-dom stuff looks neat though

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

tef posted:

in some ways, we have always been doomed to reimplement X11

this is actually a great way to describe all this

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

tef posted:

but components are great, here's enough of a dom in serverside javacript that you can render, and send the html over the wire.

Something like this is why I don't feel like a complete monster for having built a system that used a headless browser to render templates, then inline all images and strip all sensitive code / data to produce a single Fat HTML file

fake edit: said fat HTML file was distributed by email and inline images were too big, I actually had them all so that they would be unzipped and displayed on page load

i AM a monster

Sapozhnik
Jan 2, 2005

Nap Ghost

tef posted:

honest answer: something like this from 2009

http://web.stanford.edu/~ouster/cgi-bin/papers/fiz.pdf

the long and short of it is that a lot of how we approached mvc was kinda bunk, and applet like apis, or building a component tree and calling render() is much better for re-use than keeping your html, and your sql in different directories

but javascript wasn't fast enough to do components client side at first, and trying to write your own dom api server side, on the other hand, is a total pain in the rear end. everyone gives up and concatenates strings or uses templates. your component library kinda has to be in javascript too, or you have to be able to compile your widget's logic down to javascript to do it.

now react exists, and sure enough, it was built for doing more interactive components client side

but components are great, here's enough of a dom in serverside javacript that you can render, and send the html over the wire.

in some ways, we have always been doomed to reimplement X11

the shadow-dom stuff looks neat though

what? no

how the hell is react in any way like x11

akadajet
Sep 14, 2003

Sapozhnik posted:

what? no

how the hell is react in any way like x11

idunno but it sounds smart

Sapozhnik
Jan 2, 2005

Nap Ghost

MrMoo posted:

Only just starting to rollout Chrome 55+ to support it. I'm already lucky to be beyond 52 so I can call imageBitmap.close, 1GB/s garbage otherwise :lol: All the desktops are stuck on Chrome 46 to support Java and IDC's applet MarketQ.

why aren't you using babel

akadajet
Sep 14, 2003

Sapozhnik posted:

why aren't you using babel

babel's transpilation of async await requires a big ugly generator runtime for some reason.

akadajet
Sep 14, 2003

it also makes source map debugging unusable

Sapozhnik
Jan 2, 2005

Nap Ghost
x11 is an async rpc protocol for bitmapped rendering that also provides an event stream

x servers do not host any application logic

display postscript i guess in some old incarnations runs imperative code on the renderer side of things but even then it's an immediate-mode rendering api.

react is a tree of stateful thunks. there is a scene graph and there is absolutely client-side intelligence involved.

Sapozhnik
Jan 2, 2005

Nap Ghost
react is pretty drat cool though. i might do a brief effortpost about it for non-js people because it has some very neat ideas in it that are fun to talk about

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

gonadic io posted:

there are no good programmers though.

also computers are so complex there's absolutely no way to actually understand what's going on unless you're writing in the rawest of assembly/most trivial peripheral bit twiddling so we just throw code out there and hope it looks like it works.

There's just so much poo poo to know that no one can know it all and there are a few basic orientations that people seem to take to that fact:

"I know almost everything, I'm SOOO good!" Ah, this is cute in middle schoolers, mildly worrying in high schoolers, and a pain in the butt in coworkers. Nothing wrong with enjoying a feeling of having attained some significant knowledge but this type will sometimes want to take vengeance when a situation shows that they don't know something. And there are lots of things this person doesn't know because they are a human

"I'm an expert in the following areas and technologies... and everything I don't know is not really worth learning." Just fine as a coworker as long as they never have to leave their lane or evaluate anyone else's stuff, so Not Fine Actually over a long enough timeline. Still too personally invested in Their Precious Skills

"There's a bewildering amount of stuff out there; I know how to not gently caress up some of it in the following areas and learn as I go" the actually good philosophy

IMO

tef
May 30, 2004

-> some l-system crap ->

Sapozhnik posted:

x11 is an async rpc protocol for bitmapped rendering that also provides an event stream

x servers do not host any application logic

display postscript i guess in some old incarnations runs imperative code on the renderer side of things but even then it's an immediate-mode rendering api.

react is a tree of stateful thunks. there is a scene graph and there is absolutely client-side intelligence involved.

i meant more about in terms of:

x11 provides a simple api for interfaces: bitmaps, events

we build widget sets atop to provide things over it, patching over the lack of things we don't have

then we get things like xdri and substantial architectural changes that basically violate the whole design principle and some other goddam extension that i can't remember the name of

what was previously a gui over a network became a janitor for local processes.

anyway

we had html, as a way of interacting with remote document collections
we brought in forms, widgets, etc, but we hacked over it with css and javascript
and now, although most of us have moved to widget sets, they're still built in terms of simpler components,
but we also have localstorage and a litany of other extensions

what was a document platform is now an application platform

what was a sandbox is now something with desktop integraton (storage, notifications, etc)

what i wanted to say was, 'wanting to impement NeWS and doomed to reimplement X11' but i felt i was being too obscure

we always wanted the component system, it's just, that's far harder to adopt. too much to learn up front, too much to reimplement for compatibility. but we end up adopting the hack, and crufting on what we need , asking ourselves why this happened, despite maybe taking a decade to get the box model right

but, i also meant that the whole 'things get pushed backwards and forwards between the display and the application as power/resource/latency changes between them;'

meanwhile, we're re-inventing applets again. web assembly.

Shaggar
Apr 26, 2006
web assembly is gonna be good cause u can write c# instead of javascript+html

akadajet
Sep 14, 2003

Shaggar posted:

web assembly is gonna be good cause u can write c# instead of javascript+html

typescript already exists for people who wish they were writing .net

Adbot
ADBOT LOVES YOU

Shaggar
Apr 26, 2006
typescript is inferior to c# and still involves javascript at some point

  • Locked thread