Hello. My name is Robin Weissman and I serve as Pennsylvania's Secretary of Banking and Securities. Financial fraud is the crime of the 21st century. I want to thank you for taking the time to learn more about how we can work together to protect the most vulnerable members of our families, as well as our friends and neighbors. Thank you. One in five of everybody you see on these sidewalks in about 20 years will be age 65 or older. In 20 years after that, 50 percent of them are going to have some cognitive impairment dementia that will make them extremely vulnerable to being defrauded of their money. Each year, con artists swindle elders out of more than two and a half billion dollars.  Older people just don't have time to make up for the losses. Older people control 70 percent of the wealth in this country. So the money is there and you have professional scam artists who know where the money is and they've developed a great set of tools to go get it. People look at me and figure number one, she's old. Number two, she's a woman. Number three, she won't be able to do anything about it anyway. So why do we become more vulnerable to financial fraud as we age? What actually happens to our brains? The older brain shrinks in size. There's less fluid in it. It's not as big as it used to be. The neurons, electrical signals, the pathways for cognitive function are all impaired. Then when you overlay cognitive impairment on this normal age-related change, then you have an individual who is not fully capable of making sound financial decisions. Karen Wilson understands that all too well. She was incapacitated. She was in a situation where she was completely broke. She had no money left. Helplessly, she watched as her mother's cognitive capacity started to decline. She was really a wonderful mother, really sweet and calm and caring. I'd taken her shopping and we went into a jewelry store and just for fun like a breakfast at Tiffany's moment. I looked at a ring and I said, I love this, do you? And she said, yeah, she said, I'll buy it for you. And I said, mother, it's like $60,000. And she goes, that's okay, I have my checkbook. And I knew she was being serious and I knew that she was not okay mentally. People with early onset dementia are more willing to gamble literally with their money. And of course, some dishonest quote unquote money managers take advantage. And the result? Countless horror stories. I have an aunt who lives in the Midwest. One afternoon, she got a phone call and during this phone call, she was convinced to send $5,000 Western Union, which she did. So she called the police and they tried to trace it. And of course, by that time, the money was gone. A gentleman in Houston was treated for having fallen to the Nigerian email scam. He had about $750,000 and he lost all but $35,000. And he felt like if he gave that last $35,000, he'd got all his money back. Even legitimate everyday investing opportunities can become a nightmare. Yes, it's very frustrating. They look at you and think, oh, she doesn't have anything left up there. We can rip it off and it'll be okay. And it's not okay. Hand in hand with financial abuse is the shame of having been taken. It's embarrassing to fall for a high-pressure sale or a friendly voice on the phone promising fantastic returns. We decided to take her checking account out of her hands because there were checks being written that we couldn't document. And we should have started preparing 15 or 20 years earlier. When a loved one is in cognitive decline, family members can be in massive denial, unable to reverse the roles of who was caring for whom. She died in a deficit situation. Somebody had worked that hard her whole life. I'm guilty. I wasn't there. I didn't do the right things. So what can we do to stem the rising tide of financial abuse? Financial fraud is elder abuse, pure and simple. On our intake form in our office, we do have a question, are you having financial difficulties or stress? And if appropriate, we can help refer people to community resources. Even people with mild cognitive impairment lose the ability to make good financial decisions. People with mild cognitive impairment can go to the opera, play golf, go out to dinner with friends, have fun, almost be like their old selves with the exception of managing their money. They make financial errors four times that of persons who don't have mild cognitive impairment. There are signs that can help health care providers and family members identify a potential problem. Has a patient or relative become socially isolated? Have they made questionable financial decisions or been asked to change their will? Have you noticed deterioration in their ability to make daily decisions? The worst thing you can do is be disconnected and isolated. Your parents need for you to take control. They need to have one of their children manage their health care and manage their investments at the same time. Everybody needs to stop and think of themselves as someday being a frail, older person and asking him or herself, what type of systems do I want to have in place when it's my turn? That's our goal is to help everybody have as good an old age as they can. I still have complete faith in people. I keep thinking that maybe they just have had a bad day or have had a situation. You kind of hate to give up on people. So you just keep hoping that things get better. Hello, my name is Teresa Osborn and I serve as Pennsylvania's Secretary of Aging. Each one of us has a responsibility to keep older Pennsylvanians safe from harm and ensure that they are treated with the dignity and respect they deserve. On behalf of the Pennsylvania Department of Aging, thanks for watching.


This is Mises Weekends with your host Jeff Deist. Hey ladies and gentlemen welcome back once again to Mises Weekends. I'm joined by someone I'm sure most of you know Michael Malis. He's an author. He co-writes a lot of books with celebrities. He's on Fox shows like Kennedy all the time and at least for our purposes he's perhaps most famous for his book Dear Reader which is an in-the-voice autobiography from the perspective of Kim Jong-il in North Korea so what we're talking about today is sort of in scare quotes the economics of North Korea because obviously Michael has been there and has a perspective that Michael I'm going to say I can't imagine there's more than maybe a hundred Americans or so who have even decided to go there since the Korean War but maybe I'm wrong you talk about it not being that easy that hard to visit. I'm sure it's more than a hundred to be fair I mean because it's been what 60 years but it's not a huge number at all.  Well so what's interesting is it's difficult to find aggregate economic data about North Korea. GDP is this sort of you know put your finger in the air type prediction. Some people say it's about 30 billion dollars which is maybe a little over a thousand dollars per capita so what's interesting to me is is by that measure alone if that's ballpark true it's not necessarily among the five or ten poorest places on earth. Would you agree or disagree with that? I mean the poverty is not the problem do you know what I mean if they were just poor I wouldn't care about them one way or another so you know so to speak it's that's doesn't isn't what makes North Korea uniquely terrible well so when you when you arrive did they require you to exchange US dollars for their local currency? No no no so here's why North Korean tourism became a thing and this just speaks to something that all the listeners will be very interested in. Before the Cold War ended Kim Il-sung the great leader played the Soviet Union and China against each other and basically North Korea was a literal welfare state so what they did is they would have something called friendship prices so Soviet Union would send North Korea oil and North Korea in barter would sell them like crappy socks that Russians could have no use for and they would call it a wash so by this way they subsidized the North Korean economy however with the collapse of the Soviet Union no one neither China nor now Russia wanted to subsidize this insane regime so they without oil I talked about this in my book it was an inversion of that great Leonard Reed SAI pencil because without oil you can't run the factories without factories you can't produce fertilizer without fertilizer you can't grow enough food in this mountainous country and that led to a famine of one to two million people so which was a genocide so what they desperately want for them tourists is hard currency because obviously we're not big fans of the US Fiat dollars but the US Fiat is a lot less of a rights violation than the North Korean currency so they want you to spend your US dollars or RMB or euros because then that will something that will be a hold of value I think it's illegal for foreigners to use they have different currencies for different people so I believe it's illegal for foreigners to use North Korean currency so it's interesting they have the central people's committee they actually do have industries they're strictly planned it looks like they have some mining some degree of agriculture, farming, fishing did you I know you travel in the countryside up to the DMZ did you see much in the way of of anything industrious happening you know all these Kami countries there it's not like the hippies of the left they are real big on industry and factories and all this stuff the North Korean seal has like a dam you know these are like power wires so they took you you come to New York or even if I went to Auburn you're not taking me to the coal mine or you're not taking me to the Con Ed plant in North Korea oh yeah we went to the water bottling factory we went to the hospital one of the things that they make people go to is this barrage which is a kind of dam that they built and you have to climb like 10 stories of stairs they could tell you about this great barrage it's like the fourth biggest in the world or something and all the tourists who go there are like you're just showing me a dam you know I kind of looked at a picture of this back home so they're very big on their industry and very proud of it because that's their claim that before the great leader Kim Il Sung drove out the wicked Jap devils as they call them you know he brought industry to North Korea and turned it from an agrarian country into the 21st century that's a very Stalinist idea that you know once the communists take over they what was it Len's quote is that communism is socialism plus electricity why do you think that the Chinese don't do more why don't they sort of take them as a client state do you think you think North Korea is an embarrassment for China North Korea is clearly an embarrassment for China and I'll give you a couple of examples during the 70s they built a I think it's story statue of the great leader Kim Il Sung and Pyongyang you can see a photo of me next to that statue on my website and they played it in gold and the Chinese leadership at the time said you know we're communists maybe a giant gold plated statue isn't what we're about so they're like good point and they change it to bronze so that was one of the problems that they had between China and North Korea but North Korea in their propaganda and in their worldview they revel in the fact that they're a country that's the size of Pennsylvania obviously they wouldn't use that reference and they are defying China the United States Russia Japan they call themselves a shrimp among whales so the fact that China will say do this and that the Marshall Kim Jong Un concerned the population say look we're getting pressure from all these other countries that are bigger than us but I'm so tough I'm so great I'm defying them and he has a point. When you look at the people you met who obviously your guides and some other people you met were relatively fortunate by North Korean standards and clearly they're steering you around as to where you can go but did you gain any sense of sort of the personal economics of individuals there are they their habitations their heat air conditioning diet I mean all these things we hear about but we don't you know it seems very amorphous to us how they're sort of day to day personal economics are I mean they they took us to a farm and we there was like a model family you know what I mean a grandma and grandkids the grandkids are filthy I mean quite literally filthy I mean the home is fake because they've got a TV and all this other stuff but everywhere you go in North Korea everywhere there is a crack on the wall a stain on the carpet some rust in the in the bathroom even on everywhere you go there's a fly even on the on the plane there was a fly which is like a such a biblical symbol of evil and corruption you go to their Central Park they have this big fountain the water is not running the lights aren't on it's covered in mildew I mean the decay and the scent like I have I brought that books from North Korea you can smell that decay in these books it's impossible to describe it's almost like a seller but worse so when you're in Pyongyang at night capital city right any capital city the fact that half the buildings don't have electricity I mean and this is as good as it gets so everywhere you go this idea that some people have in the west that you go to Pyongyang and it's like going to Epcot it is not at all like that it is completely just decaying and I think one of the reasons is if you're pointing out that things are broken or wrong that in effect is criticized in the government suddenly so people know how to keep their heads down and their mouth shut you don't want to be a troublemaker although I was called a troublemaker by my guide but that's okay well how do they even have if we think about the economics is sort of a concentration camp how do they even have black markets I mean you talk about seeing people at the airport bringing western electronics but what do they have to even trade on a black market so a lot of times people go to China and bring back food so what one of the good things about the weakness of the regime is that the thugs the police the enforcers are much more susceptible to bribery because basically it works like a tax you'll have a black market in a public square it's open you know open air the cops will come down he gets his cut looks the other way and you have this exchange and the government every so often tries to crack down but since they can't provide food their hands are essentially being tied so this is a great example of kind of this you know a lot of libertarian talk about agorism you know having the black markets supersede the state of Korea and what's very very healthy about it is you can tell me all day long and convince me that the great leader Kim Il Sung is the most wonderful person to ever live that's fine you're not going to be able to convince me that it's great that my kids are starting I mean that's a very hard sell to make so at the end of the day you could have this cognitive dissonance that yet great leader Kim Il Sung is the best person ever it's the Americans fault that we don't have food fine but I'm still not going to obey the law because I'm going to make sure I have food in my and what's really sick about you know there's so many layers of people with North Korea during the 90s when the famine hit and they refused to allow food in the people who were the most loyal were the first ones to starve because they thought food's coming food's coming I trust the leader he's always provided us in the past and the ones who are like this is nonsense I got to look out for number one those are the ones who managed to get food so I mean this talks about how the totalitarian state perverts any sense of decency and sanity in in peaceful relations between human beings what's interesting to me is the mysteriousness surrounding Kim Jong-il usually excuse me Kim Jong-un usually they're you know in a lot of poor countries the leaders live in in these gilded palaces and are very ostentatious with their wealth and their roles Royce's and such whereas here you said you know you don't even really know which government building is which and there's no great palace for the supreme leader right I mean they weren't even told that he existed until I think it was 2009 so the leadership is not something that's discussed in the sense that we can talk about you know the Kennedy family or the Clinton dynasty or the bushes they are treated as this kind of supernatural almost entities so the fact that recently Kim Jong-un is trotting his life around this is a very recent development during his lifetime it was not clear at all how many wives Kim Jong-il had he even became a bigamist because as I talk about my book his first wife was kept secret from his father the great leader Kim Il-sung because she was born she had she was previously married and so on and so forth so he got married again secretly so this family is not there's no books at the airport where you can learn what I mean yeah there are books about Kim Jong-il was like as a kid but this does not bear truth to reality well at least judging by you know your Korean guides your host that it doesn't seem like that like Koreans go around thinking that they're part of this communist ideology or even worshiping the Kim family that they're more just seeing themselves as Koreans and this is what they have to do is it did you sense any sort of sort of open ideological thought or is this just getting through the day I think when you're dealing with elites in cities just like here you're going to have you know how like in New York and I'm speaking so from Brooklyn and this is not something I admire but there's this snide contempt for like the heartland right it's just like oh we're better than them so when the people who I talked to in Pyongyang my guide she very much saw herself as this urban cosmopolitan figure she knew about slang from South Korea she was trying to present herself and in a sense she was because to even step foot in Pyongyang by law you have to be very high up in North Korean society so if you're living there and I mean let alone interacting with foreigners you are off the charts in terms of your status in that country that's being a celebrity effectively so she very much was aware of her status and here's one telling story in North and I was I was very much trying to empathize with her and see things from her perspective especially having been born in the Soviet Union at one point she talked about how during once a year everyone by law has to go the countryside and help with the rice harvest and naively I said oh that sounds really nice and Jeff you can imagine that actually it could be something that's fun like we're all doing this together maybe like a 4th July thing and she looks at me she's like yeah it's great and you know I felt stupid because you realize this woman who's like a millionaire and she has a lot of skills and like as Fru Fru as it gets for her it's like green acres it's like I gotta go with the hit and I asked her I said you know back home we look down on people at the countryside is it the same thing here she's like she literally said of course and it's which is so interesting because so much of their propaganda is the farmer the guy in touch with the soil these are the true people and she's like I mean the disdain from her was about this you know their propaganda is to create what they call a monolithic ideological system the idea that everyone in North Korea thinks with one mind it is not that way at all they are so normal and trying to be normal in the most abnormal country at Earth I was shocked and delighted by how easy it was to have a conversation with her. Well you know they're so close even compared we talked about the former Soviet Union but the Soviet Union had the entire West to look at in terms of prices technology media clothes music you name it I mean here we talk about the impossibility of calculation in a socialist system here other than a little trickle maybe of goods from China but otherwise how do they have an economy do they actually talk about the Central People's Committee they actually brag about their 5 and 7 year plans? Not anymore so here's another good example so you know what's funny with these commie states is that every so often they'll have a new movement right Sankovite I think was the Russian one like oh now we're going to start all working harder and faster at the same time even though that was our plan 3 years ago and our plan 10 years ago so they had something called the Cholima movement which you know it's funny because they'll steal an idea from Russia and pretend it's original so it's like oh it's completely different because ours has the symbol of a pegasus so the Cholima Cholima is there it's a pegasus it's their symbol of speed and I asked my guide I go what do you want me to send you from abroad if I could send you something and she said a Porsche and I said lady I'm not sending you a Porsche she said immediately she's quick I said lady I'm not sending you a Porsche and don't ask me to send you Cholima either she goes we have the original one here what do I need you to send it to me for so she was very very quick so again every so often they'll have these arguments but that has fallen by the wayside and that used to be very much the case and the great leader Kim Il Sung there would be the first 5 year plan and the 3 year plan I talk about this at length in my book and the big argument was are we going to have heavy industry or light industry it's these very kind of old school communist arguments and now I think that is not a thing whatsoever I think the congress meets very rarely and it's much more of a year by year situation. You know I saw some of your back and forth on Twitter with various people since obviously North Korea has been in the news with the Olympics and everything do you think that there are concentration camps secret concentration camps that maybe even your host didn't know about I mean do people whisper about refer to things or their gulags you know places where criminals are setting big numbers. There's clearly concentration camps you could see them on Google Earth there's a great organization called Human Rights in North Korea every year they'll have a different an update on the concentration camp system and there's different levels of camps some you get to leave some your death sentences I've heard very many conflicting reports from North Koreans I've spoken to and research about how much do the North Koreans know about these camps what is very known is every so often people disappear with their families and I spoke to one of my a refugee I knew and I said what did you think of this and she's like it was a good thing because clearly they did something wrong and you know they broke the law and we can relate to that because there's a lot of times if you see someone on TV going to jail you think okay it's a good thing they're going to jail you don't put two and two together that what they may have done is listen to a CD of you know South Korean music or something like that it's something that you have that you know you're taught a certain thing since you're a kid but yeah they very much are aware at any but that's the other misconception it's not the kind of thing where you know Jeff if I steal a pencil I'm going to camp it's not binary that like as soon as you do something wrong you're going to camp there's levels of punishment so people live in fear yeah going to camp but also a very common punishment is oh you're a college professor you trade the party now you're going to work be a farm hand for the rest of your life so yeah that's a far cry from the camp but it's still quite a step down that now you have to work the earth and you'll never have a second set of clothes. Do you think there's any chance I mean what would it take to get mobile devices into North Korea what would it take to get Wi-Fi beamed in from Cuba I know they have cell phones what would it take to open up in terms of communication internet so that that's what they have now is you'll have people in the northeast is where the people who are most disloyal to the regime are forced to live and there's the border between that and China is very porous so you will have like people who are in South Korea will call these brokers using like Chinese cell phones and communicate with their family back home and this is a very big mechanism for information to be getting into North Korea so one of the great things about information is if I want to smuggle guns if I want to smuggle drugs you know guns will set off a metal detector a dog will smell drugs information you can't bottle that up it costs nothing to move it costs nothing to transmit I tell it to you I still have it in my mind so it's very very very hard to control information especially in a gossipy culture like North Korea and that's been a very healthy thing where you know there's an expression I forget the exact expression but it's something how like you know how the walls have ears so people are very paranoid and there's certain things you just do not discuss unless it's with your family but there's levels you know so and there's also you know and I knew this growing up coming from a Soviet household how you can you know do double talk and tell tell the information but you have plausible deniability like for example you know back in the day my mom called her mom in Russia and would be like oh does your neighbor want to come visit America in March oh no that's bad weather in America you know what I mean even though someone's listening on the phone and everyone knows what's going on but you could still play dumb so there's all these little tricks that they have to work around the sensors and that's why in many ways the North Korean propaganda has changed and their hold is really weakening on the people year by year well last question for you is about demographics I read an interesting article from this hedge fund manager who says well there's a billion gallons billion barriers of oil in Korea and they have reasonably young demographics are people having kids I mean is it a is it a young country in that sense is there any hope that the demographics are going to change things I mean as sick as it sounds I would bet money that the old people died off because it's going to be very you're not having medical care it's going to be very easy to I mean life expectancy is not going to be very high so yeah people are having kids absolutely and that is and again it's the younger people are becoming much more cynical because they don't remember the so-called good times under the great leader Kim Il-sung he died in 94 when there was kind of food on the table when you did have you know China and the Soviet Union kind of protecting the North Korean regime when Kim and I talked about this in the book also when Kim Jong-il shortly before he takes over they had a propaganda campaign called let's eat two meals a day because they said having three meals a day is unhealthy so no one needs to be told this do you know what I mean so it's it's a very they don't remember what it was like when North Korea was strong and proud Well Michael Malis we're about out of time thanks so much for that I can't recommend the book enough my dear reader an unauthorized buyer for my son my 11 year old son loved it be sure to follow Michael Malis on Twitter and subscribe to his YouTube channel because he's going to start doing live feeds at YouTube so Michael thanks a lot again for your time ladies and gentlemen have a great weekend


Last year, over a hundred thousand children were injured in playground accidents because many people didn't realize the dangers there. To five-year-olds, a slide can be a menace, so teach them to hold on tightly, to watch out for other kids, and avoid places where little fingers can get crushed. Supervise children and keep accidents out of the playground. For free safety information, write CPSC Washington DC 20207 Product Safety. It's no accident.


Hello, I'm excited to be here at this fantastic conference. I think I have the longest title. Okay, where's the switch? Don't see the button. Okay, it's a little bit big. Better. Sorry. So the title could have been shorter. It could have been just how I was seduced by a technology. This talk is... I was fortunate to work at Interactive Things. I'm no longer with them. I trained another company one month ago. But this talk is very much a result of our collaborative efforts at Interactive Things to find a tool stack and architecture which allowed us to build the middle and larger scale interactive visualizations for the web. So especially Jeremy Stuckey put a lot of effort in that. So my background is computer science, software engineering. I started my career like in early 2000s. I worked mostly on UIs, web stuff and some data analysis. At some point I was so fascinated by one of Hans Rosling's videos that I decided to learn more about database. And I did a PhD with Enrique Bertini and Danila Lan. It helped to learn some basics. But the nitty-gritty... On the theoretical side, of course. But the nitty-gritty stuff of engineering data visualization that I had to learn by doing. And so I worked at Interactive Things that helped me a lot to learn lots of things. And before that I participated in some projects. I will show you very quickly because it's not a portfolio talk but so that you better understand what's my background, like some of the works I did. I've used many tools, Java, Adobe, Flex, which I kind of liked. JavaScript D3, Backbone, React. Lots of D3, lots of D3. React, Backbone, mapping stuff. So, yes. This is my current project. I work at a startup called Teralytics where we are looking at visualizing people mobility. So I'm the only one at the moment doing the front-end. By the way, if you want to join me, let me know. So there are lots of big data analysts. So it's big data about people moving in cities and so I'm building the front-end. So that's what I've built so far. It's kind of a dashboard where we have a sleeping map with showing how many people work in different streets at different times. And there will be more and more views, different controls. The views are interconnected. So it's like a dashboard which has to be scalable. So the architecture, I had to choose for that, has to be scalable, flexible and have a very good component model. So I chose React for that or rather an architecture enabled by React. And I'll try to explain you why today, why it makes sense. First, a little bit of history, so to say. So I think that visualization is a lot about communication, right? So we want to tell people what we know or we want to help data, so to say, to tell stories by themselves, right? That are hidden in the data. And the media is also very important, which we used to tell those stories. So our far ancestors left us these rock paintings which we can still enjoy, which is fantastic. Our not that far ancestors used paper and they could put more and more information on it, right? But it's not always a good thing, right? Because if you put too much data in one thing, it becomes very overwhelming and hard to understand what's going on, although it's potentially more informative. So we now have all those interactive devices, right? We have to deal, we have to take advantage of them because there is really a lot of potential. We can support interactive exploration. We can show one facet of the data at a time. And I personally believe that for addressing the challenges of which big data poses, interactivity is a key. So we don't have enough pixels to show all the data at the same time on the screen, right? So we have to summarize it. But if we summarize it, we reduce it and we have to allow the user to summarize it in different ways so it can be explored. WebJail will not solve all of the problems. Interactivity also helps to find personal stories. So users explore the data and they choose their path. They choose what they are interested in. And of course it can be more engaging if designed well. But it's very hard actually, I can tell you, to design a good interactive application. This is like a simple network exploration tool which allows to explore it on separate levels and has like different views. It cost me a lot of sweat to develop this and to make it work on different platforms also. So I mean, it's a simple thing. Why is it so hard? Why is interactivity hard, in fact? It's because with every new interactive feature we add to the system, we add a new potential state or potentially many states, right? Which the system can be in. And the more states we have, the more transitions we have between those states, right? It's a combinatorial growth and we have to model all those transitions. We have to make sure that they are still, that we always still have consistent representation of the data even when the transition is, after a transition run, right? And because we have so many of them it becomes very, very difficult to ensure that we are really doing it in a consistent way all the time. Do we really have to do it this way? Is there a way around? Maybe. So this is the great grammar of graphics by Lillian Wilkerson. What this book taught us? It taught us actually that nearly any statistical graphic can be expressed declaratively by defining a mapping from the data to some visual elements, right? We just define how data elements are transformed and what are the static properties of the graphical elements, geometric objects which are finally rendered by the computer. And it's beautiful because it's so simple and declarative, right? So it's basically defining a function. So if we are speaking about visualizations for the web, right? Function which maps data to DOM objects on our web page. And we know that this model works really well because there are so many implementations which have been developed so far and still are developed which are very successful. But are they really scalable in terms, like, if we have a more complex application with many components which depend on each other? I mean, how can we apply the same model? Does it work? Not directly. So this is an example of our work which we did for Neutriloed Zeitung, the Swiss newspaper. It tells a story about the events of the First World War. You can see that, like, it's a pretty complex interface. There are lots and lots of components. They are interdependent. There is, like, another separate view showing, like, the armies of different countries, their sizes, and when they engaged into the war. There are some additional views here. You can interact with the map as well. So it's a pretty complex application. It would have been much more difficult to build with D3 alone. So we used React to package the whole application. And so what does D3 have to offer for such larger applications? We have this reusable chart pattern, right? Which is very nice. It can help us to package one specific particular chart into, like, encapsulated component and then reuse it in different places. But it doesn't really tell us how to handle the whole application state, how the data flows in the whole application. It doesn't allow us, or doesn't tell us, at least, how to compose components, which is really important to build those middle and large-scale applications. And essentially it's always the same problem. We have many components which are interdependent. We have too many dependencies between them which are difficult to take care of so that it's consistent. So what has the industry... What has been the industry standard for developing large US embassies, right? For 30 years already. We have model controller and view. We have the data in the model. The view is what we see on the screen. And controller figures how to, like, controls the data flow between the model and controller and the view. If we speak about using it for database on the web, we can put the D3 part, the D3 code in the view, right? And we can, like, that the controller takes care of sending the right data. It works. It helps to encapsulate logic and separate it from the view. But, I mean, again, it's the same problem. We have lots of components. They are interdependent. The models are interdependent. Once something changed, we have to update the right models and update the right views. Lots of dependencies. Also, here we have, like, models which are designed specifically for the views. And that results in data being scattered, right? Our application state is scattered across the models. There's no one source of truth. Also, sometimes it's even redundant, which, of course, doesn't contribute to consistency. So it could be improved, maybe. If we just do it in this way, we get the application state, right? We can encapsulate it without thinking too much about how we represent it at first. But then we define, like, this mapping from the application state to the actual representation. That's it. So it could be something like this. So we have a big application state, right? We have a component hierarchy, and the application state gets rendered here. And if we have some interactive thing, some button which the user clicks, we eventually propagate this event to the app state, change the application state, and then do a render, right? Again, very simple model. So it's actually very much in the sense of the grammar of graphics. We have data and we map it to DOM objects, right? We have application state and we map it to DOM objects. And over time, application state changes, but the mapping from the application state to the DOM object doesn't. It's always the same, right? So it's important, so-called. Over time, this way, we can develop an interactive application. So, I mean, it's a simple model, very nice. Why haven't we been doing this so far? There is one issue with it. It requires full render on each state change, right? And it can be costly. Well, but maybe there is a way around. And this is where React comes for the rescue. Because with React, we have this notion of the virtual DOM. So it's a virtual representation of the actual DOM tree, which gets eventually rendered in the browser. Why virtual? Virtual is easier to manipulate, right? It's not that costly. The actual DOM is very costly to change, because any change can cause a reflow, which is very, very costly. So it's basically slow. But if we manipulate the virtual DOM first, right, and figure what we have to change in the actual DOM, this can be affordable. So how React works, it's basically, when a change happens, we keep track of the previous state of the virtual DOM. So this is the previous state. Then something changed, right, in the virtual DOM representation. We see that this node has changed. And React runs a heuristic algorithm which tries to identify the minimal set of changes. Not optimal, but with some heuristics, so that it runs in predictable time. Which mutates the actual DOM in the browser, so that it represents our most recent state, right? So we basically do the minimal set of changes to come from this state to this state. And the virtual DOM is a way to describe the state of the visual representation. So with this approach, full render becomes affordable. And it actually enables this architecture, which I was talking about before. So let's see some examples. This is the simplest hello world. What is going on here? So we have a virtual representation of a div, right? HTML or DOM element with hello as text. And class named greeting. This class name instead of class because class is a keyword in JavaScript. And so here we create this virtual representation of this node. But here we tell React to render it in the actual DOM. And it will be rendered as a child of document body. Very simple. So React is coming with something called JSX. It's basically a syntaxical sugar for JavaScript which allows us to use HTML or HTML like text within our JavaScript code, right? It's not mandatory to use it, but I find it very useful because you see right away where are the DOM objects. It sends out in your code. So I'll use it throughout the examples. But it's doing the same thing as this. It gets transpiled into plain JavaScript if you use it. So one very good thing about React is it's very strong component model. Basically it's all you do when you develop applications with React. You create components, and each component basically is a function which defines how data is mapped to its visual representation. So here we define a component called greeting, right? We say that it has a property name of the type string which is required. And so this is the most important function in a component which is called render, and it basically creates the virtual representation of the DOM which eventually will end up in the browser. And here's what we do to render it. So we say greeting. We pass a name as a parameter, and that's the result, right? Let's do some visualization. This is a scatterplot. We have some data, and we have a scatterplot component. We render the scatterplot component passing some data to it. So this array basically. And the render method creates an SVG document. React works nicely with SVG, so we can do graphics in the browser with it. And here we just use a standard JavaScript map function to map each data element to a circle. That's simple. Forgive me, I'm using a bit of ES6 syntax. You need a transpiler for that, but I find it easier to read. But this is basically just a function with two parameters. So yes, it's pretty much in the sense of the grammar of graphics. We map data to visual representations. This could be improved a little bit. We could use scales for that, right? Like in the grammar of graphics or in D3. And actually we can use D3 for that because D3 has lots of visualization goodies which are independent of the DOM manipulation, right? Actually, we can use most of the functions from D3, even some of those which manipulate DOM, I will show you later. The only function we really kind of use is append, or we shouldn't at least. So let's see. We use the scales from D3 here. We defined scale for x, y, and the radius. And we just use them here. Plain simple. I think it reads even better than D3. But it's not the point. So let's do some changes. That's where it becomes more interesting. So we have an update function which basically re-renders the whole thing every time, passing new randomly generated data to the same component, right? And here in the SVG we have an on-click handler which basically just calls the update function. So when I click, it re-renders. Great. Not very impressive yet. But the cool thing about this is that, I mean, we could do the same thing with D3. But the cool thing is that this scatterplot component, right now it's just one component, but it could have been the whole application and it wouldn't have changed much, right? We could re-render the whole application in just one function call without it costing too much. Okay, animation. So we do some changes. Maybe we want to animate them. This is where React does not excel that much at the moment. However, it still works. So the straightforward approach is to introduce T, a parameter part of the state, right? Which says like in what time, moment of time we are in the animation. So it's between the animation based on this time moment and use the standard React re-render cycle, right? But that means that we have to do the diff operation on each change, right? And for this particle system kind of, this is basically the worst use case for which you can apply React because here every single node is changing on every single update. And there is no point in doing the diff because we know it's changing every time. It only costs something. So if we do the same thing with plain D3, it's much smoother because there is no diff operation. These examples were prepared by my colleague Jeremy Stuckey. You can find them on his blog's page. So there are some... So I mean, it still works, but it's slow if we do it this way. You can take a pragmatic approach. What if we say, okay, we are not really caring about the internal state of the animation for the whole application state, right? We can just use D3 transitions to animate between the states. And this works. It's a little bit of a slippery road because React is not anymore in full control of the rendering. But I mean, it works. We have a little bit of care. So we have this component update, did update. So React has those lifecycle events. They are so called. For each component, you can implement those methods. And this one gets called each time the component is updated, right? And here at this point, we actually have the real DOM node we can operate on. In the rendering phase, we don't have this node because it's not yet been rendered or not necessarily. Here we just create the virtual representation of our node. But in some of the last cycle events, we can manipulate the actual DOM nodes. And here we can run a D3 transition, which works. We can even emulate entering and exiting transitions, which D3 has, because normally this is a little bit more tricky, but it still works. Normally React, if your render method, after a subsequent render, removes some element, right? React will remove it from the actual DOM straight away. So there will be nothing to run this exiting transition on, right? So we have to tell somehow React to keep it for a while while we are running the transition. And this is what this transition group does. It basically adds two additional lifecycle events, which are not there by default, which we can use to run an animation, and then call back when we are done so that React knows, okay, now I can remove it. So it kind of works. But they are actually working on better support Facebook, I mean, for animation, and we can expect that in the future it will be supported. But even now you can do things. But you tend to develop applications with less animations. At least, at least I tend to. At least at first. And then you add animations as needed. Okay, here's just a simple example for one project I worked on. So internet permits. Yeah, here you, I hope you can see that those flows are animated. And the project is built with React. But this animation is a plain D3 animation running via D3 timer. So it's, again, pragmatic approach. But for the rest of the applications, it's actually absolutely relevant that these flows are animated, right? So it doesn't have to be a part of the actual state of the application. Never mind. Let's do some interactive stuff. This is about interaction. This is the fun stuff. We can create a slider component, which works, which we can manipulate. So what we have, we have properties with title value, on value change. This is a function which we have to, the parent component wants to get notified when there is some change, right? The value actually is not part of this component, right? It's not part of the state. It will be part of the whole application state. And it gets value injected, so to say, as a perimeter, and the slider only knows how to render it, right? We have another lifecycle event, component deep mount, which get called as soon as the node, actual DOM node is created. And here we can initialize some non-react stuff. We can use D3 drag behavior, which is very useful for creating something like this. We could also use standard react events for that, but drag behavior has also support for touch, which is nice. Why not use it? So handleDrag gets called by the drag behavior, and here we just basically take the mouse position and calculate the value we have to notify the component of the new value. So now let's try to build the application, which has an application state. This is a simple way to put it together, right? We encapsulate our application state. We have only one property density in this case. We have a getter and a setter. When the setter gets called, we render, right? And we have a component for our whole application now, not just slider, but here we do compose. We take our slider component and edit here. Then we have a diff with the actual density value, which you can see here, right? And the render function, which gets called when we change something, just renders everything, the whole application to the document body. Cool. That's quite simple. We created the scatterblot component before, right? Remember, why not reusing it? We just take it, we pass the right data to it, and so I added something to the application state, right? The points and the opacity in other property, which we can change here, and it works. So that's how it works. It's really, really straightforward to compose an application out of components, which you define, and which are functions. It's important that, given the same data, they render the same result, right? If they are like this, it's really easy to compose. So, yes, basically we built an example of this application using this architecture. If you're getting really serious about this, you should look at flux. Pattern proposed by Facebook for building applications enabled by React, but it's very similar. There are a few new concepts, like stores. Store is basically application state with the business logic, but in a flux application you can have multiple stores. In some cases you want to better modularize your stores. I'm not always sure it's a good idea. I also like the idea of one big application state. But if you have multiple stores, then you also need a dispatcher which, given an action for which in flux there is also an explicit expression. It's like an object which specifies an action, which can pass from a component to the dispatcher. The dispatcher figures out in what order the stores have to be updated if there are dependencies between them, so nothing goes wrong. But the idea is very similar. The data flow goes always in the same direction. There are no dependencies between the components, except from parent to child. Something really new which was announced recently by Facebook but hasn't been yet open sourced is really an illustration of flux. And here the idea is that, as far as I understand, that each component specifies its data needs. You don't anymore have to pass the data from the parent components down the hierarchy to the lower level components. You just say in every single component which data it needs. And the system figures out how to feed the components with the data on the client. It also fetches the data from the server in the most efficient way, so that there is no over fetching and under fetching. Which is really, really cool. But we have to wait until it's released. So if the internet permits I hope. Does it? Does it? Maybe not. I want to show a little bit. It doesn't seem to work. So, a sleeper map example. Sleeper map, like Google Maps. So, here we basically have, it's a rewrite of an example for a plugin for D3 called D3 GeoTile which basically allows us to, for a given projection of Mercator for a given setting. Scale and translate. To calculate the numbers of the tiles we would need to download from OpenStreetMap, for instance. Which we have to show actually draw in the application. So, there must be actually two kinds of tiles here. Which we can see for some reason. Because these are raster tiles. These are just images. So, I have here a component for raster tiles and there must be also vector tiles. So, it should look something like this. Yeah, it seems that the internet is not working. I'm sorry. I'll try different connection. A secret one. Let's see, let's see, let's see. Yes, yes. So, okay. Great. So, we have our sleeper map component with height and center position in Boston, in this case. Get initial state. So, components can also have internal state. Usually, you don't need that. But sometimes, you have some state which only this component should know about. If it's relevant for the rest of the application. In the case of the sleeper map, it can be either, I think, depending on the application. But here we just keep it within the component. The component gets re-rendered automatically. So, our state is scale and translate, right? It's like the projection settings. Component did mount. Here we initialize our zoom behavior. Again, it's using the D3 magic. Zoomed gets called when the user interacts with the map. And it changed the internal state of the component which leads to re-render. Get projection, get transform. And the actual render. Here we use this geotile plugin which gives us the list of tiles we have to actually show. So, there are two kinds of tiles. Raster tiles are the images and vector tiles are basically tiles of geometry. Geojson geometries, which we can render as a vector path. And we can apply some visual mapping to it. So, here they are rendered. So we have the simple raster tile component and the vector tile component. Vector tile component also fetches the actual geometries from the server when it gets mounted. And then so we set state, internal state of the geometries. It leads to a re-render and then we can actually draw the geometries. As paths. So this is how it works. Slow. Is it the folder of React? Yes. The thing is that we always re-render and here we have a costly operation. Tile path. It does the re-projection. Do we really have to do this every time we want to pan or zoom? No. There is something called shoot component update in React. It's basically a way to say, okay, this part of the tree of the virtual DOM, I don't want it to be re-rendered. I know that nothing has changed, right? By default, everything gets re-rendered. So render of every single node in the virtual DOM representation is called. Sometimes we know that we don't want it. So here we can basically say next properties and next state. These are like the new values of the properties and of the internal state of the component. We can compare them to the previous state. If they haven't changed, we don't have to re-render. We return false. But just adding this method, we can make it much smoother, right? So great. We could optimize something. So this is this method, shoot component update, which makes a difference. If you are having performance problems with React, look at this. How you can improve it. Immutable JS. Something using immutable data structures is good. You know that. We use immutable strings in JavaScript and Java and it's really good. Unfortunately, we don't use them for everything, like in Clojure. It's my favorite language and everything is immutable. But there are libraries for that, which we can use in JavaScript. Immutable JS was inspired by Clojure. And what it can do, what it offers is basically a set of a library for collections. We have maps, sets, lists, and so on. All immutable. It means when we change something, right? In our map. We get a new object. This will return false. It will be a new object. And the old object will still retain. So how does it help us, actually, here? The thing is that with this, we can implement shoot component update very efficiently. Imagine that you have a large data structure. And you want to check where it has changed. What do you have to do in JavaScript? You have to do a deep comparison, which is very costly, right? What do you have to do with an immutable data structure? You have to compare the identities, which cost almost nothing. And that's the power of immutable objects. Unfortunately, so you can structure your application state using immutable objects, but if you want to use it with D3, okay, that's not always easy. Many functions expect JavaScript arrays, right, in JavaScript. So we need to convert, or we need to use JavaScript objects. So there's no perfect solution for that unless we rewrite D3. So one other thing I'd like to mention is server-side rendering. You probably know that most of the visualizations which we create on the web with D3 or other libraries which use JavaScript to render something into the DOM, they produce something invisible to search engines, right? Because search engines do not run our JavaScript and do not generate those DOM elements. So, and this is not perfect. With React, because React uses virtual DOM, if you use something like Node.js on the server, what we can do, we can use the same, exactly the same code which we use on the client to produce the DOM representation of our components. We can use it to render our application into a string, right? So my app is React component which you also use on the client. But here on the server we basically say render this to the string and send it back to the user, right? So the search engines will see it. They will not have to run our JavaScript and also the user will see like the ordinary users will see the results earlier. They won't have to wait for our whole application to load and build those visual representations. So there are two advantages. What's also very interesting and exciting is that there are other implementations of React which use other destinations for other target platforms for rendering. There are some libraries for rendering into canvas. There is a new library called React Native made by Facebook where you can use React to develop iOS and Android applications. There is however no support for graphics in React Native. There are only UI elements so far but I'm sure it will come. There are some experiments even for WebGL, I think. Although they don't look very promising at the moment. But it's pretty exciting. It doesn't mean that you can run the same application which you write for the web, for SVG, producing SVG, to use the same application to render into canvas or iOS because you have other primitives, right? Our primitive components of which you build your application. But it's still the same approach, the same idea and it shows that the idea is good, I think. So React developer tools, I'll briefly show that. This presentation is actually a React application. And React developer tools is an extension for CRO which basically shows you your virtual DOM representation here. So you see I have this is my root component, slide show, player. I can even see the properties of this component which got passed by the parent current slides, the internal state and it's pretty cool for debugging purposes. So hot code reloading. This is something called 2. Okay. Yes, here it is. So here we have five sliders, right? So I just set some values. Great. We see the average value, here's the source code for that. Okay. Let's change mean to median, right? Did you see it change? A little bit, right? It was 69, became 67. Okay, we can change the label so you surely see average. Let's remove value. Save. Okay, changed. So it got refreshed, right? So this changed. Did you see the sliders change? No, they didn't change. Right. But it was a refresh, wasn't it? It wasn't really. It was a re-render, right? We re-rendered our application because the whole application is just one big function. We just run the renderer again. It rendered. Even if we change some source code, we change the render logic, right? But the state was not thrown out. We still kept the same state as we had before we made the change. This is pretty amazing. Imagine if you have a complex application where we have to click 20 times to get the specific state which you are currently developing, right? You don't have to lose that with this approach. Only works with Webpack. But I highly recommend to use it to package your application and manage dependencies. So, okay. Yes, this I showed you. One last thing I want to show. This is from a highly recommended article by David Nolan called The Future of the JavaScript MVC frameworks. What he did, he run a comparison. He implemented an application with React and OM. OM is a React wrapper which he made in ClotaScript. It's basically React still in the basis of it. And the same application. It was to do MVC in Backbone, right? And this is from Chrome developer tools. It's a flamethrower. So, basically, we see here functions which call other functions. So, this is time. This is a function which takes longer. This calls this function, this function, this function, and so far. So, we see how much every function takes to, like, how many functions get called and how long they take to proceed. So, first thing is that the Backbone was slower than the React version. React and OM. I think it was, like, three times or something. The second thing is that the pattern of the function calls, you can see it's so much different, right? Here we have lots and lots of small functions which get called. We have one model which updates another model which has another dependency. It leads to this very, very complex pattern of function calls. In React, we basically have, okay, re-render, do the difference, and so forth. Which architecture is easier to reason about? You can guess, I think. So, to summarize, React is fun to use. And it enables architectures which are easy to reason about because we avoid these unnecessary dependencies. It's a case to large applications and sometimes there are performance issues but they can be dealt with. But for some applications like particle systems, it's not the best choice, maybe. Although you can still develop a component and within the component do something which does not use React for rendering. Still. It kind of works. So, thank you. If you want to look at the source code of this presentation, you can find it on GitHub. To be sure, I'll try to improve it in the next days. Thank you. Thank you.


I've chosen an unusual paper for my next journal club discussion, it's a sociological study inspired by Q Dragon's recent response to the Discovery Institute. The DI are asserting that there is a strong atheist bias among biologists, and that this bias creates an atmosphere hostile to theists, who account for only 10% of biology professors. I think this is wrong on several levels, and I want to present this survey data in support of why I think so. The title is The Religiosity of American College and University Professors. The authors are sociologists from George Mason University and the University of British Columbia, and it presents an analysis of a 2006 survey of professors from across the United States. I'm going to skip on the usual areas of the paper, such as abstract and introduction, and I'm going to only briefly describe the methods, because the interesting points here are in the results or data section, and the authors conclusions. The survey subjects were selected using existing databases of degree-granting institutions, where one professor from each category of study was selected at each institution. The data were stratified to include both elite and non-elite education settings from Harvard and MIT to community colleges. Elite status was determined by the US News and World Report rankings. School and law schools were excluded, as the purpose was to focus on undergraduate degree-granting institutions. This will obviously exclude the bulk of medical researchers who work in research institutions rather than at four-year undergrad institutions. The response rate was 51%, which is excellent for this type of survey, and the total number of cases used is 1,417. They randomly conducted phone surveys with 100 non-responders to determine if there was any bias in responders. Here are the results. Table 1 is a belief in God survey. The selection of responses was different from studies I've seen in the past, but strong atheists account for 9.8%. Agnostic atheists account for another 13.1%, and an interesting 19.2% believe in a higher power, which could include pantheists and other groups that classically don't believe in a personal God. A good 51.5% of professors do believe in God, though, even if they admit to some doubt. Table 2 is interesting, as it breaks out Table 1 by disciplinary field. The most godless groups are psychology and mechanical engineers by far, and the most religious are in finance, accounting, and elementary education. I'll leave it up to you to pour over the data. I want to move on to Table 4, which compares religious orientation by institution type and by discipline. Note that the non-elite doctoral degree-granting schools actually had the highest non-religious responses, and the elite institutions show a broad distribution of different views. In the disciplines, experimental sciences show the highest non-religious rates, but the social sciences and humanities have similar numbers. Only the health fields show a substantial proportion of traditional religious views. Table 5 shows that the largest religious affiliation of professors is none, with 31.2% claiming no particular group, 15.9% are Catholic, followed by the usual slew of different flavors of Christian or Jewish, and a few Buddhists, Muslims, and Hindus thrown in. I'm willing to bet that this same result would not be obtained if medical schools or research institutions were included in the survey, where Hindus and Buddhists who are very heavily represented. Table 6 are regression coefficients between a variable and a survey result. Negative values here represent an inverse relationship, positives a direct relationship. Stars indicate significant correlations. For example, if you have a PhD, you are significantly less likely to claim a religious affiliation. If you are married, you are more likely to attend church, but if you are white, you are less likely. If you're from the northeast or west, you are less likely to accept the literal truth of the Bible. And if you are a researcher of any kind, you are very, very likely not to hold traditional religious views. I leave it to you to read the full conclusions of the authors. I've chosen just a few of my favorites. But the hypothesis that the university is a secular institution because of the irreligious tendencies of the faculty does not withstand empirical scrutiny. It is a secular institution despite the fact that most of its key personnel are themselves religious believers. Here's another great one. In light of our findings, one such mechanism that might be hypothesized to exist, that students become more secular as their atheist professors call into question the value of religion seems implausible as a broad generalization. If anything, our finding that the most secular professors are those focused primarily on research, a minority of all professors, would suggest that the bulk of the teaching function in American colleges and universities is being carried out by academics who are personally sympathetic to religion, albeit not in its most traditional forms. So the old narrative about the evil atheist professor corrupting the youth of America into godless socialist intellectualism isn't well supported by the demographic survey data. Most professors are religious just not to the same degree or in the same way as America as a whole. Married professors are significantly more likely to regularly attend church and professors of applied health like nursing or business professors are also more likely to be traditionally religious while professors with a doctoral level degree are less likely to be religious. In just the elite institutions, only 1% of professors describe themselves as born-again Christians while 13% describe themselves as Jewish, which is the opposite trend at non-elite institutions like community colleges where born-again Christians may represent up to a quarter of the professors. Only 5.7% of all responders were biblical literalists. 39.5% believed the Bible to be divinely inspired, with 48.3% believing the Bible to be an ancient book of fables, legends, history, and moral precepts. It's true that researchers and physical science professors who rely heavily on empirical data and evidence in their daily work are a bit less likely to be accepting of a faith-based religious belief and much less likely to accept biblical accounts as literally true. If the Discovery Institute believes that studying biology and the modern evolutionary synthesis automatically leads to atheism, I think they need to explain what about studying psychology or sociology or even engineering leads people down that same path. The data really suggests that the higher echelons of learning and education are inherently less religious, or at least less traditionally religious. I'm sure that's not the narrative they want. Fortunately for them, they show an amazing ability to live in their own imagined reality rather than the world you or I actually inhabit. Thanks for watching.