Archive for the ‘Programming’ Category

h1

a new project site for my oS

April 7, 2009

a new project site was created @ Google code.

address: http://code.google.com/p/ring0/

you can fine updates on the code base, review the code; etc

wiki is also created for updating new concepts, ideas, learnings; etc

_enjoy coding

h1

Running C and Python Code on The Web

July 8, 2008

Last week, Scott Petersen from Adobe gave a talk at Mozilla on a tool chain he’s been creating—soon to be open-sourced—that allows C code to be targeted to the Tamarin virtual machine. Aside from being a really interesting piece of technology, I thought its implications for the web were pretty impressive.

 

Before reading this post, readers who aren’t familiar with Tamarin may want to read Frank Hecker’s excellent Adobe, Mozilla, and Tamarin post from 2006 for some background on its goals and why it’s relevant to Mozilla and the open-source community in general.

 

If I followed his presentation right, Petersen’s tool chain works something like this:

 

1.  A special version of the GNU C Compiler—possibly llvm-gcc—compiles C code into instructions for the Low Level Virtual Machine.

2.  The LLVM instructions are converted into opcodes for a custom Virtual Machine that runs in ActionScript, a variant of ECMAScript and sibling of JavaScript.

3.  The ActionScript is automatically compiled into Tamarin bytecode by Adobe Flash, which may be further compiled into native machine language by Tamarin’s Just-in-Time (JIT) compiler.

 

The toolchain includes lots of other details, such as a custom POSIX system call API and a C multimedia library that provides access to Flash. And there’s some things that Petersen had to add to Tamarin, such as a native byte array that maps directly to RAM, thereby allowing the VM’s “emulation” of memory to have only a minor overhead over the real thing.

 

The end result is the ability to run a wide variety of existing C code in Flash at acceptable speeds. Petersen demonstrated a version of Quake running in a Flash app, as well as a C-based Nintendo emulator running Zelda; both were eminently playable, and included sound effects and music.

 

So, once Petersen’s modifications to Tamarin make their way into the next version of

Adobe Flash, we can expect to see older commercial games running in the browser. Even more impressive, though, is the sheer volume of existing code that can be made to run inside the browser: Petersen showed us the C-compiled versions of Lua, Ruby, Perl, and Python all running on the web in secure Flash sandboxes.

 

What this means for Python

 

The potential implications this has for Python are particularly interesting to me. The ability to run Python on the web is exciting, to say the least; also interesting is the fact that by sandboxing CPython in a virtual machine, we solve a lot of the security issues that currently face the language when it comes to running untrusted code.

Petersen’s work also resonates with a few goals of another project called PyPy. I’m going to try to explain the idea behind PyPy in a later post; for the time being, the slides from my April 2007 ChiPy presentation on PyPy may serve as a passable introduction.

 

In a nutshell, the difference in mindset between PyPy and Petersen’s work is that the former is radically innovative in scope and mission, while the latter is pragmatic. PyPy’s goal is essentially to move the canonical implementation of Python from C to Python itself, and then use a pluggable toolchain to translate the Python interpreter to any platform with a configurable set of language and implementation features. In one fell swoop, this modularizes the composition of the Python interpreter in such a way that innovating and maintaining different ports and variants of Python like IronPython, Jython, and Stackless no longer requires either writing an entire copy of the same interpreter in a different language or branching the CPython source code and making pervasive changes to it.

 

Rather than focusing on innovation, Petersen’s work focuses on code reuse. Instead of moving a canonical interpreter implementation from C to a dynamic language, his strategy is to simply compile the existing C code to run in a virtual machine that’s implemented in a dynamic language. Both approaches aim to obviate the necessity of “ports” of interpreters to different platforms, and as such their purposes intersect at a common subset of functionality. But Petersen’s work can’t be used to facilitate the innovation of the Python language and its implementation, while PyPy offers few or no tools to reuse existing non-Python code. Perhaps it’s possible to combine the best of both worlds by taking PyPy’s generated C interpreter and using Petersen’s toolchain to allow it to be usable on the web and other places that Tamarin runs.

 

What this means for the Open Web

 

To be honest, I’m not quite sure where the dividing line is between what of Petersen’s work is Flash-specific and what can be reused to benefit the Open Web. Since ActionScript is a sibling language to JavaScript, it’s possible that the custom VM he created can be run in a browser with relatively few modifications—albeit much more slowly in Firefox at the time being, since SpiderMonkey-Tamarin integration is not yet complete. Once that’s further along, though, I imagine it should be possible to create C “libraries” that can be used in the toolchain to allow sandboxed C code to interact with web pages rather than Flash apps. Should this be feasible, I think it will possibly be the ultimate in a relatively recent string of next-generation Javascript virtual machines that allow existing code to run safely in browsers.

 

Also, in the context of the web, download size is a significant concern because applications are essentially streamed to clients. While Petersen’s toolchain means that it’s possible to instantly inherit most of CPython’s benefits on the web, it also means that we get all of its flaws along with it—such as the fact that the standard CPython distribution is a few megabytes large. But there’s ways to get around this.

 

In any case, I’m really excited to see how both Petersen’s work and PyPy proceed. I just hope I haven’t mis-represented either one of them here due to a lack of understanding; I’ll try to correct this blog post as I become aware of my mistakes.

h1

9 Reasons Why Application Developers Think Their CIO Is Clueless

July 2, 2008

As CIO you hold one of the most important executive positions in your company. And, to lead successfully, you must earn the respect of both the business and your information technology organization. But earning the respect of application development professionals is no easy task: The CIO position has been a revolving door as of late and many application development professionals have become cynical.

How Not to Be Clueless

“My CIO is clueless.” These are words you don’t want to hear if you want to earn the respect of your application development professionals. So how do you avoid being a clueless CIO? Steer clear of these behaviors:

1. The CIO is a control nut.
If you want to be a Controller then get a job in the accounting department. Okay, so maybe you are not a certifiable control nut. Maybe it is just a strategy you are employing because your direct reports can’t get the job done. If this is the case, then control is not the solution. Have the courage to replace those managers that aren’t strong. Control won’t work in the long run anyway.

2. The CIO is aloof.
Stop thinking about your golf game. You may have a great team—strong individual managers and team chemistry—but your leadership is still necessary to keep things on course (not the golf course). Besides, no matter how much you practice, your golf game will still be mediocre, but you can be at the top of your game as CIO if you work at it.

3. The CIO gulps vendor Kool-Aid.
Did you know that there are more than 34,750 registered lobbyists in Washington, D.C., for just 435 representatives and 100 senators? That’s 64 lobbyists for each congressperson. I wonder how many vendor account managers there are per CIO. You are smart enough to know that vendors are trying to sell you and you won’t be fooled wholesale. Yeah right. Their influence can eat away at you without you even realizing it. Be even more skeptical than you are now. Just say no.

4. The CIO is a technical dinosaur.

Unless you are running for president of the United States, experience does matter. Technology has changed since you were writing RPG on the mainframe umpteen years ago. And for you younger guys who made your bones writing VB or Java Web apps, make sure you know why there is so much buzz about Ruby on Rails and multicore programming. Your ability to talk tech will go a long way to earning the respect of application development professionals.

5. The CIO is ubergeeky.
Application developers respect a CIO who has deep technical knowledge, but your job is to lead, not to tell them how to architect systems, write code or tap an Ethernet coaxial cable. Rise to your leadership position and trust your technical people to get the job done. And if you don’t trust them then you are either a control nut (see number one) or you don’t have the right people.

6. The CIO thinks changes can happen overnight.
Sorry to have to break this to you: You are not a wizard and your magic wand doesn’t work.

7. The CIO doesn’t know the difference between resources and talent.
The fastest way to lose respect is to put clueless managers in charge. Clueless managers equal clueless CIOs. Can you ever imagine Doc Rivers, coach of the 2008 world champion Boston Celtics, talking about player resources like they were interchangeable? “I need two guard resources.” “I need a center resource.” No. Talent and teamwork make winning teams. Talent matters. Don’t pay lip-service to talent. Find a way to locate and use the talent in your organization. You will only be as good as the team you assemble.

8. The CIO collaborates to death.
Whether it is the character flaw of being indecisive or some middle-school notion of democracy, you are in charge. Collaboration is critical, but you also need to make the right decision at the right time. Collaborate like Captain Kirk. “Spock?” “Bones?” He gets opinions from his experts but there is never any question about who will make the final decision. And, if you never watched Star Trek then you shouldn’t even be a CIO.

9. The CIO spends all of his time trying to get promoted to CEO.
Not gonna happen, sailor. Despite the seemingly perfect career path for CIOs, it just doesn’t seem to happen. Only a handful of CIOs ever got the top job at any of the Fortune 500 companies. Keep your secret aspirations to become CEO to yourself or change your aspirations. Application developers need to know that you are there for them—that you are not CIO du jour.

To Thine Own Self Be True

Leadership can take many forms and styles but one thing all successful leaders have in common is that they earn and keep the respect of the rank and file. Be your own leader and maximize your success by earning the respect of your application development professionals and avoid being a clueless CIO.

h1

Google gets serious about the Mac

June 9, 2008

In the “20 percent time” that Google employees have to work on projects of personal interest, it turns out that an increasing number are spending time writing open-source projects for their beloved Macs.

Google has long had a fondness for the Mac, with upwards of 6,000 of its 10,000 20,000 current employees opting to use the Mac over Windows.

It is in the 20 percent employee development time, however, where this statistic becomes interesting. At Google, development time translates into products. The more Mac-friendly employees, the more Mac-related development. The more Mac-related development, the more Google-sponsored Mac-based open-source code.

As Google’s Mac Developer Playground demonstrates, some of this code is quite interesting.

Here are a few of the best open-source Mac projects from Google:

  • AppMenuBoy: Easily add hierarchical menus in the dock of applications.
  • MacFuse: “Implements a mechanism that makes it possible to implement a fully functional file system in a user space program on Mac OS X…(that) opens up a whole new set of opportunities for Macintosh developers, who can now put intuitive and innovative interfaces around all kinds of information.”
  • Statz: Ever want to update your status in Skype, Adium, etc. all at the same time, from one user interface? Well, here you go.
  • Vidnik: “Record video segments using your iSight camera, and upload them to YouTube.” Makes the Mac-to-YouTube process even easier (if that was possible).

There’s much more. You can always find stable projects ready for mass consumption like Google Desktop for the Mac and Notifier here, but much of the most intriguing code is housed on the Playground.

All of it open-source. All of it is available for developers to tinker with, improve, and distribute. This is a very different Google from the one I’ve been imagining for the past few years.

All of which has me thinking: what would a Google-plus-Apple combination look like? Both companies share a respect for design and aesthetics. Both companies focus on consumers. Importantly, both companies are also at the top of their game.

Could the two merge and create an even more powerful Goopple? Yes, though it is unlikely. I just can’t imagine Steve Jobs sharing the stage with anyone.

So I’ll continue to enjoy Google’s open-source Mac projects and imagine a day when the best in desktop meets the best in Web. What a cool combination that would be.

 

Google Mac Developer Playground

Welcome

Many developers at Google work on interesting open-source projects, some full time, some in their 20% time. This page is a collection of several such Mac-related projects.

Some of these projects, like MacFUSE, are mature and supported. Others are unsupported technology demos that we provide solely for experimentation and entertainment.

For the latest news, visit our blog. If you are looking for more Mac software from Google, check out www.google.com/mac.

h1

PHP Program

May 13, 2008

< ? php

echo ” Hello World ! “;

? >

h1

Dr. Dobb’s 2008 Hall of Fame Calendar

May 13, 2008

Okay, the year is almost half over and I’m just now getting around to posting Dr. Dobb’s 2008 Hall of Fame Calendar. Which probably means that I should start on Dr. Dobb’s 2009 Hall of Fame Calendar right away.

What is Dr. Dobb’s 2008 Hall of Fame Calendar? It’s a downloadable PDF document with monthly photos of recipients of the annual Dr. Dobb’s Excellence in Programming Award. Let’s see, since this is May… you have a whole month of Bruce Schneier who received the award for his contributions and writings about computer security.

 You can download your copy of Dr. Dobb’s 2008 Hall of Fame Calendar here.

h1

C Program

May 13, 2008

main()
{
printf(“Hello World!”);
}

h1

After Long time !!!

May 12, 2008

Just thought of writing a BASIC program after almost 15 years !!!

AUTO

10 REM — Hi BASIC —
20 PRINT “HELLO WORLD! “
30 END

AUTO

10 REM — I STILL REMEMBER YOU —
20 PRINT “What is your name”
30 INPUT NAME$
40 PRINT “What is your age”
50 INPUT AGE
60 PRINT “What is date you born. Enter only the date”
70 INPUT DATE
80 PRINT “What is month you born. Enter only the month”
90 INPUT MONTH
100 DIFF = 2008 – AGE
110 NDIFF = DIFF
120 NUM = 1
130 IF MONTH 4 THEN GOTO 220 ELSE GOTO 270
220 FOR I = DIFF TO 2007 STEP 1
230 PRINT “Your “; NUM ; ” birthday was on “; DATE ;”/”; MONTH ;”/”; NDIFF
240 NDIFF = NDIFF + 1
250 NUM = NUM + 1
260 NEXT I
270 PRINT “Goodbye BASIC. I will love you forever !!!”
280 REM — End —
290 STOP

h1

May 1, 1964: First Basic Program Runs

May 12, 2008

1964: In the predawn hours of May Day, two professors at Dartmouth College run the first program in their new language, Basic.

Mathematicians John G. Kemeny and Thomas E. Kurtz had been trying to make computing more accessible to their undergraduate students. One problem was that available computing languages like Fortran and Algol were so complex that you really had to be a professional to use them.

So the two professors started writing easy-to-use programming languages in 1956. First came Dartmouth Simplified Code, or Darsimco. Next was the Dartmouth Oversimplified Programming Experiment, or Dope, which was too simple to be of much use. But Kemeny and Kurtz used what they learned to craft the Beginner’s All-Purpose Symbolic Instruction Code, or Basic, starting in 1963.

The college’s General Electric GE-225 mainframe started running a Basic compiler at 4 a.m. on May 1, 1964. The new language was simple enough to use, and powerful enough to make it desirable. Students weren’t the only ones who liked Basic, Kurtz wrote: “It turned out that easy-to-learn-and-use was also a good idea for faculty members, staff members and everyone else.”

And it’s not just for mainframes. Paul Allen and Bill Gates adapted it for personal computers in 1975, and it’s still widely used today to teach programming and as a, well, basic language. (Reacting to the proliferation of complex Basic variants, Kemeny and Kurtz formed a company in the 1980s to develop True BASIC, a lean version that meets ANSI and ISO standards.)

The other problem Kemeny and Kurtz attacked was batch-processing, which made for long waits between the successive runs of a debugging process. Building on work by Fernando Corbató, they completed the Dartmouth Time Sharing System, or DTSS, later in 1964. Like Basic, it revolutionized computing.

Ever the innovator, Kemeny served as president of Dartmouth, 1970-81, introducing coeducation to the school in 1972 after more than two centuries of all-male enrollment.

h1

Not so different

May 12, 2008

The following are programs written in Ada, C and Java that print to the screen the phrase “Hello World.”

ADA PROGRAMMING LANGUAGE

with Ada.Text_IO;
procedure Hello_World is
begin
Ada.Text_IO.Put_Line (“Hello World>br>from Ada”);
end Hello_World;

C PROGRAMMING LANGUAGE

#include

void main()
{
printf(“\nHello World\n”);
}

JAVA PROGRAMMING LANGUAGE

class helloworldjavaprogram
{
public static void main(String args[])
{
System.out.println(“Hello World!”);
}
}