Thursday, October 29, 2009

Locking a file in Java

Locking a file in Java is platform dependent. Write once run anywhere? Thumbs down. Some platforms will not allow a file access without a lock while others will.


This is very useful especially when writing your own database (I know some people will argue but this is still happening in corporations handling very sensitive data). It starts with a simple file access.



try {
final File file = new File("Tables.dat");
final FileChannel fileChannel = new RandomAccessFile(file, "rw").getChannel();

// this method will block until a lock is acquired
final FileLock lock =fileChannel.lock();

// this method will not block, it will return null or throw an exception
lock = fileChannel.tryLock();

// TODO: do something with the file

// release the lock
lock.release();

// cleanup / close file
fileChannel.close();
} catch (Exception e) {
// TODO: handle exception
}

Caution: You really need to verify how the target platform handles files. This will not apply on a distributed database as well as networked file systems, if that’s the case you need to write at least a protocol for handling concurrency.

Tuesday, October 20, 2009

Earth planner - Architect Felino Palafox Jr. (Manila Bulletin)

Earth planner
Architect Felino Palafox, Jr.
October 17, 2009, 8:49am



THE MMetroplan is to Felino Palafox Jr. as the ark is to Noah.


Through the plan and the ark, respectively, both forewarned their people of destruction to come their way if they didn’t mend their ways.


Unfortunately, both were not heeded - and we all know what happened thereafter.


“It was not an act of God. The devastation caused by Typhoon Ondoy could have been averted if humans only listened,’’ firmly believes world-renowned Filipino architect Palafox.


Palafox, of course, completely knows what he was talking about. More than 30 years ago, in 1977, he came out with the Metro Manila Transport, Land Use and Development Planning project, a World Bank-funded report that aimed to protect Metro Manila from further flooding. In this report, recommendations were made for transportation, land use, zoning, and flood control, particularly in the eastern part of the metropolis, specifically in – you guessed it – Marikina, Cainta and Pasig.


The proposal, Palafox says, was to build developments in the city in the south, or northeast direction rather than west or eastward reclamations.


But instead of adopting the plan, the government at that time copied the wrong models, i.e. Los Angeles which was not even designed for pedestrians but for automobiles. On top of that, there were poor garbage disposal, and deforestation caused by illegal and legal logging to give way to the rise of subdivisions in all the wrong places.


Palafox says he came out not to fix the blame – and no, he is not running for any elective position.


“This crisis is an opportunity to learn lessons or unlearn the mistakes of the past and maybe revive those good proposals and bring them to the 21st century,” stresses Palafox who shared the same report with 32 other countries. Ironically, while most of these countries adopted the plan, the Philippines did not.



At a young age, while his siblings would build sand castles during beach outings, the young Felino Jr. or Jun would do townships - and elaborate ones at that! But it was only during his senior year in high school at Christ the King seminary that he realized he really wanted to be an architect, and not the priest that he thought he would be.


“My seminary days had a big impact on me. It was where I formed my values. Telling the truth is very important. If you break the rules and nobody caught you, you come out in public and say it, even if they will ask you to kneel down while everybody’s having their lunch,’’ he recalls.


ABS Architecture graduate of the University of Santo Tomas and master’s degree holder in Environmental Planning from the University of the Philippines, Palafox went to Harvard University for his Advanced Management Program for Real Estate studies.


From then on, the Palafox blueprint could be seen in major international projects, particularly in the bustling international metropolis of Dubai.


“In 1977, Dubai was 97 percent oil income, today Dubai is only six percent oil, 94 percent tourism, trade, commerce, real estate. Go around the world and copy. I think that was my first exposure to benchmarking.


Lift the best practices in the world and bring them back to Dubai,’’ recalls Palafox.


That was 1977, when he presented the MMetroplan to the Philippine government. It was also 1977 when he left Manila for Dubai. “MMetroplan went down, Dubai went up,’’ he says with a laugh.


Today at 59, Palafox is a staunch advocate of green architecture, green urbanism, green technology, and sustainable development.


“I’m an environmental planner. That gives more dimension to my work. I’m doing it for God, country, and planet Earth. The triple bottom line is: People first, planet Earth, then profit,” says Palafox.


In this 60 Minutes interview, Palafox reveals what really happened to his 1977 report, the solutions
that should be taken to avoid the likes of Ondoy from wreaking havoc again, the best practices in other countries that we should look up to, and the kind of architects and urban planners that the country badly needs today. (RACHEL C. BARAWID)


STUDENTs AND CAMPUSES BULLETIN (SCB): Most people these days know you as the person who pointed out all the flaws in the planning of Metro Manila right after the great flood happened.


FELINO PALAFOX JR. (FPJ): I didn’t want to come out in the media – until they started blaming God, when they started to say it was an act of God. What’s this, hugasan ng kamay? Or para huwag magabayad ng insurance? Nakakaawa naman ang mahihirap, so I came out.


I was part of the Metro Plan Manila funded by World Bank in 1975-1977. That plan sinunod sa ibang countries. Daniel Burnham, the great American architect commissioned to plan Manila and Baguio, after he planned Chicago, Washington D.C. and other great cities in the world, told the government at that time, if there’s any city in the world, Manila should take inspiration from Paris and Venice. Paris’ river Seine, Pasig River; the canals of Venice, the esteros of Manila.


SCB: So what you’re saying is that we should have embraced the water?


FPJ: Yes. Water is the front door of development.


We were doing alright until we became an independent country, we started implementing the wrong models of urban planning.


Under Burnham, there was more space, there was city movement using the waterways. What did we do after we became a Republic? We turned away from the Burnham recommendation and our planning model became Hollywood and Los Angeles, which was not designed for pedestrians. I think the education of our Filipino architects and planners was more on the Los Angeles type of urban planning. But if you go to any school in the world — I went to Harvard, my daughter to Oxford — they will tell you, Los Angeles has the worst planning!


I met the mayor of L.A., he announced that Los Angeles was a 60-year old mistake.


He said he was sending away his urban planners to New York, Paris, Singapore, Tokyo to unlearn their mistake. After his talk I went to see him. “Mr. Mayor, I have a bigger problem in my country.” “Where are you from,” he said. “From the Philippines. What’s your problem?” “We copied all your mistakes and our leaders in the government are not even aware of it, at least you are aware of it!”


In that 1970 map, which was the basis of the Metro Manila Transport, Land Use and Development Planning (MMetroplan) project, I was team leader and senior planner. I was a United Nations scholar in UP, and part of my contract with UP was I should work with government for two years after my graduation. I got assigned to the Department of Public Works and Transportation and Communication.


(FPJ shows SCB a map)


This is a September 1970 flood map. At that time, with this flood map of the MMetroplan, were recommendations for transportation, land use, zoning, including flood control.


As early as 1975 to ‘77, we identified the directions of growth of Metro Manila. Westward, reclamation; eastward to Marikina; northward towards Bulacan; southward to Paranaque, Alabang, Canlubang.


But we were not allowed to stop development from going east because that time, government was promoting Lungsod Silangan.


If you do a topographical analysis, from the Manila Bay, it’s only, say elevation zero, then as you go further inland towards EDSA, it goes up to elevation 30 meters above sea level. Then it drops to the Marikina valley floor, about five kilometers wide, parang basin ‘yan, then it goes to 10 kilometers, up to 300 meters in elevation and then above 50 kilometers to the Pacific Ocean, pataas siya. So what happened? Illegal or legal logging, deforestation.


The water from the mountains could not be stopped and they brought with them not water but mud, which silted Marikina River, Pasig River, all the esteros and Laguna Lake.


FIXING THE PROBLEM, NOT THE BLAME


SCB: So Metro Manila should have not grown eastwards?


FPJ: It should have been controlled development with the proper infrastructure, controlled sewerage, garbage collection, cleaning Marikina River, Pasig River and San Juan River. Development took place without the infrastructure and the control measure.


SCB: Could the flooding have been prevented if the plan was carried on?


FPJ: The proposal was to protect Manila from the flooding, divert the floodwaters from the mountains to Manggahan floodway towards Laguna Lake. Balita ko pati yun na-clog na rin.


And more importantly, there’s supposed to be a Paranaque spillway. You do the floodway to divert the water here to Laguna Lake, a canal to flush out the excess water. Hindi ginawa ‘yung Parañaque spillway. Clogged na yung Pasig River, Marikina River, San Juan River, clogged na yung mga rivers from Laguna lake towards Manila Bay, hindi pa ginawa yung Parañaque spillway. Thus the flood.


SCB: At that time, were you vigorously campaigning for this?


FPJ: I left the country eh. All the plans were given to all the government agencies.


SCB: So they have it and they knew all along?


FPJ: Of course. Just to do land development here, you need 32 signatures from various government agencies. At least one of those 32 signatories should have warned the developers kung nasaan ‘yung flood line. If you knew the flood line in this area is 17 meters high, why did you only allow nine meters high? Why did you not encourage them to build taller?


Sa probinsya, pag wala akong makuhang information, you know what I do? I go to the churches. Panahon ng mga Spanish friars, hindi binabaha ‘yung altar. Common sense eh.


And we can learn from the Badjaos, nakatira sila above the sea, pero hindi binabaha ‘yung bedroom nila, kasi they know the fluctuating levels of water. ‘Yung mga ninuno natin, ‘yung mga bahay nila bakit hindi binabaha, houses on stilts. And these are very, very common urban planning, master planning, architectural, engineering concepts na kung hindi nabigay sa’yo ng gobyerno, dapat ‘yung arkitekto, ‘yung planner, ‘yung engineer, should have done this due diligence.


SCB: Can we still fix it?


FPJ: Yes it’s fixable. I am defining the problem and how do we fix the problem, where do we move from here, come up with the best alternative solution.


SCB: Even if everything’s in place already?


FPJ: Definitely. I was urban planner of Dubai. Dubai has only 72 kilometers of natural waterfront. Kinulang sila sa waterfront so rural Dubai reclaimed the islands. More than one-half of the Netherlands is reclaimed, bakit hindi sila binabaha? Under the sea ang one-half of Hong Kong.


‘Yung Pasig River, Marikina River, remove the mud, bring it to Manila Bay and then maybe we can create islands there. And those islands we can have recreational and industrial islands, a port, or housing for the poor. Urban planning-wise, architecturally-wise, it can be done. I think it’s political will and funding and attitude.


SCB: May politika ba rin sa ganito?


FPJ: When I do projects abroad, they give us the fault line information. I asked the late Dr. Raymundo Punongbayan, one of the best technocrats we ever had, how come you don’t publish the Marikina fault line? He said he was prevented from publishing it by certain vested interest groups, baka bababa raw ‘yung land value. But even as a tourist in Tokyo, I was able to get the earthquake fault line from the Metropolitan Government of Tokyo. If you go to California, they will even be proud to tell you, this is the Andreas fault line, nagiging tourist attraction pa. Sabi ni Punongbayan, it’s even safe to build beside a fault line, huwag lang above it. Sa UP, there’s a fault line in the middle of the campus. But people don’t know where it is. I know where it is. Kaya ‘yung building na yun hindi ako pumupunta. (laughs)


SCB: Saan?


FPJ: Sa grounds, ‘yung pababang ganun…


SCB: Sunken Garden?


FPJ: Sunken Garden. Sa gitna yata nung main library, kaya walang opisina dun. (laughs) The main building of UST is also designed for an earthquake. The buildings will just separate and come back together again, earthquake breaks. ‘Yung mga may bearings came late na. ‘Yung sa Taiwan, ‘yung mga buildings, they dance.


SCB: How long will it take before the floods subside?


FPJ: There are a package of measures. You remove the putik, the garbage in all our waterways, rivers and lakes. Build dikes. Then let’s start planting again in Sierra Madre, cover the mountains with trees. And then do the Parañaque spillway. It’s a political and funding problem. It’s not an engineering problem.


SCB: What lesson does this great flood teach us, as far as urban planning is concerned?


FPJ: This global crisis is an opportunity to learn lessons or unlearn the mistakes of the past, and maybe revive those good proposals and bring them to the 21st century.


THE WORST IS YET TO COME?


SCB: Seeing all these, don’t you get frustrated?


FPJ: I am, I really am! Kasi the other 32 countries I’ve done architectural planning in, they pay us for our recommendation. Ngayon may sumulat pa baka gusto ko raw tumakbong senador, or sa MMDA. I’m really just trying to help.


SCB: If we continue with what we’re doing…


FPJ: It will happen again, it can be worse. No more turning back. We now have global warming and climate change happening and they are saying, at a minimum, the seawater will go higher by one meter. Another estimate tells us, six meters or 20 feet.


SCB: We will be seeing the city disappearing from the map or hindi naman ganun ka-grabe?


FPJ: It can happen unless we act now.


SCB: How do we deal with the squatters problem?


FPJ: That’s another thing that’s hurting also, they were blaming all the squatters. In Singapore, 82 percent live in government housing – in the right place, at the right time, at the right type of development.


So how did they do it? It’s vertical urbanism. There’s a plan. But they are near their places of work.
Our relocation of squatters have been a failure. I think that policy of relocation is wrong unless when you relocate them, kasama ang livelihood. What’s happening in our country, because they are poor, relocate them as far away from their places of work. We cannot just remove them, we must give them decent housing near their places of work. I think if you remove all the squatters here, mamamatay ang ekonomiya ng Metro Manila. About 62 percent of our policemen are squatters. Where will we get our gardeners, drivers, street sweepers eh ire-relocate mo lahat?


There are government lands that are under utilized, mga military camps, or even underutilized church properties. It even becomes a social problem. Kasi the husband comes to work in the city, and they end up having one, two or three families.


Kapit Bisig sa Pasig River, kasama kami diyan, with ABS-CBN Foundation. So ‘yung mga nire-relocate sa Laguna, may place of work as well, may training pa. ‘Yung isang snatcher ng alahas noon, pagdating sa Laguna, alam mo kung ano ang trabaho? Gumagawa na ng alahas. (laughs) And that’s a private sector initiative.


ARCHITECTURE LOVE


SCB: How did you come to be in the seminary?


FPJ: I come from a very religious family. We were seven brothers and three sisters. Six of the seven brothers, the only choice we had for high school was the seminary, sa Christ the King seminary.


You don’t know where you’ll be assigned after seminary life, maybe Papua New Guinea, Africa, or Abra, and I thought that I wasn’t ready for that. There were also three vows – poverty, obedience, and chastity – and maybe one of them I cannot comply with. (laughs)


SCB: But have you always wanted to be an architect?


FPJ: Ever since I was a young kid, when we go to the beach, my brothers and sisters would make castles, I would do townships. Nandun na talaga. I would make my own toys out of tin cans, out of recycled rubber tires. I was very imaginative daw. When I went to Dubai, it reminded me of when I was a small kid. The ruler of Dubai transformed a garden city out of the desert. It reminded me of building townships out of the sand when I was young.


At age 10, I learned how to drive. On my birthday, my gift was to build a basketball court, ako ‘yung project head. I just asked my parents for the cost of building materials, the laborers were me and my friends. I drove the trailer with the gravel and the lumber. I wasn’t supposed to drive! (laughs)


But it was really only in fourth high school in the seminary that I knew that this was what I really wanted to do. But I was a good seminarian, they tell me. (laughs) I was the student council president,
and despite of my height I was also a basketball varsity player, and I was also the editor-in-chief.


SCB: How did seminary life influence you in what you do now?


FPJ: Most of my values formation happened in the seminary. Telling the truth is very important. If you break the rules and nobody caught you, you come out in public and say it, even if they will ask you to kneel down while everybody’s having their lunch. If you speak the truth, God will be with you.


SCB: How about your Harvard experience, what has it taught you?


FPJ: The best take home value of Harvard is veritas, the truth. Forget everything you learned in Harvard, except the truth and the search for knowledge.


One of the lessons that I never forgot is that if I were to die today, rather than write our eulogy, we should write about the legacy that we want to leave behind. From the seminary to Harvard, I have always been taught to speak the truth, even when I get death threats or libel cases.


SCB: Having been to so many countries, do you have a favorite architectural landmark?


FPJ: Marami. I like Paris, it’s a center for arts. I like London and New York because they’re very walkable. I like Cambridge and Boston because I studied there. You don’t need a car there. You just walk. I like walkable cities.


SCB: Is there a Palafox brand of architecture?


FPJ: I’m not so much for the style. For me, gone are days of the ivory tower architects. We don’t have a style. It is what is required of the property, of the site, of the culture, the expectations of the clients. I don’t want to put a Palafox signature. That’s ego-tripping.


Architecture is teamwork. Architecture is art, science, technology, economy, sociology, transformed into a building form. It’s man-made, man-appreciated, man-used, and man-abused. When I’m gone, I’d like people to appreciate and feel good when they visit these sites, even if they don’t know it’s Palafox architecture.


SCB: How would you convince a young person to take up architecture?


FPJ: Take up architecture that teaches green architecture, green urbanism. We may have to change the curriculum and update it. I hope that doing it for our country and planet Earth is good enough.


Last May, I took up green architecture, responding to the global crisis. Last July, I went back to Harvard, architecture and sustainability. Third week of October, I’ll be in Chicago discussing the advantages of vertical urbanism. Last May, I was in Singapore for green energy. I’ve been asked by the mayor of Berlin to talk about the structures in Berlin. Coming from the Third World, I was asked to share my expertise in a First World country!


I’ve done projects in Sri Lanka and Iran. Iran was devastated by an earthquake about five years ago. I built six schools and I got an award in New York for that, parang ambassador for peace through architecture. We now practice what I call architecture for humanity, patriotic architecture, an architecture of hope and faith. I did GK projects in Smokey Mountain and one in Tarlac for the Aetas.


SCB: Is there a project that you have now that you are proud of and brought out the best in you?


FPJ: One of them is the Global Gateway in Clark. It’s 170 hectares and our clients, Kuwaitis and Americans, want us to put the best practices in the world there. It’s across the airport and will probably be the most modern business park in our country. We’re still conceptualizing at wala pa ‘yung wow architecture there. This will create about 72,000 jobs. We’re bringing to the country $2 billion worth of construction.


In Cagayan de Oro, an area liable to flooding, we’re telling them to make a riverwalk, and put it higher than the floodline.


We do also work, I call it patriotic architecture because I don’t want to call it pro bono, for Gawad Kalinga or the Church. One recently completed, we won a design competition for the Manila Polo Club. We were allowed to preserve two big trees. I explained to them that those trees are valued at least P2 million for the oxygen it’s been giving us for the past 50 years. We built around it and they spent a million pesos more.


We’re designing a museum in Quezon City and I was able to persuade the mayor not to cut the trees, and the contractors are complaining now. We snake around the trees, and the trees that cannot be avoided, we put them inside the museum. Now the contractor is complaining. (laughs)


HIS LEGACY


SCB: What are the challenges that we face in this new era?


FPJ: Climate change is number one. What an irony because we are a signatory to the Kyoto Protocol and we are one of the 43 signatory countries that will be most adversely affected by climate change and global warming.


We have the third longest waterfront. Dubai, Saudi Arabia, and other countries create artificial waterfronts, and what do we do to ours? Basurahan, back of the house, public toilet. And God gave us more than 7,000 islands, 400 rivers, and almost 200 of them are already dead. So I hope that this is really a wake up call. It is not an act of God, but our fault as a nation.


Another challenge that we face is corruption and criminality. How can you address criminality when your policemen are squatters? They’re not even allowed to be buried in the Libingan ng mga Bayani. If you’re a whistleblower, ikaw pa ang ginagawang kriminal.


SCB: Personally, what do you do whenever there are crises like this?


FPJ: I go back to school everytime there is a crisis. I have my seven diplomas, but every nine months or a year after a crisis, I go back because we share mistakes, multicultural and multinational solutions to a global crisis.


I feel so sorry because something so basic as flooding, we can’t even address it. In 1935, the Philippines was number one in Asia. In 1965, we were number two in Asia, that’s why the Asian Development Bank decided to locate here. Our competitors for the location of ADB? Tehran, with the support of the Shah of Iran, and Tokyo. But the nations in Asia voted for Manila. For about 400 years, we were the Asia-Pacific hub of Spanish Europe. For about 100 years, we were the Asia Pacific hub of America. So we’ve been there, we’ve been a global center, we’ve been globally competitive. What went wrong?


SCB: How do you merge the conflicting interests of architecture and engineering with caring for the environment?


FPJ: I’m an advocate of green architecture, green urbanism, green technology, sustainable development. I’m also an urban planner. An architect designs buildings, an urban planners design communities.


I’m also an environmental planner. I’m a planet Earth planner (laughs). That gives more dimension to my work.


SCB: What do you do during your spare time?


FPJ: I have lots of books. I think we have a full time librarian that handles this. We probably have the most collection in the Philippines of architectural books. I also love traveling and photography. I love to keep learning.


SCB: Where do you get the energy?


FPJ: I’m doing it for God, the country, and for planet Earth. And the triple bottom line: People first, planet Earth, then profit. Kaya nagkagulo-gulo ang bansa natin kasi profit, profit, profit.


One third of our potential clients, we give them up if they involve destruction of the environment, or if it involves corruption.


We gave up a million dollars kahit may libel pa akong P50 million. We were able to preserve those trees. The trees are still there, but so is the libel case. The President assured me that they will not be cut. There were 2,000 signatures for the trees.


SCB: Saan maganda magtanim ng puno sa Rizal para maiwasan ang pagbaha?


FPJ: Sa Sierra Madre. But if you want to address climate change, you should start with yourself. I used to fly first class, then my daughter, who is an urban planner also from Oxford, told me that my carbon footprint is very high. Now I fly economy.


I used to love imported food. Now puro local food na lang. Hindi ko lang magive-up ‘yung red wine. (laughs) I walk as much as practicable. The buildings we design, anywhere in the world, we try to reduce the carbon footprint. That explains why I can give up $1 million in architect’s fees to protect trees.


SCB: Is there a future for urban planning?


FPJ: There’s a future for hardworking, honest and benevolent urban planners. Problema din natin ang pocket politicians, pocket consultants, pocket suppliers, and pocket lawyers to protect the pocket politicians. The playing field is no longer level.


Architecture and urban planning are very noble professions. That’s why I had to consult our people here when I gave up the $1 million. I had to consult my people here, and even if it was almost Christmas, I really felt that we had to give up that million dollars. If I accepted the million dollars, we are no better than the prostitutes. We love the money but we don’t love the work. And everyone clapped their hands. Psychic income is there. (laughs)


SCB: So in the Harvard tradition, what’s the legacy that you want to leave behind?


FPJ: That architecture is not just about profit. Always continue to improve but put people first, especially the marginalized.


I’m speaking up because God and the squatters were being blamed. God doesn’t need defending, but it’s not just the squatters.


It’s a sin of omission for all of us.


They say that only one percent of Filipinos are corrupt, but the other 99 percent don’t speak up or just leave the country. It reminds me of a joke that I once heard. A sheik friend told me that several countries were complaining to Allah, because He favored the Philippines with more beautiful
islands, resilient, hardworking and nice Filipinos. Sabi daw ni Allah, “Stop complaining. I also gave them the worst politicians.” (laughs)


(Interview by RACHEL C. BARAWID, RONALD S. LIM, JASER A. MARASIGAN)


Read the original article [here].

Sunday, October 18, 2009

vrms - Virtual Richard M. Stallman

Though I am aware that there are non-free packages lurking in my box, I want to be precise, thanks to Virtual Richard M. Stallman.



Non-free packages installed on linux-conqueror

fglrx-modaliases Identifiers supported by the ATI graphics driver
linux-generic Complete Generic Linux kernel
linux-restricted-modules- Non-free Linux 2.6.28 modules helper script
linux-restricted-modules- Restricted Linux modules for generic kernels
nvidia-173-kernel-source NVIDIA binary kernel module source
nvidia-173-modaliases Modaliases for the NVIDIA binary X.Org driver
nvidia-180-modaliases Modaliases for the NVIDIA binary X.Org driver
nvidia-71-modaliases Modaliases for the NVIDIA binary X.Org driver
nvidia-96-modaliases Modaliases for the NVIDIA binary X.Org driver
nvidia-glx-173 NVIDIA binary Xorg driver
skype Skype - Take a deep breath
tangerine-icon-theme Tangerine Icon theme
virtualbox-3.0 Sun VirtualBox

Contrib packages installed on linux-conqueror

nvidia-common Find obsolete NVIDIA drivers
nvidia-settings Tool of configuring the NVIDIA graphics driver

13 non-free packages, 0.9% of 1505 installed packages.
2 contrib packages, 0.1% of 1505 installed packages.

Well, I need these.
- NVIDIA - Who wants to use the generic vesa driver (+ mesa) for playing games?
- Skype - I have relatives to keep in touch with.
- Virtual Box - I use Windows 7 to run web applications classified as For Microsoft Internet Explorer Only.

Wednesday, October 07, 2009

Linus’ discussion about goto statements

As discussed by Linus Torvalds 6 years ago,


From: Linus Torvalds
Subject: Re: any chance of 2.6.0-test*?
Date: Sun, 12 Jan 2003 12:22:26 -0800 (PST)


On Sun, 12 Jan 2003, Rob Wilkens wrote:
>
> However, I have always been taught, and have always believed that
> “goto”s are inherently evil. They are the creators of spaghetti code


No, you’ve been brainwashed by CS people who thought that Niklaus Wirth
actually knew what he was talking about. He didn’t. He doesn’t have a
frigging clue.


> (you start reading through the code to understand it (months or years
> after its written), and suddenly you jump to somewhere totally
> unrelated, and then jump somewhere else backwards, and it all gets ugly
> quickly). This makes later debugging of code total hell.


Any if-statement is a goto. As are all structured loops.


And sometimes structure is good. When it’s good, you should use it.


And sometimes structure is _bad_, and gets into the way, and using a
“goto” is just much clearer.



For example, it is quite common to have conditionals THAT DO NOT NEST.


In which case you have two possibilities


- use goto, and be happy, since it doesn’t enforce nesting


This makes the code _more_ readable, since the code just does what
the algorithm says it should do.


- duplicate the code, and rewrite it in a nesting form so that you can
use the structured jumps.


This often makes the code much LESS readable, harder to maintain,
and bigger.


The Pascal language is a prime example of the latter problem. Because it
doesn’t have a “break” statement, loops in (traditional) Pascal end up
often looking like total shit, because you have to add totally arbitrary
logic to say “I’m done now”.


Linus


Read the full discussion [here]. PHP 5.3 recently introduced goto statements.

Saturday, October 03, 2009

Cypress Semiconductor USB2.0 Storage Device

I’m just happy to have this device plugged in my PC.



UUID: 32efe183-7da8-4aea-8750-299d6584cc4a
VendorId: 0x04b4 (04B4)
ProductId: 0x6830 (6830)
Revision: 0.1 (0001)
Manufacturer: Cypress Semiconductor
Product: USB2.0 Storage Device
SerialNumber: ############
Address: sysfs:/sys/devices/pci0000:00/0000:00:02.2/usb1/1-8//device:/dev/bus/usb/001/004