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
Deacon of Delicious
Aug 20, 2007

I bet the twist ending is Dracula's dick-babies
jesus christ

c++ is the worst because of the people who use it & their discussions of it

Adbot
ADBOT LOVES YOU

MononcQc
May 29, 2007


:barf:

MeruFM
Jul 27, 2010
i don't understand why node.js exists.

Was it born facilitate the people who cannot 'learn' anything but javascript?

Shaggar
Apr 26, 2006
its for people who think javascript is good and don't understand why its not

double sulk
Jul 2, 2010

shaggar was right

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

Notorious b.s.d. posted:

What was the x11 experiment?

no experiment, it was a product: NCD WinCenterPro. all information about it is quietly dropping off the internet, but there is this cool little paper I love, it's so straightforward. some interesting passages:

Networking NT Applications Using X posted:

The display screen is represented by a single surface object. Each off-screen pixmap is another surface. Because the screen is represented as a single surface, all windowing operations are hidden from the display driver. This is a simplification which is welcome most of the time, but does make it difficult to support multiple depths or "visuals" in the X sense

you know, I knew this and I never put two and two together: you can't trivially redirect Windows windows to a remote X11 display, because windows are just regions of a single big surface - there is nothing "behind" a window: this is why, if you move a window above a nonresponding window, you will leave either a "track" or erase the underlying window to gray, respectively depending on whether the underlying window was configured to have a transparent fill or the default fill

at least, this used to be true until Windows Vista, which introduced a composited desktop, skipping an evolution phase directly to mapping each window to a polygon in 3D space. Windows XP had already introduced a limited form of compositing in the form of "layered windows" that you could apply an alpha channel to, but the real deal came in Windows Vista

few people know that Microsoft actually had the technology as early as 1999/2000, running on Windows 2000, as part of goofy UI experiment Task Gallery

Networking NT Applications Using X posted:

The only access to TCP/IP available in stock NT is via the WinSock API. This API does not meld well with the NT kernel I/O model and as such suffers badly in performance and functionality

this was very true in Winsock 1: back then, sockets weren't even guaranteed to be file descriptors. been no longer true for more than a decade, but for a long time you had to code very defensively around sockets. the story of how Winsock 2 fixed this while retaining backwards compatibility is the usual mix of horror and fascination

Notorious b.s.d. posted:

And I *definitely* want the story on concurrent instances for rdp/ts

I'm afraid it's not as interesting as I made it sound :shrug: writeup later

hackbunny fucked around with this message at 21:24 on Nov 8, 2013

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

hackbunny posted:

you know, I knew this and I never put two and two together: you can't trivially redirect Windows windows to a remote X11 display, because windows are just regions of a single big surface - there is nothing "behind" a window: this is why, if you move a window above a nonresponding window, you will leave either a "track" or erase the underlying window to gray, respectively depending on whether the underlying window was configured to have a transparent fill or the default fill

x11 has no backing storage for windows either. drawing is done by an Expose event, similar to how windows has WM_PAINT.

hackbunny posted:

at least, this used to be true until Windows Vista, which introduced a composited desktop, skipping an evolution phase directly to mapping each window to a polygon in 3D space. Windows XP had already introduced a limited form of compositing in the form of "layered windows" that you could apply an alpha channel to, but the real deal came in Windows Vista

layered windows were from windows 2000. even the start menu and menus had alpha fade ins.

Bream
Feb 3, 2013

Farmer's Barket
does anyone have any opinions about oreillys 21st century c?

http://www.amazon.com/21st-Century-Tips-New-School/dp/1449327141

the idea is interesting, but it also sounds a lot like something an hn would say, so i thought it would be better to check.

e.

quote:

This is a book about breaking tradition and keeping C punk rock. I don’t care to compare the code in this book to the original C specification in Kernighan & Ritchie’s 1978 book. My telephone has 512 megabytes of memory, so why are our C textbooks still spending pages upon pages covering techniques to shave kilobytes off of our executables?

maybe this is not the book for me.

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

MeruFM posted:

i don't understand why node.js exists.

I know, c and inetd are good enough for anybody.

Deus Rex
Mar 5, 2005

shrughes posted:

C++ is bad because its destructors don't take parameters, which means that if object X's lifetime is naturally a sublifetime of object Y's, and if X needs Y to clean itself up, then you need to put a pointer to Y inside of X in order to do that cleanup. Things would be cleaner if the destructors took parameters -- you'd just pass in the pointer to Y to the destructor call, and it wouldn't be possible to exit scope without such a thing. In C you'd just call the cleanup function manually and this wouldn't be a problem. Go and D try to help with this problem a little by using defer statements or scope(exit) statements (except with D this is just another frilly language "feature") but in C++11 really destructors should take arguments and smart pointers could even take them with a C++11 variadic argument list.

how would destruction of automatic objects on stack unwinding work if destructors could take parameters, i.e.:

C++ code:
struct Bar {};

struct Foo {
    ~Foo(Bar *b) {
        // clean up with *b
    }
};

void do_first_thing(Bar *b) {
    Foo f;
    throw std::exception();
    delete f(b);
}

void do_things() {
    Bar b;
    try {
        do_first_thing(&b);
    } catch (std::exception e) {
        // handle error
    }
}
what happens here?

MrMoo
Sep 14, 2000

Suspicious Dish posted:

x11 has no backing storage for windows either. drawing is done by an Expose event, similar to how windows has WM_PAINT.

X11 does and it is optional and unsurprisingly all the big apps assume and abuse it and thus make LTSP and X11 terminals paperweights for "real" work as they cram full documents into it and crash when your terminal runs out of memory displaying a facebook page full of megapixel selfies.

http://tronche.com/gui/x/xlib/window/attributes/backing-store.html

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Yes, I know about the backing-store property. The X server is implementation is free to ignore it, and we removed the initial implementation for quite a long time until we rewrote it to be implemented on top of manual composite redirection (see composite spec).

Deus Rex
Mar 5, 2005

MeruFM posted:

i don't understand why node.js exists.

Was it born facilitate the people who cannot 'learn' anything but javascript?

<dentist> that's why node.js exists: terror at the thought of having to learn another language (because JS is so full of pitfalls that they assume all languages are this bad)

MeruFM
Jul 27, 2010

Zaxxon posted:

I know, c and inetd are good enough for anybody.

it's built on a language designed to manipulate html document elements

sorry for your loss though

Notorious b.s.d.
Jan 25, 2003

by Reene

MeruFM posted:

i don't understand why node.js exists.

Was it born facilitate the people who cannot 'learn' anything but javascript?

it was born because it was possible

v8 was a pre-existing javascript implementation that was a.) fast enough to serve content and b.) not dependent on any browser components

it was natural that someone would attempt to bodge it together with a web framework

Notorious b.s.d.
Jan 25, 2003

by Reene

hackbunny posted:

no experiment, it was a product: NCD WinCenterPro. all information about it is quietly dropping off the internet, but there is this cool little paper I love, it's so straightforward. some interesting passages:

is there anything keith packard HASN'T done with X11?

he's written hundreds of papers, hacked on X11, xfree86, and X.org again, written his own X server several times (kdrive, xgl), apparently gone from embedded X11 to windows NT terminal servers, crikey

i guess once you have a specialisation going...

MononcQc
May 29, 2007

people really wanted to reuse the notoriously high-quality front-end javascript libraries into the back end.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
now keithp's working on present and dri3 which are cool.

also xgl was dave reveman.

power botton
Nov 2, 2011

same now I'm using vega to generate PNGs offline using node so along with my link to the web report i can show an actual mini thumbnail of what the user is about to see

its beautiful. thanks d3. thanks vega. thanks node.

shrughes
Oct 11, 2008

(call/cc call/cc)

Deus Rex posted:

how would destruction of automatic objects on stack unwinding work if destructors could take parameters, i.e.:

C++ code:
struct Bar {};

struct Foo {
    ~Foo(Bar *b) {
        // clean up with *b
    }
};

void do_first_thing(Bar *b) {
    Foo f;
    throw std::exception();
    delete f(b);
}

void do_things() {
    Bar b;
    try {
        do_first_thing(&b);
    } catch (std::exception e) {
        // handle error
    }
}
what happens here?

There, the code doesn't compile.

I don't know what the syntax would be, let's say, for the case of local variables, it's some statement

heres_how_you_destroy f(b);

Then you'd have to write

code:
void do_first_thing(Bar *b) {
    Foo f;
    heres_how_you_destroy f(b);
    throw std::exception();
}
Note that the heres_how_you_destroy statement doesn't have any side effects, it just adds some information to the next closing curly brace (in a manner of speaking). It would be invalid for the statement to reference a variable that doesn't exist when the variable f needs to be destroyed (any variable declared after f in the same scope or inside an inner scope).

By default the lack of a heres_how_you_destroy statement for a given variable is equivalent to having a statement heres_how_you_destroy v();

Or maybe you could come up with a better syntax, because that's probably not what you'd end up with after careful consideration. (Maybe when defining the class you could tell it how to map constructor arguments to destructor arguments, which would only be applicable in the case of creating/destroying local variables.)

This would mostly be useful for resource-frugal situations, probably where you have objects allocated on the heap moreso than on the stack, so the stack based syntax is not that interesting to me.

Edit: deus rex pointed out you'd have to put your heres_how_you_destroy statement before any function call that isn't noexcept. You should also be able to specify the destruction through some sort of bastardized finally block.

shrughes fucked around with this message at 00:30 on Nov 9, 2013

Sapozhnik
Jan 2, 2005

Nap Ghost
i really can't get over the fact that all javascript numbers are floating-point

yes yes i know technically doubles have a 48-bit-ish mantissa so you can represent any 32-bit int precisely inside one but still that's just loving vile. everything's fine at smaller magnitudes but once your numbers get big enough they sort of just silently become mushy instead of having a well-defined overflow condition. though c is hardly better in that you can't portably catch or saturate overflows even though this is something you might want to do from time to time.

node.js seems like a more fashionable and more restricted lisp. given the psychological tendencies of the sort of people who are attracted to lisp it probably explains a lot.

power botton
Nov 2, 2011

didn't twitter run out of numbers so now some tweet ids are long strings and some are numbers and askjaskjlahklsjd

Notorious b.s.d.
Jan 25, 2003

by Reene

Mr Dog posted:

i really can't get over the fact that all javascript numbers are floating-point

yes yes i know technically doubles have a 48-bit-ish mantissa so you can represent any 32-bit int precisely inside one but still that's just loving vile. everything's fine at smaller magnitudes but once your numbers get big enough they sort of just silently become mushy instead of having a well-defined overflow condition. though c is hardly better in that you can't portably catch or saturate overflows even though this is something you might want to do from time to time.

a language designed in 4 weeks in the mid 90s for dhtml dude

Mr Dog posted:

node.js seems like a more fashionable and more restricted lisp. given the psychological tendencies of the sort of people who are attracted to lisp it probably explains a lot.

at this point, this should be bannable

Sapozhnik
Jan 2, 2005

Nap Ghost

Notorious b.s.d. posted:

at this point, this should be bannable

the hell does that mean?

Opinion Haver
Apr 9, 2007

git clone trooper posted:

didn't twitter run out of numbers so now some tweet ids are long strings and some are numbers and askjaskjlahklsjd

they have an id and an id_str field and if you use the id field for tweets with id greater than 2^32 wacky things will happen:

code:
> x = {"id": 10765432100123456789, "id_str": "10765432100123456789"}
Object {id: 10765432100123458000, id_str: "10765432100123456789"}
> x.id.toString() === x.id
false
> x.id
10765432100123458000

Notorious b.s.d.
Jan 25, 2003

by Reene

Mr Dog posted:

the hell does that mean?

comparing lisp and js is laughable bullshit from HN, and it gets debunked and laughed at every 100 pages or so

i'm too lazy to copy/paste the last such attempt

MeruFM
Jul 27, 2010

Opinion Haver posted:

code:
> x.id.toString() === x.id
false
> x.id
10765432100123458000
i'm not anti-stateful but this behavior is kinda lol even without the integer translation error

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

MononcQc posted:

people really wanted to reuse the notoriously high-quality front-end javascript libraries into the back end.

the position of my cursor meant i somehow read this as "the notoriously high-fatality front-end javascript libraries"

Notorious b.s.d.
Jan 25, 2003

by Reene

coffeetable posted:

the position of my cursor meant i somehow read this as "the notoriously high-fatality front-end javascript libraries"

and yet we do not regret kickstarting our nodejs CAN-Bus controller for "the ultimate driving machine"

brave hacker soldiers pushing the limits of automotive disruption

Scaevolus
Apr 16, 2007

Opinion Haver posted:

code:
> x = {"id": 10765432100123456789, "id_str": "10765432100123456789"}
Object {id: 10765432100123458000, id_str: "10765432100123456789"}
> x.id.toString() === x.id
false
> x.id
10765432100123458000
Of course === won't say a String and a Number are equivalent.
code:
> x.id.toString() == x.id
true

Zlodo
Nov 25, 2006

shrughes posted:

destructor arguments
:goonsay:

let me show you why none of this idiotic poo poo is necessary bc the compiler does an amazing optimization job that goes way beyond just removing the pointer to the lockable object in your previous example (and bc this destructor parameter idea is really loving retarded)

i compiled this using clang:

code:
#include <mutex>
#include <iostream>

using namespace std;

class Butt
{
    public:
        void fart()
        {
            unique_lock< mutex > lock( m_mutex );
            cout << "lol butts\n";
        }

    private:
        char m_somestuff[256];
        mutex m_mutex;    
};

int main( int argc, char** argv )
{
    Butt b;
    b.fart();
}
using clang's libc++ whose implementation of unique_lock is this (including only the ctor and dtors used there and removed some things for readabilty):

code:
template <class _Mutex>
class unique_lock
{
public:
    typedef _Mutex mutex_type;

private:
    mutex_type* __m_;
    bool __owns_;

public:
    explicit unique_lock(mutex_type& __m)
        : __m_(&__m), __owns_(true)
    {
      __m_->lock();
    }

    ~unique_lock()
    {
        if (__owns_)
            __m_->unlock();
    }
oh noes, the fart function will have on its stack a pointer (__m_) to a mutex which will actually be the this pointer + 256, what a waste! and a bool too! goddamn we need destructor arguments

but here's the generated assembly (w/o some noisy stuff and exception handling stuff which is irrelevant here):

code:
main:                                   # @main
-> main bc the butt ctor and the fart function were inlined

	pushq	%r14
	pushq	%rbx

	subq	$296, %rsp              # imm = 0x128
-> this is where the butt is allocated on the stack by subtracting its size

	leaq	256(%rsp), %rbx
-> rsp = butt. rsp + 256 = the m_mutex member within the butt. that __m_ mutex pointer that you wanted to get rid of with your ridiculous
solution is actually stored directly into the rbx register

	xorps	%xmm0, %xmm0
	movups	%xmm0, 272(%rsp)
	movups	%xmm0, 256(%rsp)
	movq	$0, 288(%rsp)
-> here's the part of butt's ctor where the fields are initialized. this was probably a memset call in mutex's constructor that clang replaced
with a few instructions that clear a 128 bits register and write it in memory to clear 16 bytes at a time

	movq	%rbx, %rdi
	callq	_ZNSt3__15mutex4lockEv
-> here's the call to mutex::lock(), directly passing rbx as its this pointer
wait, where did that unique_lock instance even go? turns out clang figured it could split that small class into two variable each containing one of its fields
and then other optimizations got rid of those variables. like that __owns_ poo poo? it was just set to true on the only code path through the function so clang
figured it was loving useless and completely removed it from existence


	movl	$_ZNSt3__14coutE, %edi
	movl	$.L.str, %esi
	callq	_ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc
-> the cout call

	movq	%rbx, %rdi
	callq	_ZNSt3__15mutex6unlockEv
-> release the mutex, directly reusing the mutex address that is still in rbx to call mutex::unlock()

	movq	%rbx, %rdi
	callq	_ZNSt3__15mutexD1Ev
-> call the mutex destructor

	xorl	%eax, %eax
-> clear eax to do the return 0 that i forgot like a noob

	addq	$296, %rsp              # imm = 0x128
	popq	%rbx
	popq	%r14
	ret
turns out my "handwaving" of compiler optimizing out fields and even entire classes from existence was right and that your an idiot looking for a complicated solution where just doing the obvious thing works fine

Zlodo fucked around with this message at 01:36 on Nov 9, 2013

Sapozhnik
Jan 2, 2005

Nap Ghost
jfc you dragged out one of the least interesting and contentious aspects of C++ and dragged it out into a gigantic page long spergfest

gj

Zlodo
Nov 25, 2006

Mr Dog posted:

jfc you dragged out one of the least interesting and contentious aspects of C++ and dragged it out into a gigantic page long spergfest

gj

yw

Scaevolus
Apr 16, 2007

Zlodo posted:

let me show you why none of this idiotic poo poo is necessary bc the compiler does an amazing optimization job that goes way beyond just removing the pointer to the lockable object in your previous example (and bc this destructor parameter idea is really loving retarded)
The fact that everything got inlined and useless variables eliminated in your trivial example is not representative of actual code. Tiny benchmarks often run into this problem: most of what they do is useless, so a sufficiently smart compiler will remove it entirely.

Zlodo
Nov 25, 2006

Scaevolus posted:

The fact that everything got inlined and useless variables eliminated in your trivial example is not representative of actual code. Tiny benchmarks often run into this problem: most of what they do is useless, so a sufficiently smart compiler will remove it entirely.

it did call mutex::lock and mutex::unlock so the locking did take place

PrBacterio
Jul 19, 2000

shrughes posted:

(Maybe when defining the class you could tell it how to map constructor arguments to destructor arguments, which would only be applicable in the case of creating/destroying local variables.)
theres already a way in which you can pass on constructor arguments to the destructor, its called a "member variable" maybe you should look it up

Opinion Haver
Apr 9, 2007

Scaevolus posted:

Of course === won't say a String and a Number are equivalent.
code:
> x.id.toString() == x.id
true

i meant to type == x.id_str and didn't notice, whoops

tef
May 30, 2004

-> some l-system crap ->

Mr Dog posted:

i really can't get over the fact that all javascript numbers are floating-point

use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays :q:

quote:

yes yes i know technically doubles have a 48-bit-ish mantissa so you can represent any 32-bit int precisely inside one but still that's just loving vile. everything's fine at smaller magnitudes but once your numbers get big enough they sort of just silently become mushy instead of having a well-defined overflow condition.

as in comparsion to how other languages handle numeric overflow.

quote:

node.js seems like a more fashionable and more restricted lisp. given the psychological tendencies of the sort of people who are attracted to lisp it probably explains a lot.

lol, it's nothing like a lisp, no-one writes mini-languages and semantic extensions at the same rate as lisp, or even ruby.

Notorious b.s.d.
Jan 25, 2003

by Reene

Mr Dog posted:

jfc you dragged out one of the least interesting and contentious aspects of C++ and dragged it out into a gigantic page long spergfest

gj

this is how C++ users establish dominance and compete for mates

Adbot
ADBOT LOVES YOU

MrMoo
Sep 14, 2000

MeruFM posted:

i don't understand why node.js exists.

The premise is sound, you have to pre-validate user input on the client in JavaScript because the Internets is slow, and you have to validate everything on the server because you cannot trust the client. Implementing the same checks twice is duplicate effort and increased chance of defects.

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