I recently bought and read "The Lights in the Tunnel: Automation, Accelerating Technology and the Economy of the Future". You can get a copy here: http://www.thelightsinthetunnel.com/. That includes the option of a PDF that you pay what you want for. The book isn't that long. I thought it was well written and an easy read so neither time nor cost are real excuses for not reading it.
Review
The short review is that I thought this was a great book and I think everyone should read it. When I read the introduction I literally felt like I was reading my own thoughts. The main premise of the book is that exponential improvements in technology are going to lead to automation taking over a lot of jobs and creating a situation where the average person in the US can't find jobs. If you go through this blog you'll see I've been saying similar things. The author, Martin Ford, said it before I was really thinking about it though. This book was published in 2009, probably around the time I really started considering the topic.
While I tend to focus on technology and society, this book brings in a lot more economics. What happens when a large fraction of people are out of work? They have no income and stop buying things. That leads to a downward spiral. The author is a big supporter of the free market. However, he makes it clear that our economy is driven by the mass market and that for the mass market to work, you have to have money in the hands of the masses. The success of our economy isn't driven so much by supply as it is by demand. Robots and computer programs don't buy things. If automation makes enough industries capital intensive instead of labor intensive, you don't have enough people with money to spend and things go downhill.
One of the big differences between this book and what I have written about on this blog is that Mr. Ford isn't even pushing things hard on the technology side. He isn't looking at strong AI. He isn't going into the things that sound more Sci-Fi. I think that is a great strength of the book because even people who don't believe in strong AI or who question things like the Singularity can't deny that robotics can do things like Soap.com (http://www.youtube.com/watch?v=6zXOW6v0c8s) or many other examples of places where automation is making industries that had been labor intensive much less so.
This book also presents some solutions. However, I'm not going to repeat all of his arguments or his solutions. The reason is that I think Mr. Ford has done a great job of doing that in a very crisp and succinct manner. Attempting to paraphrase would only screw things up. Instead I simply suggest you read his words for yourself.
Corrections/Modifications
Of course, this doesn't mean I agree with everything in the book. So here are a few things I disagree with. You might consider coming back to this after reading it. I would argue that these are details. They don't impact the main conclusions of the book. However, I think they could impact people's choices and perhaps policy decisions so it is worth bringing them up. The book shows that without changes we will go from point A to point B. Nothing I say here will change that. All that changes in my view is a few wiggles in the road. I also present one other suggestion for how to make things work better on his suggestions to help us get to point C (which is a much better place than point B).
My only significant disagreement with Mr. Ford is that I disagree with his analysis of which jobs will be automated early and which ones will stick around. He expresses repeatedly that anything that is easily outsourced will be automated and that things that don't outsource are "safer". It seems to me that he is basically saying that software AI is a lot easier than robotic AI. I agree that robotic AI is hard, but I think he is too broad in his conclusion that software AI can take over all knowledge jobs. This leads him to a number of other conclusions that I disagree with, but I think it is worth explaining why I disagree.
In the book, an example of a "safe" job that he gives in a truck driver. In 2008-2009 I can see how some people might have thought that. In late 2011 no one should believe that. The Google car should have made that clear. That is only a normal car, but there is work happening in the EU that is specifically aimed at long-haul trucks. Truck driving seems to me to be one of the most unsafe jobs you could train for today. Other examples in the book are house keeper, car mechanic, and plumber. I don't see house keeper as safe either. I think that object recognition systems are getting too good as are systems that have mobility without rolling around. Car mechanic might work, but only for "older" cars. As he mentions in the book, newer cars will probably be built such that robots can do repairs. I expect that to be especially true of electric cars. Plumber might be the best option for a safe job in this list. It combines the need to go into a normal house, work in areas that are often highly cluttered, and other factors that I see being really hard to automate. Granted, I think automation will get there, but if someone is looking for a job to train into that won't be automated too soon, plumber might be a fairly safe one.
On the other side, Mr. Ford assumes that all knowledge jobs and anything that can be outsourced is easy to automate. His main example is a radiologist. I agree 100% on that job. I expect computers will do that better than humans very soon if they can't today. However, he paints with too broad a stroke here. To see why, consider other jobs that can be outsourced: creative writer and graphic design artist. There are people working on getting software to do those things. However, I think most people would agree those are really challenging to automate, even if they are software only, no robotics involved. He doesn't mention those, but he does mention programming. I point out creative writer first to make it clear I'm not just "defending my turf". This isn't a knee jerk defensive reaction to telling people they shouldn't major in CS. I strongly believe that writing software has more in common with writing fiction and painting than it does with building bridges. What is more, unlike creative writing, software construction has been proven to be non-computable in the general case. The Halting Problem demonstrated that as one of the earliest results in CS. That doesn't mean computers will never be good programmers. At some point I expect they will get as good and better than non-augmented humans. After all, humans put bugs in code too. However, it isn't at all straightforward and I would argue it will be very hard to do. It will certainly take longer than automating truck drivers and house keepers.
So my main complaint is that I think Mr. Ford draws the wrong line in saying what jobs are "safe" in the near future. It isn't about whether it is a knowledge worker or not, it is about algorithmic describability. It is about "art" vs. "science". This also means that it isn't about college vs. non-college type jobs either. The real line has a lot more nuance to it. Still, Mr. Ford's conclusions stand. Over time that line will move and more jobs will rely more heavily on automation because they can. Thanks to the natural optimization of the market system, they will. The result will be that companies put a lot less money into the general public through employee wages or that the money is much more concentrated in a few individuals with specialized skills.
In his solutions, Mr. Ford mentions a number of changes to policy that will help to preserve jobs. They basically remove government forces that go against job creation. Things like payroll taxes and job based health insurance are policies that put an extra burden on companies that hire humans. To preserve jobs we want the cost of employing a human to be that person's wages, nothing more. Adding additional costs just gives employers a reason to try to do the job without a human. (Or in the case of outsourcing, an American. Employers don't pay FICA on non-US workers.)
I think there is one other big policy change that Mr. Ford misses. We need to remove the minimum wage. In fact, I think this might remove some of the hurdles he goes through talking about job sharing. The minimum wage sets a bar where, when the cost of automation goes below that bar, industry will flip 100% from humans to automation. If automation really does bring prices down the way it should, some money is better than no money, and having a job making that money is better than sitting at home while a robot does it. For those worried that people will be squeezed to the point where they can't live, I'll just say that Mr. Ford introduces other ways of getting money into consumer's pockets. They aren't handouts, but they help to keep our system running.
There are inevitably other tweaks that would have to be made to Mr. Ford's proposals to make things work, but on the whole I found this book to be very valuable and I honestly wish we could get everyone in the country to read it. Life moves pretty fast and technology is making the pace even faster (in an exponential way). I agree with Mr. Ford that we are going to have to make some changes in how our society works to keep up with it.
Tuesday, August 30, 2011
Saturday, August 27, 2011
A Radical Idea for Education Reform?
Background
The question mark in the title is because it is possible this won't be seen as such a radical idea. I think it would represent a major shift at the very least, and I expect most people to see it as pretty radical. Let me know what you think.
I believe most people would agree that we have problems with educating our society. The problems are the result of systemic issues in society. They can't be laid at the feet of teachers or schools. Parents, media, and many other factors play an equally significant role, to the point that just working on schools and changing up teaching isn't going to fix it. There is only so much a teacher can do with an unmotivated student whose parents really don't care.
I've generally been against the proposals I've seen to "fix education". I think accountability for teachers is a good thing, but I hate the "teach to the test" mentality that current standardized testing produces. I don't blame the teachers and schools though. If I were told that my salary and job security were to be based on my student's results on one of today's tests, I would teach to that test too. I'd be stupid not to.
I also have generally rejected voucher proposals because I fear that they will lead to a number of different problems, especially in areas of lower population density that can't support lots of schools using the standard model. I like the idea of market forces and competition, but I see problems with vouchers that outweigh the benefits.
Modified Testing
The solution I present here was really born from something that my friend, Jason Hughes, said in a discussion about education. The comment was that you want to pay people when students pass the tests, not before then. Home schooling was part of the conversation as well. This happened about the same time that IBM's Watson was beating humans at Jeopardy!. That combination was significant for me because I don't think I could support that idea if the tests were the standardized tests of today. However, I think Watson like technology gives us the ability to make much better tests that we could literally reconfigure the entire education system around, with the idea that people get paid when the tests are passed.
I don't give multiple choice tests. I know they can be built fairly well, but I insist on short answer with the possibility of partial credit. I just think this is better. It isn't the best though. The ideal test format is an oral exam. It gives the tester the ability to really probe into the student's brain to see what they do and don't know. The tester can help occasionally with little steps and take that into account for the grading. If the student can get 90% of the problem, it generally shouldn't matter too much what the 10% they miss is. However, with other testing techniques, if that is near the beginning they miss pretty much the full problem because they can't get started.
Oral exams aren't used in many places though. They are simply too labor intensive. Even at a small school like Trinity they are often prohibitively expensive. On a larger scale you would also run into problems of uniformity in the testing if a single person can't give all the tests. This is where a Watson-like computer could really help. The computer could have expert level knowledge of concepts and ask questions that start with the basics and work up, going through a web of knowledge associated with the topic and probing how far the student knows things. The computer results could be very uniform across huge populations and really tell what the student does and doesn't know.
This is different from normal tests because the computer could explore a huge range of topics. If the student doesn't know things, it stops asking questions in that direction. A normal test covering the same material would require thousands of questions. This means you could have detailed reports on what the student has mastered and what needs to be worked on. You can also give credit or pay out for fractional mastery of a subject and track improvement over time in a far more detailed way.
The Proposal
Combine this type of testing with "pay people for the tests" and you can fundamentally change the economics of education. The main idea is that "people" becomes parents/students, not schools. Schools will still exist and parents can pay schools to teach their kids, but the money comes to the parents first. If you are poor and can't get a job that pays well, home schooling might be your best source of income. In that situation the parents will support their kid's learning because that is how they pay the rent and buy the food.
The market will create schools and professional tutoring locations because many parents won't have an economic incentive or the knowledge to teach everything their kid needs to know. The difference between this and vouchers is that it will scale to any size. In regions of low population density, you might not be able to support schools with diverse values, but smaller tutoring services would work well and could easily pop up to fill in voids without being 50+ miles from a kid's house. What is more, because this lets parents get paid for teaching their kids, rural locations, where jobs are often hard to come by, will probably see a lot of home schooling and you get a system where the economic ideal for many parents will be for them to learn new material so they can teach it.
The Details
Of course, the devil is in the details and I certainly won't claim to have worked them all out. However, I think one of the wonderful things about this system is that there aren't many details. It basically comes down to, what do you test on and how much do you pay for it? IMO this is a decision to be made at the state or local level. However, you can get a general idea pretty quickly. Start with topics that are the current education requirements in the state. Consider building from there. As for how much to pay, figure out how much you pay in education right now, subtract off the cost of running the testing centers (which shouldn't be all that high) and then divide by how many kids are in the state and how many topics you expect kids to master each year. It is also possible to pay out differently for different topics. I'm sure that there could be ways of doing that intelligently, but I am not convinced it should be attempted on the first cut.
Another detail that will have to be dealt with is whether to scale payments based on number of children in a family. I don't know if this would really be needed, but I could see situations where people have more kids just to keep getting those education checks. For some reason I don't think this is a real problem. First, you don't start paying until they are several years old. That removes a lot of the possible incentive right there. Second, teaching little kids and older kids at the same time will be hard and potentially inefficient. You probably make more getting your kids up to calculus and advanced composition than you would if you stop early with the older ones and try to get new younger ones. Indeed, having payouts increase for higher level topics would make sense and would help to prevent people from having kids just to get checks.
Other Benefits
One of the potential problems with schools today is that they become daycare centers with teachers spending lots of time just watching over the "children". That is a waste of time and effort in a number of different ways. If you get paid for passing test for material mastery, you want to use the time teaching, not baby sitting.
Another potential advantage, though one that people might find controversial, is that kids stop when they are done. If a student reaches his/her limit, and simply can't master any other skills, it is time to move on to something other than education. Hopefully something that uses what they have learned productively. What I think might really happen though is that students max out in some areas, but keep improving in others. The result is maximum utilization. They take things as far as they are capable, and because they have real economic incentive (as do their parents) they really will try to keep going as long as they can. Current school systems don't work this way.
Adult Education
While the details of how it would work and how far it can be pushed are less clear in my mind, I really do think that this idea could be extended past normal school age. We already have government programs to help re-educate people who have lots their jobs to give them new skills so they can find new jobs. These programs pay for the school, not the results. Pay out when mastery has been demonstrated, and those programs would probably work a heck of a lot better.
I'm sure this also applies to college curricula, but I'm not certain how much or how well. It likely does very well in some areas, but I'm not sure if it really works for all. Still it is something worth thinking about.
The question mark in the title is because it is possible this won't be seen as such a radical idea. I think it would represent a major shift at the very least, and I expect most people to see it as pretty radical. Let me know what you think.
I believe most people would agree that we have problems with educating our society. The problems are the result of systemic issues in society. They can't be laid at the feet of teachers or schools. Parents, media, and many other factors play an equally significant role, to the point that just working on schools and changing up teaching isn't going to fix it. There is only so much a teacher can do with an unmotivated student whose parents really don't care.
I've generally been against the proposals I've seen to "fix education". I think accountability for teachers is a good thing, but I hate the "teach to the test" mentality that current standardized testing produces. I don't blame the teachers and schools though. If I were told that my salary and job security were to be based on my student's results on one of today's tests, I would teach to that test too. I'd be stupid not to.
I also have generally rejected voucher proposals because I fear that they will lead to a number of different problems, especially in areas of lower population density that can't support lots of schools using the standard model. I like the idea of market forces and competition, but I see problems with vouchers that outweigh the benefits.
Modified Testing
The solution I present here was really born from something that my friend, Jason Hughes, said in a discussion about education. The comment was that you want to pay people when students pass the tests, not before then. Home schooling was part of the conversation as well. This happened about the same time that IBM's Watson was beating humans at Jeopardy!. That combination was significant for me because I don't think I could support that idea if the tests were the standardized tests of today. However, I think Watson like technology gives us the ability to make much better tests that we could literally reconfigure the entire education system around, with the idea that people get paid when the tests are passed.
I don't give multiple choice tests. I know they can be built fairly well, but I insist on short answer with the possibility of partial credit. I just think this is better. It isn't the best though. The ideal test format is an oral exam. It gives the tester the ability to really probe into the student's brain to see what they do and don't know. The tester can help occasionally with little steps and take that into account for the grading. If the student can get 90% of the problem, it generally shouldn't matter too much what the 10% they miss is. However, with other testing techniques, if that is near the beginning they miss pretty much the full problem because they can't get started.
Oral exams aren't used in many places though. They are simply too labor intensive. Even at a small school like Trinity they are often prohibitively expensive. On a larger scale you would also run into problems of uniformity in the testing if a single person can't give all the tests. This is where a Watson-like computer could really help. The computer could have expert level knowledge of concepts and ask questions that start with the basics and work up, going through a web of knowledge associated with the topic and probing how far the student knows things. The computer results could be very uniform across huge populations and really tell what the student does and doesn't know.
This is different from normal tests because the computer could explore a huge range of topics. If the student doesn't know things, it stops asking questions in that direction. A normal test covering the same material would require thousands of questions. This means you could have detailed reports on what the student has mastered and what needs to be worked on. You can also give credit or pay out for fractional mastery of a subject and track improvement over time in a far more detailed way.
The Proposal
Combine this type of testing with "pay people for the tests" and you can fundamentally change the economics of education. The main idea is that "people" becomes parents/students, not schools. Schools will still exist and parents can pay schools to teach their kids, but the money comes to the parents first. If you are poor and can't get a job that pays well, home schooling might be your best source of income. In that situation the parents will support their kid's learning because that is how they pay the rent and buy the food.
The market will create schools and professional tutoring locations because many parents won't have an economic incentive or the knowledge to teach everything their kid needs to know. The difference between this and vouchers is that it will scale to any size. In regions of low population density, you might not be able to support schools with diverse values, but smaller tutoring services would work well and could easily pop up to fill in voids without being 50+ miles from a kid's house. What is more, because this lets parents get paid for teaching their kids, rural locations, where jobs are often hard to come by, will probably see a lot of home schooling and you get a system where the economic ideal for many parents will be for them to learn new material so they can teach it.
The Details
Of course, the devil is in the details and I certainly won't claim to have worked them all out. However, I think one of the wonderful things about this system is that there aren't many details. It basically comes down to, what do you test on and how much do you pay for it? IMO this is a decision to be made at the state or local level. However, you can get a general idea pretty quickly. Start with topics that are the current education requirements in the state. Consider building from there. As for how much to pay, figure out how much you pay in education right now, subtract off the cost of running the testing centers (which shouldn't be all that high) and then divide by how many kids are in the state and how many topics you expect kids to master each year. It is also possible to pay out differently for different topics. I'm sure that there could be ways of doing that intelligently, but I am not convinced it should be attempted on the first cut.
Another detail that will have to be dealt with is whether to scale payments based on number of children in a family. I don't know if this would really be needed, but I could see situations where people have more kids just to keep getting those education checks. For some reason I don't think this is a real problem. First, you don't start paying until they are several years old. That removes a lot of the possible incentive right there. Second, teaching little kids and older kids at the same time will be hard and potentially inefficient. You probably make more getting your kids up to calculus and advanced composition than you would if you stop early with the older ones and try to get new younger ones. Indeed, having payouts increase for higher level topics would make sense and would help to prevent people from having kids just to get checks.
Other Benefits
One of the potential problems with schools today is that they become daycare centers with teachers spending lots of time just watching over the "children". That is a waste of time and effort in a number of different ways. If you get paid for passing test for material mastery, you want to use the time teaching, not baby sitting.
Another potential advantage, though one that people might find controversial, is that kids stop when they are done. If a student reaches his/her limit, and simply can't master any other skills, it is time to move on to something other than education. Hopefully something that uses what they have learned productively. What I think might really happen though is that students max out in some areas, but keep improving in others. The result is maximum utilization. They take things as far as they are capable, and because they have real economic incentive (as do their parents) they really will try to keep going as long as they can. Current school systems don't work this way.
Adult Education
While the details of how it would work and how far it can be pushed are less clear in my mind, I really do think that this idea could be extended past normal school age. We already have government programs to help re-educate people who have lots their jobs to give them new skills so they can find new jobs. These programs pay for the school, not the results. Pay out when mastery has been demonstrated, and those programs would probably work a heck of a lot better.
I'm sure this also applies to college curricula, but I'm not certain how much or how well. It likely does very well in some areas, but I'm not sure if it really works for all. Still it is something worth thinking about.
Saturday, August 13, 2011
Government of Infrastructure
I'm not really a very politically minded person. Like everyone, I have opinions about politics, but it isn't my day job and I don't strive to stay informed about what is happening in politics. The reality though is that politics impacts all of our lives, whether we want it to or not.
As a general rule, I don't fit into either party. I'm pretty centrist in many ways. On fiscal things I'm a bit more conservative. On social things I'm a bit more liberal. It seems odd, but in many ways the platform I often agree the most with is Libertarian. I only want government involved in the things it really needs to be involved in and even then it should be involved using the lowest level of government that works. So the federal government should get out of most of the things it does, IMO, and let state and local governments deal with those things. What is more, I think that the capitalist market can be very efficient for many, many things and where it is efficient, I think government should stay out completely and let the market do the work.
However, if I have a discussion with a "true" Libertarian, we'd argue about things like NASA and NSF which I consider to be part of the essential things that the national government needs to fund. This leads to the question of what I think is essential and why. From the above we can glean two criteria:
So what do I think qualifies for #1? The title of this post gives away the answer. In a general sense, I consider the market short sighted. Investors want their profits today. It is hard to invest in things that won't pay off for an extended period. I have come to the conclusion that the best term for these long-term aspects of society is "essential infrastructure". What is more, I think the authors of the constitution had a similar opinion.
Why do I think the founding fathers felt this way? The Constitution is a fairly bare bones document. They really gave the majority of the power to the states. The US had just come out from under an oppressive government and they didn't want to set up a replacement for that here. Despite the minimalism of the federal government they set up, they included a federal postal system. It does stand out as a bit odd. However, I'd argue that they viewed it as the one essential piece of infrastructure for the time that couldn't be done on a smaller scale than national and couldn't be trusted to private industry.
For a nation to work, you have to be able to communicate. 200 years ago that meant a postal service. You had to be able to trust that communication and make sure it worked across state lines as well. Today the postal service isn't as essential. There are other options and, quite honestly, the free market can do it better. Things change over time. There are still essential infrastructure elements, they just look different. The interstate highway system is probably one of the best examples of a parallel to the postal service. It was a huge cost and it really needed federal government involvement to pull off. However, the ROI has been remarkable.
What about today? What are the things that the national government needs to be funding today using this selection rule? It is things that significantly add to national competitiveness in 20 years, but that don't work as well if implemented on smaller scales. It is possible to debate what should go into that, but here are my inclusions with some rational.
General education is a state issue. I liked that the Obama administration put forward a national curriculum. I think such a thing is a very good idea given the high mobility of our population. That should only be a strong suggestion though and states or smaller governments should handle education issues in general. The ideas I have for this might well become my next post.
There is probably something to be said for enforcing costs of externalities, but that's not going to fit into this post.
What you'll notice is missing is entitlements. They are a huge chunk of the current federal budget and I honestly think they should be axed. I do believe some form of entitlements are required. The future I see with automation making many people unemployable will require this. However, that isn't an issue for the federal government and they should get out of that business. Then we can have 50 states "playing" with possible ideas. Actually running different experiments will go a long way to figuring out what works. What is more, I'm guessing this isn't a problem with a single solution. Texas and North Dakota could very well need different solutions to this.
As a general rule, I don't fit into either party. I'm pretty centrist in many ways. On fiscal things I'm a bit more conservative. On social things I'm a bit more liberal. It seems odd, but in many ways the platform I often agree the most with is Libertarian. I only want government involved in the things it really needs to be involved in and even then it should be involved using the lowest level of government that works. So the federal government should get out of most of the things it does, IMO, and let state and local governments deal with those things. What is more, I think that the capitalist market can be very efficient for many, many things and where it is efficient, I think government should stay out completely and let the market do the work.
However, if I have a discussion with a "true" Libertarian, we'd argue about things like NASA and NSF which I consider to be part of the essential things that the national government needs to fund. This leads to the question of what I think is essential and why. From the above we can glean two criteria:
- The market won't do it well/efficiently.
- It has a scale/scope that needs to be national and won't be as efficient if done more locally.
So what do I think qualifies for #1? The title of this post gives away the answer. In a general sense, I consider the market short sighted. Investors want their profits today. It is hard to invest in things that won't pay off for an extended period. I have come to the conclusion that the best term for these long-term aspects of society is "essential infrastructure". What is more, I think the authors of the constitution had a similar opinion.
Why do I think the founding fathers felt this way? The Constitution is a fairly bare bones document. They really gave the majority of the power to the states. The US had just come out from under an oppressive government and they didn't want to set up a replacement for that here. Despite the minimalism of the federal government they set up, they included a federal postal system. It does stand out as a bit odd. However, I'd argue that they viewed it as the one essential piece of infrastructure for the time that couldn't be done on a smaller scale than national and couldn't be trusted to private industry.
For a nation to work, you have to be able to communicate. 200 years ago that meant a postal service. You had to be able to trust that communication and make sure it worked across state lines as well. Today the postal service isn't as essential. There are other options and, quite honestly, the free market can do it better. Things change over time. There are still essential infrastructure elements, they just look different. The interstate highway system is probably one of the best examples of a parallel to the postal service. It was a huge cost and it really needed federal government involvement to pull off. However, the ROI has been remarkable.
What about today? What are the things that the national government needs to be funding today using this selection rule? It is things that significantly add to national competitiveness in 20 years, but that don't work as well if implemented on smaller scales. It is possible to debate what should go into that, but here are my inclusions with some rational.
- Fundamental Science Research - If you are reading this, your entire life is based on Quantum Mechanics. However, the time between the development of the theory and when there were products that could use it was measured in decades. The market doesn't do well supporting things with those turn around times. They are vital to the future progress of our society in 20-50 years though. Just like interstate highways, they are also something that works best at the national level. This is where things like NASA, NSF, and NIH (along with DARPA) come into play.
- Science Research Education - Local governments can handle most of education. This bullet is actually tied to the one above it. The people who discover tomorrow's version of QM are being educated today. You can't know exactly what hypothesis of today will shape tomorrow. Nor can you know which students will wind up really making the big contributions. That's fine because industry needs a lot of trained researchers too and they can't afford to train them in house. This is NSF, NASA, NIH, and DARPA again. Science funding is a bit scatter shot because not everything will turn into a breakthrough. The things that don't are still beneficial to the knowledge base and hopefully they can be done in labs that are helping to train the next generation of researcher.
- Energy/Network Infrastructure - Highways still matter, but this matters more. The market actually does a very good job with a lot of this, but this is an issue of national security and productivity. It needs some oversight and more help to give it a boost and diversify it. Our electric grid needs serious updating. Utility companies can't afford to do this. I have to admit this is something I really wish the "stimulus plan" had done something with. Giving a little boost to things like wind and solar isn't just green, it helps diversity our energy sources. Nuclear too. Fission might not be active today, but projects like NIF tie this in with the two bullets above it.
- Air Flight Infrastructure - Here is another one I wish the stimulus plan had done. Air traffic control barely squeaks by. Most airlines barely squeak by too so you can't milk money out of them. This is still a very important part of our transportation infrastructure that crosses state borders.
General education is a state issue. I liked that the Obama administration put forward a national curriculum. I think such a thing is a very good idea given the high mobility of our population. That should only be a strong suggestion though and states or smaller governments should handle education issues in general. The ideas I have for this might well become my next post.
There is probably something to be said for enforcing costs of externalities, but that's not going to fit into this post.
What you'll notice is missing is entitlements. They are a huge chunk of the current federal budget and I honestly think they should be axed. I do believe some form of entitlements are required. The future I see with automation making many people unemployable will require this. However, that isn't an issue for the federal government and they should get out of that business. Then we can have 50 states "playing" with possible ideas. Actually running different experiments will go a long way to figuring out what works. What is more, I'm guessing this isn't a problem with a single solution. Texas and North Dakota could very well need different solutions to this.
Abstracting Properties GUIs
I've had a lot of ideas running around in my head related to things like government and education. However, I figured that before I posted on those I should do one that is directly related to programming, so here it is.
A problem I run into fairly frequently is having an object that has properties that I want a user to be able to interact with through a GUI. In the past this was typically something I encountered in Java. This last week I hit it when writing code for my textbook using Scala. Some "standard" approaches would be to a JavaBeans approach using reflection to make the display code generic of apply an MVC pattern. These are big hammers for what is often a fairly small problem. Those are also solutions that aren't going to fly early in a second semester course
To give you a feel for what I'm talking about, consider this code for the situation I'm talking about.
There are three things that vary. The first is just a String. The second is a value that is converted to a String. The third is setting a value. The third one is the challenge. In C/C++ you could use references/pointers to handle the setting code here, but you would have bigger challenges if what you were setting weren't "primitive" types. In Java you don't have references so you need to encapsulate setting functionality. That means making an interface with a single method and making a bunch of anonymous inner classes. Huge overhead. The code winds up being even longer than the original and as such it isn't really significantly easier to modify.
Scala provides a much nicer solution, mainly because function literals can be written so succinctly. Having tuples helps too. So I make an array of tuples. Each element in the tuples corresponds to one of the things that varies. A loop can run through and add them all.
As written here, this code won't handle things that don't go into text fields, but it isn't hard to imagine an extension that does that. I need to play with it some more, but I think the "properties sequence" that includes getter and setter functionality might be a great way to write a general library for properties that is easy to work with and maintain. Pull the GUI building part out and the presentation becomes independent of the data as well.
A problem I run into fairly frequently is having an object that has properties that I want a user to be able to interact with through a GUI. In the past this was typically something I encountered in Java. This last week I hit it when writing code for my textbook using Scala. Some "standard" approaches would be to a JavaBeans approach using reflection to make the display code generic of apply an MVC pattern. These are big hammers for what is often a fairly small problem. Those are also solutions that aren't going to fly early in a second semester course
To give you a feel for what I'm talking about, consider this code for the situation I'm talking about.
class Fractal extends DrawLeaf {
private var (xmin,xmax,ymin,ymax) = (-1.5,0.5,-1.0,1.0)
private var (width,height) = (600,600)
private var maxIters = 100
private var propPanel:Component = null
// code we don't care about that uses data
def propertiesPanel() : Component = {
if(propPanel==null) {
propPanel = new BorderPanel {
layout += new GridPanel(properties.length,1) {
contents += new BorderPanel {
layout += new Label("X min") -> BorderPanel.Position.West
layout += new TextField(xmin.toString) {
listenTo(this)
reactions += { case e:EditDone => xmin=text.toDouble; changed = true }
} -> BorderPanel.Position.Center
}
contents += new BorderPanel {
layout += new Label("X max") -> BorderPanel.Position.West
layout += new TextField(xmax.toString) {
listenTo(this)
reactions += { case e:EditDone => xmax=text.toDouble; changed = true }
} -> BorderPanel.Position.Center
}
contents += new BorderPanel {
layout += new Label("Y min") -> BorderPanel.Position.West
layout += new TextField(ymin.toString) {
listenTo(this)
reactions += { case e:EditDone => ymin=text.toDouble; changed = true }
} -> BorderPanel.Position.Center
}
contents += new BorderPanel {
layout += new Label("Y max") -> BorderPanel.Position.West
layout += new TextField(ymax.toString) {
listenTo(this)
reactions += { case e:EditDone => ymax=text.toDouble; changed = true }
} -> BorderPanel.Position.Center
}
contents += new BorderPanel {
layout += new Label("Width") -> BorderPanel.Position.West
layout += new TextField(width.toString) {
listenTo(this)
reactions += { case e:EditDone => width=text.toInt; changed = true }
} -> BorderPanel.Position.Center
}
contents += new BorderPanel {
layout += new Label("Height") -> BorderPanel.Position.West
layout += new TextField(height.toString) {
listenTo(this)
reactions += { case e:EditDone => height=text.toInt; changed = true }
} -> BorderPanel.Position.Center
}
contents += new BorderPanel {
layout += new Label("Max Count") -> BorderPanel.Position.West
layout += new TextField(maxCount.toString) {
listenTo(this)
reactions += { case e:EditDone => maxCount=text.toInt; changed = true }
} -> BorderPanel.Position.Center
}
} -> BorderPanel.Position.North
}
}
propPanel
}
}
I have 7 properties here and a whole bunch of redundant code to set up a GUI for setting those properties. This code is ugly. When I write it, it kind of makes me want to cry. There are basically 7 copies of the same thing here with only minor variations. In Java I never found a way to deal with this that I liked that I could present at this level. The standard rule of "abstract that which varies" led to huge code overhead or writing a separate library for fields that could be edited via code.There are three things that vary. The first is just a String. The second is a value that is converted to a String. The third is setting a value. The third one is the challenge. In C/C++ you could use references/pointers to handle the setting code here, but you would have bigger challenges if what you were setting weren't "primitive" types. In Java you don't have references so you need to encapsulate setting functionality. That means making an interface with a single method and making a bunch of anonymous inner classes. Huge overhead. The code winds up being even longer than the original and as such it isn't really significantly easier to modify.
Scala provides a much nicer solution, mainly because function literals can be written so succinctly. Having tuples helps too. So I make an array of tuples. Each element in the tuples corresponds to one of the things that varies. A loop can run through and add them all.
private val properties:Seq[(String,() => Any,String => Unit)] = Seq(
("Real Min", () => rmin, s => rmin = s.toDouble),
("Real Max", () => rmax, s => rmax = s.toDouble),
("Imaginary Min", () => imin, s => imin = s.toDouble),
("Imaginary Max", () => imax, s => imax = s.toDouble),
("Width", () => width, s => width = s.toInt),
("Height", () => height, s => height = s.toInt),
("Max Count", () => maxCount, s => maxCount = s.toInt)
)
def propertiesPanel() : Component = {
if(propPanel==null) {
propPanel = new BorderPanel {
layout += new GridPanel(properties.length,1) {
for((propName,value,setter) <- properties) {
contents += new BorderPanel {
layout += new Label(propName) -> BorderPanel.Position.West
layout += new TextField(value().toString) {
listenTo(this)
reactions += { case e:EditDone => setter(text); changed = true }
} -> BorderPanel.Position.Center
}
}
} -> BorderPanel.Position.North
}
}
propPanel
}
This code isn't just shorter, it is less brittle and easier to maintain. Want to add a new property? No problem. Declare the variable and add one line of code to the sequence. Need a more complex set? That's not a problem either.As written here, this code won't handle things that don't go into text fields, but it isn't hard to imagine an extension that does that. I need to play with it some more, but I think the "properties sequence" that includes getter and setter functionality might be a great way to write a general library for properties that is easy to work with and maintain. Pull the GUI building part out and the presentation becomes independent of the data as well.
Subscribe to:
Posts (Atom)