Isn't it ironic that we have 15, 20% unemployment depending on how you measure it? And the stock market is going up, not down. It went down, but then it came back up. Came back up because the Fed is keeping it up. So the Fed is defending capitalism really to an unprecedented degree. Hello and welcome. I'm Lynne Freese. And that was Robert Polin joining in this episode of Global Political Economy News stocks. What would it take to move from COVID-19 lockdown to an abundance of decent jobs in all countries? Is it possible for a capitalist society to reach full employment and stay there? In this segment with Robert Polin, we get some perspective on all this and on why full employment is such a challenge to capitalist prerogatives and neoliberal logic. Robert Polin is a professor of economics and co-director of PERI, the Political Economy Research Institute at the University of Massachusetts in Amherst. A prolific author, Robert Polin's upcoming new book is titled Climate Crisis and the Global Green New Deal, The Political Economy of Saving the Planet, co-authored with Noam Chomsky. Welcome, Bob. Thank you. With the COVID-19 crisis, unemployment's reaching levels last seen in the Great Depression. In your book, Back to Full Employment, you delve into basic observations of Karl Marx, John Maynard Keynes, Michael Kaletsky and Milton Friedman as major thinkers on unemployment. Let's start there. Give us a press say on that. Karl Marx is widely considered to be the great thinker of socialism, which he was, but the fact is that Marx spent about 90% of his time when he wrote about political economy, writing about the nature of capitalism. In his discussions about capitalism, one of his most fundamental insights, in my opinion at least, was his point that capitalism needs mass unemployment in order to function as capitalism. Not that you need mass unemployment in terms of the well-being of human beings, but if we're operating within a capitalist system, you have to have masses of people who are unemployed or else you can't have a functioning capitalist system. And his argument is straightforward. What he said was, in a full employment version of capitalism, workers will get more bargaining power. Why? Because if they don't like their job, they can quit and just go get another job and they don't have to worry because you have full employment. So what Marx said is, you have to have that mass of unemployed people or what he called the Reserve Army of Labor. Waiting outside the factory gate, waiting outside the office, waiting in the unemployment lines, and that because of that, that enables capitalists to maintain bargaining power over workers and to keep their wages down. If workers had more bargaining power, they'd bargain up their wages, that squeezes profits, and capitalism without profits is an impossibility. So that's why Marx said, mass unemployment is intrinsic to the operations of capitalism. Now if we move forward to some of the other major thinkers that you listed, we have John Maynard Keynes, I would argue, is the next great theorist on unemployment, and Keynes critically was writing in the midst of the 1930s Great Depression. So thinking in terms of the 1930s, where we have 20, 25% unemployment rates, Keynes was making the argument that this was a massive policy mistake, that you could run capitalism without mass unemployment, certainly not without 25% unemployment. So Keynes said, what we need to think about are policies that will bring the capitalist economy to full employment, and what he was referring to specifically were government policies to stimulate economic activity, to get businesses to invest more, to get people to spend more, and that way, and the government would then be responsible for maintaining the higher level of activity, and with a higher level of overall economic activity, people have jobs. And so he was saying from a technical standpoint, we can certainly operate a capitalist economy at full employment, and keep it at full employment, as long as you have well meaning intelligent policy makers who are hitting those targets of keeping the level of overall activity high. Now the third person you mentioned is Kalitsky, and Kalitsky is obviously nowhere near as well known as Marx and Keynes, who are probably two of the three or four most influential economists ever. But Kalitsky had a very insightful approach, and he basically made the point that there's a lot of truth in both Marx and Keynes, and his synthesis of them is what's really critical, because he said, Kalitsky said, okay, Keynes is right. Keynes made the point, we have the economic policy tools, and we have like really smart intelligent people sometimes in government, and it's true they can raise the overall level of activity in the economy, which will create more jobs, they can keep the economy at the high level of activity, so you have full employment under capitalism, no problem. Technically, he was right. But then Kalitsky said, listen, Marx is also right, because Marx's point was not about the technical requirements for full employment, it was about the political requirements for full employment, and in fact, Kalitsky's famous paper is called Political Aspects of Full Employment, and so Kalitsky said, look, sure we can get to full employment following Keynes, but we still haven't solved the problem that at full employment, the workers are going to get more bargaining power, they will bargain up their wages, that will squeeze profits, capitalists won't have profits to the extent that they want, and that is going to undermine the viability of the capitalist system. So Kalitsky had this brilliant synthesis of Marx and Keynes, and then the last person that you mentioned, Milton Friedman, he comes at it from a very different tradition, but weirdly enough, his conclusions aren't all that different than Marx, believe it or not, though he comes at it from a right wing neoliberal, I mean, Milton Friedman pretty much defined neoliberalism, but here is basically Friedman's argument is, look, in a capitalist economy, you have competitive markets and people are competing, businesses are competing for customers, they're competing to produce products that people want to buy, so any business at worth its salt is going to hire workers, and as long as they need workers, and they're going to pay people what they're worth, bargaining is going to end up paying everybody what they're worth, because otherwise you lose good employees, the other businesses will hire the good employees, pay them more, and so you can't compete by just paying low wages, this is what Friedman said.  Now then what he said is that, okay, I know, I know, I know we don't really have full employment, but he said the reason is that workers' bargaining power causes the unemployment, which is kind of what Marx came out and said, coming at it from a different angle, but Friedman said the following, take the idea of minimum wage laws, so let's say we set the minimum wage at $15 an hour, businesses say, these workers aren't worth $15 an hour, maybe they're worth 10, but the law says I have to pay them 15, and I can't pay them 15 because then I can't make any money, so therefore these workers are going to be unemployed. And what is causing unemployment in this case in the Friedman story, what's causing it is the government intervention, presumably trying to help out the workers, ending up making things worse for a lot of workers, because even if a worker says, okay, sure, I'll work for $10 an hour, the law says you can't do it, so you have all these people that are willing to work for $10 an hour that can't get jobs because the businesses don't want to pay them 15. So that's what Friedman called labor market rigidities, and those rigidities like minimum wage laws, and as Friedman also said, unions perform the same function, unions give workers bargaining power, they do, they bargain up the wage, but Friedman says, well, if you bargain up the wage, then businesses are going to get forced to pay workers more than they're worth, and that won't last. And so that, according to Friedman, is the basic cause of unemployment, that workers have too much bargaining power, that'll cause unemployment. Ironically, Marx also said, when workers have too much bargaining power, capitalism can't work as capitalism. Keynes was known as the father of macroeconomics. Talk about that and about the most important purpose of macroeconomics in the time of Keynes, and then how the use and purpose of macroeconomics changed so dramatically from the late 1970s. You know, of course we had economics before the Great Depression and before Keynes, and as I said, Marx really focused a lot on the problem of mass unemployment, but really it's with Keynes's book in 1936 during the Great Depression and in the aftermath of that, that we really start to focus on this and we have this field explicitly addressing the issues of the overall economy. So we come up with this term macroeconomics. And really, initially, macroeconomics had as its single most important purpose, initially, to achieve and sustain full employment under capitalism. That was all the point. And so the policy tools that were being refined and implemented were that the government should maintain the level of activity targeted at the level of activity that would be consistent with everybody who wanting a job, getting a job. So if the level of overall activity, what we call GDP, the level of overall activity was such that you had big, big numbers of unemployed, 7%, 8%, 9%, the government should basically spend more, create more jobs that way till you get to the full employment point. That's government spending with government borrowing, so it's government deficit spending. So you're not taking out in terms of tax money, you're just putting in in terms of government spending and then the government pays off its debts later when you hit the full employment. The other big tool during this period of macro policy was the central banks operating interest rates, influencing interest rates. So if you have high unemployment, the central bank would lower the interest rates to the extent they could. And with low interest rates, businesses are more likely to borrow money, consumers are more likely to borrow, to buy a house or to buy a car. And therefore, that's the other way through which you stimulate the economy and keep it at full employment. And that was the basic, that was it. Basically from coming out of World War II until the early 1970s, that was the toolkit. Now countries did it to greater or lesser degrees, their refinements, but that was basically the model. What happens in the 1970s is that you have this period of high inflation that was really unprecedented, certainly in peacetime. Now the cause of the high inflation was the oil price shocks coming from the OPEC, Oil Producing Countries, that realized they could get away with this. They raised oil prices 300% in 1973 and then again another 300% in 1979. Now that's just one price, price of oil, but that's a very important price, the price of oil. So that really threw the capitalist, Western capitalist economies off kilter. Through let's say the early 1970s, the rich, high income, especially European economies, were operating pretty close to full employment, 2%, 1.5% unemployment rates. They were succeeding in this kind of Keynesian model. It got completely overturned due to the oil price shock and then the shift in focus in macroeconomic policy was really to worry about controlling inflation as opposed to maintaining full employment. Now it so happened that when that oil price shock led to the inflation, you then also you return to these people like Milton Friedman who said, see we told you all along, capitalism, if you give workers too much bargaining power, just like Mark said, if you give workers too much bargaining power you're going to have inflation and so that we need to drive down worker bargaining power. There's too much strength in unions, there's too many regulations that support workers, like minimum wage laws, other forms of worker protection like unemployment insurance. And so this whole gigantic shift in the policy direction really started in the early 70s but maybe more in the moving into the late 70s and really got crystallized with the election of Margaret Thatcher in England in 1979 and Reagan in the United States in 1980 that were so aggressively anti-worker. The way they posed it was to say, well we are really for inflation control, having an economy where we control inflation and we don't have workers having so much bargaining power so that we can now learn to control inflation and that's really what happened and that really is the beginning of neoliberalism, that idea that macro policy should be used to attack the working class, not to maintain sustained decent jobs at full employment. Let's turn now to the 1990s when neoliberal macroeconomic policy really took hold in the developed and the developing world. How do you explain that? In my opinion, the consolidation of neoliberalism, of a policy regime in which we focus on inflation control over jobs in which we deregulate the financial markets, in which we basically abandon equality within capitalism as a goal, in which the public sector is attacked and in which we embrace austerity as opposed to expansion, expanding the economy to create more opportunities even if it means government spending more. That whole neoliberal package, it was around forever. I mean, yeah, Milton Friedman, this is what he'd been talking about for decades. It was really, however, only when Democrats in the US, you know, Blairites in labor, similar in Germany, the Social Democrats, they embraced a somewhat more moderate version of this neoliberal package. And that's what gave it the consolidated force that it had. If the left parties, official left parties like the Democrats in the US, had been a new deal party, a party fairly strongly committed to the well-being of workers, neoliberalism could never have been consolidated. It was when you got Clinton in there who was, you know, this brilliant slick talker, slick willy, that was the term. And he could talk about feeling people's pain and all that. And so, and that he was the first black president because he was so cool and he played the saxophone. So, all of that really helped to create an image. Meanwhile, the reality was Clinton and the Democrats were doing the bidding of Wall Street just like the Republicans had done. And the fact that it was being done by Democrats is what enabled it to come in full force. In 1998, the deregulation of the financial markets in the US was signed by President Bill Clinton. He's a Democrat. This is a left-of-center party saying, yeah, let's let Wall Street do whatever they want. You get the equivalent with Blair in the UK and Schroeder in West Germany and so forth. So really, the neoliberal project becomes a unified project of mainstream parties. And the rise of inequality has preceded a pace throughout the whole era of neoliberalism. Without Clinton, throughout Bush 1, Bush 2, Obama, inequality in the United States has risen persistently throughout all these periods. Taking a developing country experience, so we get a developing as well as a developed country perspective on all this, give us some context on how this transformation of economic thinking throughout the world, and most especially the global South, was not simply a matter of ideological persuasion that there was coercion involved. Take the case of South Africa as an example, as you have extensive experience there. What really is underlying this ideological transition is the fact that under neoliberalism, the power of capital becomes overwhelming. So sure, we have this beautiful revolution in South Africa where we overturn apartheid. And Mandela, impossible to believe, but Mandela, Nelson Mandela becomes president of South Africa. A man who spent 27 years in prison as a terrorist, so-called terrorist. So these were unbelievable historical achievements at the same time. Once the African National Congress came to power, they made the decision that, well, really they can't do anything unless they have the approval of global capital. They cannot upset the apple cart because they won't get any investments in. They won't have any money to buy imports that they need. And therefore they're going to operate within the framework of capitalism as defined by neoliberal capitalism as defined by Wall Street. Because they think that's the only way they can really succeed. That's the only path forward. It's very difficult to challenge that view. You have to have a strong analytic foundation that's an alternative. But you also have to be able to say that, look, we have a political movement that is capable of challenging the prerogatives of capitalism. We can elect people to office that don't accept the idea that rising inequality is a given and maybe even a good. We want more equality. We want more commitments to social investments, to health care, to child care, to elder care. That that's our priority. And yes, we can have market operations within that framework. But the commitment to general well-being is our foundation. And that really is the basic idea coming out of Karl Polanyi and his great work, The Great Transformation, which came out at roughly the same time as Kolecki's work. So these people, Kolecki, Polanyi, even Keynes, are really people who experienced the Great Depression, World War II, and are thinking deeply about how to build a decent society. And Polanyi said, OK, markets are one thing, but you have to have a foundation in solidarity or else you don't have a society.  And so really the challenge coming out of Polanyi is what are the things we need to do to create a foundation of solidarity? That was really his challenge, which by the way is pretty much what you get out of a careful reading of Adam Smith way back in 1776. People think of Adam Smith as the great expositor of free market capitalism. It's not actually true. He did see a lot of virtues in markets, especially relative to monarchy, but he also made the point that we have to build a society with a moral foundation. In fact, the book he wrote prior to the wealth of nations in 1776 was called A Theory of Moral Sentiments. And as Smith theorized, yeah, we can have markets and markets can be competitive and people can be out for themselves, but that needs to be within a framework of social solidarity. Bob, briefly recap the Marx problem, the Keynes problem, and the Polanyi problem in the era of neoliberalism. Under neoliberalism, as we discussed, you don't have the commitment to full employment. So the Marx problem of mass unemployment being the fundamental regulator of the operations of the macroeconomy emerges full force. Under neoliberalism, we eliminate financial regulations for the most part. And that then leads to the emergence of the highly speculative bubbles, financial bubbles, that then led to the 2007, 2008, 2009 financial crisis. And what about the issues of social solidarity? Well, we certainly are seeing that all over the world. I mean, the rise of neo-fascism is really a marker in terms of people basically deciding we don't care about social solidarity. We have gotten kicked around by the big shots, the neoliberals, the politicians, that some of them talk a good game, none of them deliver for us. We've seen this for 40 years. And so we have to fight for ourselves, and we don't want immigrants. We don't care about, we don't want social institutions. We don't want to pay taxes for that. So that's really the three critical markers of neoliberalism. Let's wrap up with your thoughts on the way forward in a world facing massive unemployment on the scale of the Great Depression and where it is technically possible to generate decent jobs in all countries. If instead of neoliberal macroeconomic policymaking that blames workers for inflation, macroeconomic policy was used to create and sustain decent jobs at full employment. Yeah, we've had 40 years in which the class strength of the capitalists has been absolutely predominant. And you can see that through the figures on inequality. So the level of inequality peaked in 1928 right before the Great Depression, the Wall Street Crash, where the top 1% got about 25% of all national income. That number after the Great Depression had collapsed, top 1% had about 10% of national income, way less proportionally. And then with neoliberalism in the 1980, it started to rise again to where it basically got back to the top 1% having about 25% of national income. The difference between now and the 1930s is that now it is still staying at 20. The top 1% still has 25% of national income. In the 1920s, it was at that level 25% and then collapsed. So the power of capital under neoliberalism has just been extraordinary, has been really historically unprecedented. What I'm advocating is, yes, a reversal back to something like a New Deal tradition, something like the kinds of things that Bernie Sanders was talking about in his campaign. So Sanders calls himself a socialist, but really the types of policies he was advocating were basically along the lines of a New Deal. And so you were nice enough at the outset of this interview to mention the new book, which is called Climate Crisis and the Global Green New Deal. So in addition to the issues of inequality, obviously we have to focus on the issue of the climate crisis and what to do about it. I see the notion of the Global Green New Deal as a way through which we can synthesize an egalitarian agenda and an ecological agenda. We have to leave it there, Robert Pollan. Thank you. Thanks so much. It's really been great talking to you. And from Geneva, Switzerland, thank you for joining us in this episode of GPE News Dogs.


We ask you to help because we need someone with your medical education whatsoever for this program. Why not? Helping if it's possible. My name is Nikola, I'm from Germany and I'm currently working now with the ICRC doing the transport of the patients from Odessa to Chitina. My family they know but they are 100% supportive so if I ask them okay what do you think about me going there they will say go ahead you can help. So on a normal day like this we are more than 8 hours in the car. Every human being has the right to go. So we support everybody no matter which nationality which whatever for sure and every patient needs an accompanying person because you cannot leave the people alone. It's quite important that you get a somehow contact or relationship even if you are not able to speak the language. So we transport the people and during this day my colleague is in the back and taking care of the patient and his wife so every people we meet it's incredible what they experience and to be honest how brave they are. I learned that many people are quite willing to help to support and in whatever they can to help people in this situation.


So, how was everyone today after lunch? How you feel? Cool. So, I might run a slightly faster, but the slides will be available online. And for that matter, we should start. So, let me start you with a short story. Roughly 400 years ago, there was this guy. Avedi Zildian. Not sure if you heard about him. He tried to turn base metals into gold. 400 years ago, they think they'd do that. So, guess what? He didn't succeed. But he found an alloy that makes nice sounds. And he founded a company that still exists. Like one of the oldest companies in the world. So, let's take a similar journey and try to turn something into rust. We're not going to pick a base language, pick a base metal. We'll pick a base language. We're going to talk about C, mainly. So, there might be some reasons for... Am I missing a slide? No, okay. There might be some reasons for rewriting, right? There might be good reasons. For example, you want more performance. You want more safety. You need to start from scratch anyway. So, maybe you want to try a new language. Or you want to try to learn something new for yourself. There's actually one hidden good reason as well. But it applies only if you want to rewrite stuff in rust. And that's if you don't want to use gold, right? Of course, there are some bad reasons that you... You might think about yourself. We want to rewrite it because the new language is cool. Everyone uses it. Or, like, why not, right? Or some guy told you to. So, I'm going to be talking about using rust in LibVert, which is the same project Michael was talking about. But it's not going to be about LibVert that much. So, I kind of assume you know what is rust.  Yeah, rust is the most familiar example of corrosion, but that's not what we're talking about here. Just to make it clear. So, the main question, should you rewrite your project in any language? No. Just no. There might be some reason for that, but don't just go and try rewriting stuff. It's all about consideration. Should you consider rewriting something? Sure, why not? Probably there are reasons why not to do that. Like, if you can't think of any reason why to do the rewrite, then just, of course, don't even consider it, right? This is all going to be about the consideration, whether to do that. There's going to be difficulties. There are difficulties, there will be difficulties always, right? So, it's about evaluating the risk, trying to see whether it's worth it or not. Just to let you know, my goal here is not to give you an answer, whether you should or should not rewrite something in another language. My goal is also not to teach you rust here, right? My goal is to provide you with some information that might or might not be valuable to you if you want to weigh the risks and so on. So, a little bit of my backstory. Like, I started with rust because I heard about it. I'm trying to keep up with new things. I wanted to learn new things. So, I heard about the language and I said, well, what should I try? I had no idea what to try. What I wrote was a sleep sort implementation in Rust and because what I heard rustations like to name things based on their relation to Rust, so I named it oxidation sort. And how did we get to consider a rewrite in Libford? Well, one of our maintainers sent a proposal that, look, we have this project that's 12 years old, how to make it live for 12 more years, right? There were a couple of things what we should do, what might be good ideas. And one of the things was, well, maybe we should adopt a safe language. He actually said go, which I did not like that much. But based on what I did, it was just a sleep sort. You need to handle threads. You need to handle moving board checker and so on. I liked it so much that I said, well, why aren't we going to use Rust instead? And he said, well, it's all about discussion, right? We should, for any language we will consider, we should do a proof of concept and so on. So I said, cool. Well, it's a milestone five years from now, so sure, we can talk about other languages as well. So then the call for papers for DevCon came. I was like, I did not write any Rust. I want to, but I have no use for it now. Let's submit a talk. Maybe it will make me write more Rust. Cool. So some of the problems we were facing when we were trying to fix are things like data integrity, right? Here you have a function where MacMap add that works on an object, you log the object, and you call the same function with locked in the name. You kind of know which function accepts the locked object and which function accepts the object that's not locked, right? Until you get to the other part where it says, well, there's a precondition. It should be locked, right? So there are things like this that can occur. Of course, Rust will not help you with everything, but every little thing helps, right? So yeah, you can partially solve this in C. Like you can have a lock function that returns a different type of object or a different type for the same object and so on, but it's not with the same elegance as some other languages would do that. One of the other things are ownership, right? You have two functions which we have, and this is like a copy paste from our code. I did nothing about this. So one of the functions gives you back the data that we have in the buffer. There's a verb buffer in libvert, and the context is only valid until the next operation on buffer. And we have another function that tells you, oh, the caller now owns a string and should free it when it's no longer required, right? It's in comments. How do you know, right? So yeah, you can kind of see it here from the declaration that one returns const, char pointer, the other one returns char pointer. So you could argue you can understand that, right? Well, unless you get to this, where you have function that accepts const char pointer, const pointer, and because it's not C++, it's C, it will not automatically add const everywhere, so you need to just cast it from various places, right? So you don't really know who's the owner in C. Then you have stuff like optional values, right? Where you have some unsigned long, long, which needs to be unsigned long, long because you need to capture the whole range. So you add a bool, whether it's specified or not. Or you have a pointer, which can be now, some cannot in this structure. Or you have an integer for which unspecified means minus one, right? And for some of these things, you need a function that creates a new structure for you because zeros are not the default, right? So a function that fills it with some defaults. And you have to call this function to get a structure. Of course, in C, the compiler will not tell you, you have to do that. And some other stuff, of course. Everyone wants to get more contributors. Everyone wants to get more maintainers. Ideally, we, of course, want more safety because it's a Libertas project that's used everywhere. It's maintaining virtual machines and doing migrations on top of them. So stuff should not go bad that much. I want to use some object-oriented goodies. We have object implementation like most bigger C projects do. So how do we just start? We want to rewrite something bigger. You can start bottom up. You start writing utility functions. You can start top-down where you write the binary and you just call the C code and you gradually go down. Or you can start from the middle if you have some isolated part of the code that can be written in almost any language like a module. Or you have drivers. We have drivers and backends in Libertas as well. And there's a question whether to write something that looks more like Rust or whether it's C-equivalent Rust. So I figured, well, let's look at the call graph, right? Generate a call graph. Look at the isolated part. So I took hours and hours to get generated. I opened it in Firefox and this is how it looks like. Right? So I did some optimizations. I worked a few more hours on top of that and it looked like this when it worked. It's all red. Because red means there's too many nodes coming from this node. I will not render them anymore. Right? So I made some lists of things to try. Right? I figured out I should start here. I tried a few things and I got to a point where something was working cool. So I looked at the list and it was not even the first thing on the list. So there were small steps. But I already learned things. So there are some tools. There are some things that can help you with rewriting stuff in Rust. There's C to Rust and there's Corout. Those things take C code and give you Rust code that does the same thing. For C to Rust, there's Web interface and command line tool. Corout is the CLI tool. It's actually interesting because it's written in literate Haskell. More languages, right? But this is not the aim of the talk. I wanted to try right Rust. This would take the only thing that I wanted to do from me. Other tool is Rust bind-gen that generates bindings for your C code so that you can use it from Rust. It works weirdly. You need it, but it works in a weird way. It takes kind of long. It needs C-lang because it uses lib-c-lang to parse the code into AST and so on and so on. And it depends whether you use it from Makefile or from build-rs in Rust. In which case all the prerequisites that the bind-gen has you will be building them on the machine where you're building lib-word and they will be your dependencies, right? We will get to that. C-bind-gen, the other way around, it generates C header files or C header files, yeah, for a Rust code. It just works. It's kind of better. Cargo vendor is one good thing. It basically vendors or Rust dependencies in your source tree so that when you're building somewhere from your disk targetball, you don't need a network, for example. But it all comes down to who controls your build system. If it's a bigger project, you want to start with the thing you have, just plug stuff in. If it's a smaller project, you still probably want to do that. The only way you can just move to cargo is if you have superdining project that you can just rewrite in one afternoon, right? That's not what we were talking about. One more thing, if you want something on top of cargo or Rust he doesn't provide, you'll need something else as well, right? Like libraries.  But no lib2 library, no package config file, stuff like that. I'm going to skip those. You can ask me later if one more. But it's not that relevant. What's good to have is tests. We have a lot of tests. We have unit tests. We have integration tests. It will help you move on with your code. So what I wanted to do was make the basic thing work in Travis that we have. With Travis, we're running this check. So we need to make this check work. So we need to make this work. So, yeah. Things that are really related to Rust, right? So one of the things is how do you pass information from auto tools to cargo? You can generate some files from .in files. You don't really want to do that. You want to have the Rust part of your project easily buildable. You want to go there and do cargo build or something. And ideally for that you do not you don't want to force some people to run configures just so they can try the Rust part. So you can have cargo features that will be run by make for example those that require some C code but they will not they will not be needed when you just want to build a Rust part, right? So one of the ideas I had and what worked the best was for me just in make file pass some environment variables to cargo build and use them from .info and have same defaults if they are not passed. We will see that. So what did we learn? How to do the rewrite?  You might be thinking wow, that's fun. No. So let's do some Rust instead. I'm going to need to speed up a little bit I guess. First thing I want to try is to have a function that does not return anything and does not take any parameters. This is how it looks in C header file. Basically what you need to know is you need to have no mangle so that the name is the same in the library. It needs to be public and it needs to have the same size. It just uses the system call method.  Second try I tried we have a function that just creates a file with some permissions. So I wrote ver file touch. It's pretty easy. Don't look at don't take my Rust code as Rust. I just wanted to try stuff out. It kind of works. But you can see there's no unsafe. How can you interface with C and have no unsafe? Well, as you can see there's utils C string. Give me a C string from the file name. So I had some utils great that I created and C string basically checks for if it's not null so I made the unsafe part as small as possible and whenever you need unsafe when you're interfacing with another language but what's really good whenever there's a reason for you to use unsafe there are the list of things that you need to make sure basically why you need to use unsafe what the compiler cannot do for you. So a couple of things for the cster from PTR there's no guarantee of the validity of PTR. Well, we kind of assume that someone gave us a valid pointer. It's our code so we can assume that. The return lifetime is not guaranteed to be actual lifetime of PTR. Well, we don't really care because the function does not store it anywhere. There's no guarantee that memory pointed to PTR contains a valid null terminated by it. Well, it's C string. It does have that. We're passing it from C and we used it as a string before in C. So it works. And the last thing, again, it's not being stored anywhere. So finally I wrote a function that actually also returns something. This is what you need to write to get cons car pointer points, strings, cons data meter and so on. And there's a question. Do you do more Rust stuff or more C stuff? Right? This is a... Well, let's work with it like it's a C code. This looks more like a C code. You can do that.  You don't really... It doesn't look like Rust. The other thing you can do write kind of Rust code and then around it, like transform the C structures and C stuff to Rust and then transform it back. The problem with this is that whenever you create a Rust structure from the C data, Rust knows about it, it wants to free it. You need to tell it, just forget about this memory. If you don't like Rust, forget about it. So you don't get double free. So... So one of the things is I learned that by tests, right? And the easiest thing to do, what you can do is test your FFI code in C. You can show you the test I have for this function in Rust. You have to create C structures and everything, why, when you can just have a C file that tests that. One of the other things to know about, you need to use the same allocator in the Rust code as you use in C. Of course, if you want to unlock something here and free it here, you can use the same allocator. You can do that if you have nightly Rust. Check some, get some alloc errors. There are two types of errors. The allocation fails or the parameters are not cool. Again, you can use PanicHook and AllocErrorHook and just have function that returns safely. You don't want your program to crash if it's multi-threaded and this does something else on the other thread, right? Again, you need to have nightly for that. That's the build stuff we talked about. I'm just going to run through it. This is how it looks if you want to use bindGaN from makeFile and it still does not properly work. This is how it looks in buildRS where it actually works better. There are some bugs why bindGaN doesn't work properly in make, but you're supposed to use it from buildRS but you cannot use it if you don't have it as a build dependency from your dist. See, bindGaN is kind of easier. This is how you use it from make and this is how you use it in buildRS and it works with dist, dist check, vpath builds and so on. This is what you need for cargo vendor. Just make sure you make the path writable based on automake documentation and use relative data to make the path because, well, some projects did not do that and I don't know how they're handling it. From what I did, I have a list of things to do. I want to use workspaces for different things. That's cool that it works. I have some stuff in separate crates, whatever is used from buildRS. The rust stuff is almost completely optional. That's good because you don't want to just change the dependencies with this big of a thing. There are some more things I still need to do that don't really work properly but we're on our way. Some of the hints that I have for you are all blindly for some stuff you found online. I did not do that and after I looked through all the things that I found they just I'm looking at it and I'm like, how could that work? How? And that includes this one. Maybe I have something there that does not work for you. Use the advantage and learn stuff. That's what we usually are good at and want to do. Also, read stuff. Don't do everything yourself. Read it but just don't follow it blindly. You can use the opportunity to get used to the language coding style so don't adapt the coding style of the language to your stuff that you use in your C code or whatever. As I say, you want to build for a few versions without Rust as a dependency like Firefox did for a couple of versions they said you can build without Rust if you want and after a couple of years they said I don't know, not years. A couple of versions they said well, now you need Rust. Read stuff. I'll leave you to it. We can learn something by corroding the code. It's going to be adventure. There are going to be pitfalls. There are going to be caveats. Even if the rewrite is not successful we can learn something new. We can find out something new just like Avidis did as I said in the first slide of the presentation. Thank you.


If you've watched any of my previous episodes of Code Club, you know that I absolutely love working in R and making figures using R. RStudio is a great platform for using R, and in this episode, I'll share with you how we can go about installing R, RStudio, and R packages. Hey, folks, I'm Pat Schloss, and this is Code Club. In future episodes of Code Club, we're really going to dig into critiquing figures, making them better, and all around learning about R so we can make our analyses easier and more reproducible. Well, before we can dig into that, I'd like to share with you some of the data that I'm going to be using in these future episodes so that if you're interested, you can follow along with me using the exact same data that I'm using. In addition, for this to work, you need R in RStudio installed. So we'll do that in today's episode. And also, a lot of what we're going to be using comes to us from the tidyverse package, and I'll show you how to install the tidyverse package as well. So first things first, why do we need R in RStudio? Good question. So when we run a command at a prompt in RStudio, or at our command line, we are running R. RStudio is a package, a software package or program that makes it easier to run R. It gives us all sorts of bells and whistles that allows us to edit code in the same environment that we run the code. It makes it easier to install packages. It makes it easier to see plots being generated. So I think of RStudio as running on top of R. You can't run RStudio without R. So hopefully that makes a little bit of sense. So you might ask, why would I ever want to run R apart from RStudio? Well, sometimes, if you're working on a high performance computing cluster, you don't have this graphical user interface like a program like RStudio is, right? So you might have to run R from the command prompt. So it pays to have a little bit of familiarity with running R from the command prompt. In today's episode, I'm going to show you how to install R in RStudio, both in a Mac environment as well as in a Windows environment. So look at the chapters down below in the timeline of this video if you want to jump ahead to Windows, because I'm going to talk about Mac first. And then we'll come back after we've installed the software so I can show you how to get the data, where to put it and how to set up a project in RStudio, and why you might want to do that. So first up, we want to install R in RStudio. I already have it installed on my Mac, but if we go to r-project.org, so that's r-project.org. And over on the left, you'll see download CRAN. So that is the link we want here on the left is a links, all the links for the different sites that have copies of R in RStudio. Here are also the USA links. I don't know if it really matters if you pick the link closest to you. I find that this one, the cloud one, it's maintained by RStudio generally is the most up to date of all the different versions. So this is what I would encourage you to use. So clicking on that link, you'll see there are three different versions that you can download. So I'm going to go ahead and do macOSX because this is the Mac version. And I'm then going to click on this first version, R-4.0.4. That will allow that to download. This will take a couple seconds to download. Once we've downloaded, it will have this package on our desktop. Depending on how you have things configured, it might also put it in your downloads directory. I like to work out of my desktop, whatever. So you double click on that. It will open up this installation dialogue. And I'm basically going to hit continue and agree all the way through. You might have to give it your password. And then it will install. Great. And it tells us that our installation was successful. I'll go ahead and close that. I can go ahead and delete that package because I don't need it anymore. Now what I want to do is show you how we can open up our terminal. So if I go ahead to finder applications and then utilities, you'll see down here that there's a terminal app. So if you double click on that, that will open up our terminal window. I use this terminal app so often that I just have it as a key fixture in my doc. So I'm here at my prompt and I can now type capital R, R, and voila, this will start R. So remember what this looks like because when we open our studio, we'll see the same thing. But again, you can run our commands from here. So two plus two, four, right? Wonderful. So I'm going to go ahead and quit this. Quit out of R and I'll minimize that. The next thing we want to install is our studio. So I'm going to come back up here and do our studio.com. And you'll see a link here for download. Click on that. We want the free version desktop for our studio with the open source free version. There are commercial versions. So if you're working for a for profit, I think you're supposed to use this $1,000 a year RStudio desktop pro. Basically, it gets you more support. Anyway, the free version works great. So I'm going to go ahead and click that download tab. Again, like we saw before, we see the instructions install R. We've already done that. Now we're ready to download our studio desktop. Click on that. And again, this will take a moment or two to download. So that then downloads a disk image. We double click. And we see that we now have this RStudio app. And all we need to do is copy it over into the applications directory. I already have a version. So I'll say I said replace. Type in my password of clumsy fingers. All right. And so that, of course, then is copying our studio over into my applications directory. Again, this is something I use a lot. And so I like having it in my doc. I get this warning from Apple saying it's a downloaded app. Yeah, I don't want to use it. I trust these people. So here is our RStudio window. Right. And so as you see on the left, this looks a lot like what we had over here from the terminal, right. And so again, we are running our from within our studio. If I want to create a script, I can go to new file R script. And this will open up another panel in the top left here, or I can do things like two plus two. And I can then click run. And that will then run that down here in the console. So again, that's one of the nice features of our studio is that it puts it all everything we're doing with R in one place. One other thing I want to show you is if we go up to our studio preferences, this opens up this preferences window. And there's a few things that I want to make sure that you have set to ensure maximal reproducibility. So basically you want everything in the R sessions workspace and history, you do not want anything there checked. Also, save workspace to dot our data on exit, you want that set to never. Okay, so this should be never, and these should all be unchecked. Basically, what our tries to do to help you is to save everything from a previous session, and then relaunch it when you relaunch R. So that might sound like a good idea. But the problem is that if you say defined a variable X in a previous session, and now you open it with all that old session information in a new session of R, X is still going to be defined, and you might not remember that, right? And so we want our scripts to run as though we were starting from scratch, as if you were to give me an R script, I want that to work. I want that script to contain all the information I need, I need to actually run and do the analysis that you're giving me in the script. So again, that's why we always want to have everything here unchecked. And we want save workspace to our data on exit set to never. Okay, so those are really important. And again, we'll do wonders for improving the reproducibility of your analysis. There's other things over here that you can mess with. Some things that you might be interested in changing might be this code tab to change how things edit, display, save, completion, diagnostics, things like that, your appearance, you might, I like white background, I know people hate white background, but you can change all these backgrounds to whatever you want to get a different appearance Dracula, who that's scary. I had modern. Actually, no, I had textmate, which is the default. So again, use whatever you want. It doesn't matter for the analysis, it matters for your peace of mind and what you like to look at. In packages, you can also set the primary crane repository. If you ever want to install a package, you'll want to do it through crane through this. And so if you'd say don't want to use that cloud one that we use the zero repository from our studio, then you'll want to change that here. Okay. So for the most part, that's really all you need to do. I'm going to go ahead and do apply, and then okay. And we're in good shape. The last thing I want to do is show you how you can install a package. And so the package that we're going to use is called tidyverse. So you might already have tidyverse installed if you've already been using our so to check that you can type over here on the right. And yours again, might look a little bit different than mine. But here, if I go ahead and maximize it, if I do tidyverse, you'll see that it pulls up the description that I already have installed. If you don't see tidyverse in this name column, and again, let me make this a little bit bigger so you can see it. If you don't have tidyverse here, you want to install it so you can click this install button here. And and then right here, in packages, you can type tidyverse. Okay. And it'll help you because it knows what packages are already in crayon. And then you can click install. And so this will run down here in the bottom left corner. And hopefully, everything works smoothly. You might get some questions about installing from source or things like that. Go ahead and click why that's fine. So to say yes, you might also get errors along the way. It seems a little idiosyncratic, what error messages you might get. So if you get an error saying like some package is missing, so like RCPP is missing, or can't be installed, go ahead and repeat the steps where over here then if it said that like RCPP, over here, you type RCPP, you could see that and again, assuming it's not installed or not installed correctly, you could then do install and then RCPP to install the RCPP package if that was the package that was throwing errors. I installed fine. So I'm going to hit cancel there. One last thing I can do to make sure everything installed correctly with tidyverse is click this square to the left of the name tidyverse. You'll see that this calls the command down in my console library tidyverse. And if you get this output, you've got everything set. And we're in good shape now for moving forward using RStudio on a Mac. All right, folks, I'm here in Windows with you. I'm actually still in my Mac, but I'm running Windows 10 through the parallels program that allows me to run Windows on my Mac. I'm not a Windows user, but in my experience, the features for R and RStudio on a Windows computer are the same as in a Mac and also on a Linux computer. I don't have a Linux computer at my disposal and I suspect most people aren't regularly running stuff on a Windows on a Linux type environment like with a graphical interface like this. So I think we should be good. I'll go ahead and open up the browser here. Where we're going to want to go is r-project.org. So we're here at the r-project.org website. On the left, you'll see this downloads button. Under that, you'll see a link for CRAN. So if you click on the CRAN, CRAN is the comprehensive R archive network. And so that is the place where you can download copies of R and that will ultimately also be getting packages to run features in R, right? So later we'll install the tidyverse and we'll get that through CRAN as well. On the left side of this screen are a bunch of links to different mirrors or places where you can download R and the packages from. So in my experience, yeah, there are these CRAN mirrors that might be close to me, but at the same time, like I think the University of Michigan has one, yeah, right here is one from Michigan. In my experience, this first one is usually the winner, right? Sometimes the other mirrors aren't up to date as much as this first one. And so I prefer to go to the zero cloud, which is maintained by our studio. All right. So we'll go ahead and click on that link for our project.org. We then see the ability to download for Windows, which is the environment we're on here. And we will get binaries for base distribution. So I think this is what we want. So we'll go ahead and do install R for the first time. Download R 4.0.4 Windows. So again, if you're watching this a few months or years in the future, it might be a different version of R. In general, I want to have the most recent version of R that I can get. There aren't huge changes across versions, but there's enough changes that I like to have the latest. So if I minimize this window, I can go to my file explorer window. And I think it downloaded it to my downloads. Yeah. And so there's my R hyphen 4.04 win, which I double click on that. This now asks me, do I want to allow this app to make changes to your device? Yes. And we'll go through and do English, the license, and I'm basically going to just agree to everything here. I'll use the defaults and that and yep. Again, just just do what just do what it asked you to do. And life should be pretty good for most purposes. This takes a few moments to install. And then we'll be in good shape. Great. So it installed, I can click finish. And we're good to go. If I look at my flag down here, I wonder if if I go down to the Rs. Here we go. There's a directory here for our new. And then you can click on, I think we want this R x 64. And this opens us up into a console where we can use R.  If you're running R in, say like a Linux console, it would look just like this. Or if you're to run it on a Mac, this is generally what we get. And again, from this window, you can do things like two plus two and get four. So that's cool. And works pretty well. So I'll go ahead and exit out of our there. I don't want to save a workspace image. What I do want to do is get our studio so we can have a better environment with which to work in R. So we will do our studio.com. And we will then click download here. And we want to choose our version. And so our studio is free for most applications, right? So if you're in the commercial world and you want extra support, then you can pay about $1000 a year. They also have servers and all sorts of other stuff. But like I said, for everything that we really want to do, we're going to use the free version. So I'll click download. It detects that I'm running this on Windows. You'll notice also that it required me to install our first which we already did. So we will then download our studio for Windows. Great. So that downloaded. And again, in my downloads, I have our studio can double click on that. Yes, I'd want it to run my computer for me. So yes, next, and we'll complete it. And looks like we're good. We can then we can then come down to our flag and see that we recently installed our studio. This should open our studio for us here. All right. So we're here in our studio. And you'll notice that this window looks a lot like what we had before in that R console. And we're in good shape. And we can do things like open up an R script, which will put up a window in the upper left corner here, where we can type R code. And then if our cursor is on that line, we can click Run. And it then runs it down here in our R console. We also have other panels over here for displaying information about the environment we're working in, history of previous commands, we've done other things. Also, we can change the size of these windows. And so we can see kind of a file manager window here, tab for plots, packages, help, and so forth. We'll come back to this packages tab in a minute. So first, I want to look at the settings. And so we'll go font tools, global options. And looking at this window, the general tab, I basically want everything here unchecked under the R session. So under this section, under workspace, and under history, I want all of those unchecked. And I also want save workspace to dot our data on exit set to never. So the problem with those default settings is that if I now if I quit our studio and come back in, it's going to reload all the old history and all the old variables and objects that I've been working with. That can cause things to go haywire when we're trying to work towards reproducibility. In my mind, we want all of our R scripts to be self contained. So that if I start it with a fresh script, fresh version of R with no prior history, it should run. Now, why would you want that to happen? Well, if I'm working on something and I want to share it with you, you want to know that you have everything in that script that you need to generate the figure, do the analysis that I'm doing. And so again, that's why we want to set all of these defaults to not be checked. And we do not want to save on exit. So that's good. Some of the other things that you might look at in here include things like looking at the code tab allows you to change things like the tabs, the display, all sorts of other things. Appearance might be something you want to change to. I've got the modern text mate, I believe you might also want more of a dark background like Dracula here gives you a different look. This is not going to affect how your code runs, but it's going to affect you in that you want to be working in an environment that is comfortable to you. And so you want to use settings and aesthetics that make you feel comfortable and make you happy to work there. Because if you're not happy, well, then you're not going to want to work in there very much. So again, the default here is text me. So if I scroll to the bottom here, I can click apply. Yes, I so we'll want to restart. So we'll go ahead and restart our studio. I don't need to save that. This will relaunch our studio for us. Go ahead and make that maximized. And we're right back here. Okay. So the one last thing I want to do with you before we go back and talk to those Mac folks is that there's a package we need to install. And so a lot of what we're going to be working in is a package called tidyverse tidyverse. And you'll see that this is empty here. So it's not installed. Sometimes if it was installed, it would show up in here. I'll show you what that looks like once we've installed tidyverse. So we can click on this install button here. And then in this packages window, we can type tidyverse. You'll see that it it helps you to type that in. And so we can then click install.  And so instead of trying to install a bunch of other packages, it's easy just install tidyverse and voila, you get everything. Well, I shouldn't say just because sometimes problems happen during the installation process, where it might complain that a certain package couldn't be installed. If that happens to you, then you'll want to repeat this process that we did for tidyverse with that package. So if it complains that, you know, RCPP didn't get installed properly, then you'll want to go back through this process, click on install. And then instead of tidyverse, type in RCPP, get that to install well, and then repeat to reinstall tidyverse, and then hopefully everything works. So that took a little while for it to install to make sure everything worked well. Go ahead and click this square to the left of tidyverse. This will run the library tidyverse command in the lower left corner. Also gives us this output from running that library command, and everything looks good here. Hopefully you got our our studio and the tidyverse packages installed well, whether using a Mac or Windows. I'm sorry, I don't have instructions for Linux users. If you need those, let me know. And maybe I'll make another video for people using Linux. It should basically be the same. Anyway, if you run into any problems, go ahead and please put a comment below this video. And I'll do my best to see if I can help you diagnose what what the problem might be. So we need some data to work with through these videos. So what I will do now is return to Safari. And if I go github.com Riffamonus forward slash raw data. So if you look down below in the notes, you might have to expand that window a little bit. I'll provide a link to get to the R download the R studio download, as well as this raw data download. If you click on releases over here on the right side of the screen, you'll click releases. And again, depending on when you're watching this video and getting the data, there might be newer releases. The latest release is 0.2. So go ahead, make sure you're there, you can then click on source code, get the zip version. That's fine. If you click on that, that will download it. Again, perhaps to your downloads directory, perhaps to your desktop. So mine went to my desktop. The other thing to note about this is that it has a hyphen 0.2 on it. So again, if you're on Mac or Windows, you should be able to right click on this to get a menu and then click rename. And what you'll want to do is remove that hyphen 0.2. So that's called raw data. I'm going to make another directory that I will call code club code underscore club. And I will drag raw data into that. And so now if you open that up, we have a directory for raw data. And so life is good, right? And in there is everything we want. So the last thing I'd like to do with you is to create a project within our studio for these code club episodes. Again, if you're a Mac or Windows, it doesn't matter. If you go file new project that opens this new project wizard, create project, and we're going to do it from an existing directory. So go ahead and click on that. And we now need to use the browse function here to browse and navigate to wherever we have that code club directory. So mine's on my desktop code club. And this is where I want to stop, you don't want to go into raw data. So I'm in my code club directory. And right there is raw data, which is good. And I'm going to click open. And so the path should look something like desktop code club, right? So the last directory is the name of the directory that your raw data directory is within. Okay, so again, it's important to kind of get all this right. Because if you're trying to use my code, then you need to have make sure the directory names are consistent. All right, we can then do create project. This will effectively relaunch our studio. And if you look at the right bottom right corner now, you'll see that we have something different in our files directory, we have raw data, which is where all our data are, as well as a file called code underscore club dot our project. The other thing you'll notice is in the upper left corner, we have the path to the directory we're in. This is our current working directory, two ways that we have to get into our studio. So the first is if I go to code club, and I double click on that icon, I have this file, code club dot our project that if I double click on that, this will open up our studio for me in the correct correct working directory that I want to be working in getting in the correct working directory is is very important. Because if we tell our to open up a file, it needs to we need to know that we're in the right place to kind of give it directions to then open that file, right? So I'll relaunch our studio to show you a second approach to get into the correct directory. So you'll notice in the upper left corner here, I'm in my home directory, I'm not in the correct working directory for my code club work. So if I do file open project, this will open up again, another dialogue window, and I can navigate to my desktop to code club to my code club dot our project file can click open. This will then switch to that project directory. And voila, we see that we have our correct working directory here in the console. If you're ever wondering what working directory you're in from within our, you can always type get wd open close parentheses. And this will give you the path, the absolute path as it's called to your current working directory. And so we are in the right place. Wonderful. So I hope that if you've never installed our studio or in our package before, I really hope that you found today's episode informative. And that helped you to perhaps get over any barriers that you had previously to installing these important tools. Also, I really hope you got that data downloaded. Because as I go forward in future episodes of code club, I'm going to keep coming back to that data. I might update that data as we go forward to add other data data sets that will allow me to illustrate other important parts of our now, if you find this stuff interesting, if perhaps you've been saying, I really need to learn our but I've been really struggling. I also teach workshops built around our analyzing data either using data from microbial ecology, or more general sources of data that have kind of a broader level of interest. Check out the notes below for all the important links for today's episode, as well as links where you can find out more information about upcoming workshops. All right, please tell your friends about code club and we'll see you next time for another episode.


Check it out guys. All right, so this is my messed up ankle It's kind of hard to see here, but I've had two major surgeries there Two major surgeries there. That's the most recent one They cut into one there back there Got a couple happy Happy scars right there, too so I don't know if you can really see me too well here We'll see so that's the leg that we're considering Removing like I said it hurts pretty much all the time every day and it will like click and pop and Hurt like hell out of nowhere, and I spend every night icing it and I can't really walk So I just want to show it to you guys before we kind of go any further And maybe just have visual records that it existed if I do go ahead and remove it Which is a weird thing to be saying, and I'm pretty sure I'll probably get comments that I shouldn't do this But or maybe not maybe people understand it and get it bulky But yeah, that's that's my leg and I don't actually remember how many surgeries I've had on it I should have kept counting we actually did at one point we used to write down the dates of every surgery that I had had on this massive pair of Scrubs that someone gave me when I was leaving the hospital They were like a size extra extra extra large And we used to write down the date of every surgery or procedure I had but then they burned in a house fire that happened when I was 16 So I lost all those dates and then I changed doctors so many times But I think it's been around 10. I think it's been about 10 in different injections and stuff in there as well So yeah at this point I'm thinking it's probably best Given the information and life I'm living right now to Go ahead with a lower leg amputation But we'll see We'll find out soon. Thanks guys