Categories
JavaScript

Eclipse: beyond the geek

I’ve been spending time today with Eclipse, the popular development tool used primarily by Java developers. I’m using Eclipse in my J2EE development because there’s a plugin that enables EJB development for JBoss, and another plugin that enables web servlet development, and yet another that allows me to interface with a SQL Server database, and even a plugin to connect with Subversion. These are all professional development tools, more or less. Yet Eclipse is not just for the pros, or the geeks.

It’s easy to install, with installations for Unix, Linux, Mac, and Windows. I had to use gunzip and tar to unzip and expand the package for the Mac, because the machine I’m using is my older Mac; it doesn’t have the modern unzipping tools of the Tiger machines.

Once Eclipse is installed, then the fun begins. You can add any number of plugins.

 

For instance, if you work with JavaScript, there are several JS plugins, and even some Dojo-based AJAX plugins. Some of these may cost, others are free. One of the more popular is the Web Tools Plugin environment, which is free and sets your Eclipse up to develop almost anything web-related.

Eclipse was installed on my PC for work, but I wanted to explore the use of Eclipse as a tool for JavaScript developers. I installed it on my Powerbook, and then used the automated update and installation program built into Eclipse to add the Web Tools. How do you do this? You’re going to laugh, it’s so easy.

First, click the Help menu item, then Software Updates -> and then choose Find and Install. From the window that opens, click the Search for New Features to Install feature, and then click Next.

In the page that opens, there’s a box listing out what remote sites to check for new and updated software. I then click New Remote Site, and in the dialog box that opens, I added in:

Name: Web Tools

URL: http://download.eclipse.org/webtools/updates/

I clicked Finish and when given a new dialog with a list of features to install, checked the box next to the Web Tools option, and then clicked the Next button. Following, I’m asked to agree to the license terms, and from that point on, Eclipse not only downloads the tools, it also downloads all the pre-requisites needed for the tools to operate. That’s it — when it’s finished it asks to re-boot and when you’re finished, you’re ready to use the new functionality.

I created a new project by selecting File->New->Project->Other. From the list that opened, I just selected Simple, and then gave the project a name: test. Based on whatever project type is picked, Eclipse adds any supportive libraries and generated files, listed underneath the project name in the left pane.

I created a new JavaScript file by again selecting File->New->Other. From the dialog that opens, I clicked Web, and then selected JavaScript. Since I’m saving my creativity for my work, I again used the name test to name the JS file: test.js.

At this point, the new test.js file shows in the left pane, and the open file ready for edits is shown in the center panel. I type in whatever JavaScript I want. As I add new program objects, like variables, they show in the outline panel on the right. If I use a built-in object, like Math or document, when I type the period to access an object property or method, a popup window opens listing available options, and even the browser icon associated with the option.

 

When I’m ready to preview the functionality, I click the Preview tab that shows at the bottom of the center edit pane; the preview emulates a browser page.

Being a programmer I know that if one plugin is good, dozens are better. Shopping around, I installed Eclipse plugins for PHP (PHPeclipse), database access (DbEdit), and a CSS editor.

The latter was a commercial plugin from JointLogic, downloadable for trial for 30 days. Once installed (using the same procedure I used to install the Web Tools), I created a new CSS file using the same approach as I used with the JS file. I then began to add styles to the new stylesheet file, and as I added new elements, they would show in the outline pane in the right.

I also selected the CSS style view pallet for the plugin by selecting Window->Show View->Other and then selecting JointLogic Web Tools and then the CSS Styles. The view is listed as a tab in the bottom pane. When double clicking on an item in the outline view, such as the H1 header, a dialog opens giving options to define this type of HTML element.

 

After selecting the changes, and clicking OK, the edits are neatly added to the CSS document.

Eclipse isn’t an all in one tool, and wouldn’t be for folks who don’t like to tweak styles, HTML, or script. It requires a Java runtime environment, and it’s not small. But it is free, it is modular, and it isn’t just for geeks.

Thought you’d all enjoy a new toy to play with.

Categories
JavaScript RDF

We interrupt your regular thinking

I wrote a while back about putting RDF files out on Amazon’s S3 file storage. Why, I was asked. After all, I don’t have enough files, I have room on my server, and so on. Yup, I agreed. Other than S3 being nifty tech and wanting to be a cool kid, why would one want to use it?

One reason: it forces one to think differently about application development and data storage when you’re restricted to using web services rather than traditional file or database I/O to access the data.

Les Orchard wrote today about his S3 Wiki work:

One of the mind-bending concepts behind this whole thing for me is that both the documents and the authoring application are all resident on the S3 servers, loaded and run on the fly in a browser. The magic S3 lends is simple file I/O, taken for granted by applications in nearly every other development environment. Otherwise, JavaScript in a browser is a very capable system.

I agree that JavaScript in the browser is a very capable front end. Oh, I don’t agree with replacing Word with Ajax–why do we always see Office as the only killer app in the world and systems have to ‘replace’ it to be considered viable? But JavaScript in browsers, as we progress closer to true cross-browser compatibility, is a very powerful application development system.

However, the part that caught my interest specifically is what Les wrote about the data storage of his wiki application. He is spot on in that S3 changes how you think of I/O (Input/Output). It forces you to challenge your data storage assumptions–all the golden rules you’ve learned since you were knee high to a grasshopper. When you do, you get this sudden burst of ideas. It’s like biting into a SweeTarts candy–you’re not sure if you like the experience, but it sure gets your attention.

In my copious spare five minutes a week, I’m loading RDF into S3. I have an idea. It came to me in a burst. It made my face pucker.

Categories
JavaScript RDF

Asking permission first

Recovered from the Wayback Machine.

Tim Bray has an interesting take on the use of AJAX: rather than have your server do the data processing, use AJAX to grab the data and then have the clients do the work:

A server’s compute resources are usually at a premium, because it’s, you know, serving lots of different client computers out there. Lots of different computers, you say; and how busy are they? Not very; your average Personal Computer usually enjoys over 90% idle time. So you’ve got a network with a small number of heavily-loaded servers and a huge number of lightly-loaded clients. Where do you think it makes sense to send the computation?

The thing is, you know what’s happening on your server, but you don’t know what’s happening on each individual client machine. In addition, you don’t know what each client can and cannot support. You don’t even know if your client has JavaScript turned on to be able to allow you do to the processing.

I agree that we can do some interesting work with Ajax and grabbing data from the server and processing it on the clients. Perhaps we need to explore some newer uses of JavaScript and RDF in light of the new server-client interoperability.

However, a developers first priority is to do no harm to those using their application. Their second priority is to ensure their pages are accessible by their target audience. If we start making assumptions that the client’s machine is ours to do with what we will, we won’t need hackers to inject harm into our scripts–we’ll do a fine job of it, ourselves.

Categories
JavaScript Technology

Babble

Tim Bray recently expressed doubts about PHP:

So here’s my problem, based on my limited experience with PHP (deploying a couple of free apps to do this and that, and debugging a site for a non-technical friend here and there): all the PHP code I’ve seen in that experience has been messy, unmaintainable crap. Spaghetti SQL wrapped in spaghetti PHP wrapped in spaghetti HTML, replicated in slightly-varying form in dozens of places…PHP has earned everyone’s respect by getting where it is, and Sun should reach out to it more than we have. But in the big picture, it feels vulnerable to me.

Tim’s lamentations about PHP reminded me of my initial encounters with, and reluctance about, some of the computer languages I’ve used–and I’ve used a goodly number. All in all, I can ‘speak’ 20 computer languages. My head is a jumble of languages–a veritable tower of babble.

(Discussion about programming languages and showing of wounds earned follows. Note that I make use of naughty language. Lots and lots of naughty language. It’s a code thing.)

 

BASIC

I started with BASIC. Contrary to popular myth, that’s B-A-S-I-C, which stands for: Beginner’s All-purpose Symbolic Instruction Code. However, the language is now usually given as just ‘Basic’.

I wrote my first application in BASIC in VAX/VMS. A not particularly useful combination at the time, but popular in colleges for classwork. Yes, I wrote my first application in college, not at home on my PC or laptop. They didn’t have PCs in a box or laptops at the time. You could have a home computer, but you’d have to either hack one, or spend a lot of money on one.

They did have the Internet–and that’s big ‘I’ Internet–but no Web. You could interact with people, though. Usenet, was big–for all those science types to talk about sex.

Anyway, it’s through BASIC that we get the origination of the concept of ‘spaghetti code’. This is code that uses a command called a GOTO to indiscriminately jump about in code to the point where you can’t follow what’s happening, and the code looks like, well, a pile of spaghetti jumbled up on a plate. The following application is an example of spaghetti code, in BASIC:

10 dim i
20 i = 0
30 i = i + 1
40 if i <> 10 then goto 90
50 if i = 10 then goto 70
60 goto 30
70 print “Program Completed.”
80 end
90 print i & ” squared = ” & i * i
100 goto 30

See? GOTO here, GOTO there — pile of doo-doo. My teacher, who actually had a PhD in English Literature but ended up in the computer sciences, said if we used GOTOs, he’d hurt us. Considering that he used to embed bits of Chaucer in his class presentations, I would have thought he would have embraced GOTOs, but, there you go.

That was my first language.

Pascal

My second language was Pascal. This is a language named after that great mathematician Blaise Pascal. It’s also a ‘teaching’ language and was never intended for commercial use. Many software developers learned how to program in a computer language they would never use again once they left college. This is just one of the many head fucks universities put their CompSci students through.

(Even then, the world has a way and Borland released Turbo Pascal. Why? Because Borland was led by a French man, and you never tell the French what to do. Bonus point: who was Borland’s founder?)

Anyway, Pascal is good because it’s a structured language and would, the hope was, teach us all how to be good structured programmers. It introduced us to functions and subroutines and proper naming and rigorous development practices–which we promptly forgot as soon as we got out of school and got into eXtreme programming; drinking caffeinated pop and telling each other jokes where the punch line goes, “…but it worked in PowerPoint!”

We ended up using Pascal for other classes, such as the study of algorithms and relational data structures. Yes, I believe I learned how to do the Bubble Sort with Pascal. This was, what, a quarter century ago, yet Google and Yahoo and other companies still ask potential employees how they would do something like a Bubble Sort.

You know what I would answer if asked this in an interview? Easy:

sort();

Then I would ask the interviewers could we please now get to the real questions?

Assembly

 

Where was I…programming languages… My next language wasn’t a higher-level language. It was Assembly. Yes, we had to learn Assembly back then. What amazes me is that people are required to learn Assembly in college today. This to me is a demonstration of how most colleges and universities haven’t a clue how to run a computer science program.

Wikipedia had the following assembly language sample:

mov al, 061h

Basically, this is equivalent to moving a hexadecimal value into a register named ‘al’. It is very time consuming. It’s also very powerful — this is to ‘the metal’ programming — as efficient as one can be. One line of code at a higher level language can translate into 10, 20, even more lines of assembly. At some point corporations discovered that it cost more to have programmers write those 10,20, or more lines than it did to add memory or disk space, so most of us don’t use Assembly in our day to day operations.

Modula II, LISP, SNOBOL4

From Assembly, the languages piled on rapidly. We beta tested the first Modula II compiler, which was meant to be a commercial version of Pascal (but never really took off). We then jumped into the esoteric with Lisp (LISP) and SNOBOL4.

Lisp is one of the oldest higher-level programming languages, and is very popular with the AI folks. In the Parable of the Languages story, I called it ‘loopy’ and that’s the best definition I’ve heard of it. I remember talking with my teacher one day about the class. We talked about how each language has a ‘gotcha’ moment when the person learning it finally ‘gets’ it. I asked him when I finally reached this state with Lisp, it would hurt, wouldn’t it?

I still passed the class.

 

I bet if you’ve heard of Lisp, you haven’t heard of SNOBOL. SNOBOL translates to StriNg Oriented symBOlic Language, but supposedly the real reason for the name is one of the implementors once said, “This program hasn’t a snowball’s chance in hell…”.

I took to SNOBOL4 like a fish takes to tartar sauce–so much so that the next time it was taught, the professor (he of Chaucer fame) had me as teaching assistant. It was when working with SNOBOL4 that I finally learned the most important lesson a CompSci needed to learn: that every problem, no matter how complex, can be broken down into smaller, simpler components.

This might sound intuitively obvious, but it’s actually a tough lesson to learn with programming. Normally when faced with a problem, we see it as a whole and try to solve it as a whole. This is the number one reason for bad code, spaghetti code, what have you. We see the whole, it intimidates us, frustrates us, and we rush our coding so that we’re done that much more quickly. If, instead, we look at the problem and break it down into manageable pieces, the solutions become clear, the code simpler, and we’re relaxed when we write the program.

The more relaxed the programmer, the better the code. This is a lesson that Microsoft never learned. Can we say, “Bug ridden piece of shit”? Better yet:

OUTPUT = ‘Hello World! Windows is a bug ridden piece of shit!’
END

C

What about the C programming language? Yes, what about it. I’ll have you know, I didn’t spend all my time on esoteric languages. I still have my first copy of the classic Kernighan and Richie’s The C Programming Language (second edition).

In my last year of college, the head of the CompSci program told me that one of the other departments needed a C programmer to maintain some geographic programming software that was used by the military in the neighboring Yakima Firing Center. The CompSci head asked if I was interested in the part-time position?

Wow, my first job programming. And then I saw the code.

File after file of code scattered all about a machine, with no external documentation and exactly one line of comments in all of it. One line. To this day, I wondered what would lead a programmer to write one, and only one line of comments. I looked and followed and tried to follow and ended in dead ends with no clue as to how the code ever compiled, much less managed to work. I approached the head of the department controlling the code and said I would need something, some kind of key, in how all this code held together. He then arranged for me to meet with the original developer at a conference in Seattle.

So I asked my now ex-husband to get a day off from work to drive me over (I didn’t drive at the time) and we found the hotel where the conference was, and waited in the car outside for it to end. As it did, one military uniformed person after another left until this one guy–bearded, glasses, button down, pocket protector, the whole geek thing–came out. I guessed this was the person I needed and approached him, introducing myself. He’d already been told I would be coming and as I started asking him about the structure of the entire application, he whipped a pen out of his protected pocket, grabbed a paper napkin, wrote a bit of code on it, smiled toothily at me, passed me the napkin and was off after the uniforms.

I stood there, holding that napkin for a long, long moment. I didn’t even have a chance to ask him about that one comment line.

This was the second most important lesson I learned in college: that people working in computers can be fucking assholes. And here you thought I learned this from weblogging.

I fumed all the way home, and told the department head that I found the person’s help to be less than useful. I also turned in an expense report for the trip, at which point he exhibited surprise and said that they had no idea that I would want to be paid for this work. Oh no, they thought that I would want to use this as fun little challenge. This was news to me, as it was to the CompSci department head, who had some choice words to say to his peer about using and abusing his students.

Third most important lesson learned: Employers will play up the ‘fun’ bits of a job, in order to distract you from the fact that they’re sucking you down to a brittle little former husk of yourself by working you long hours for little pay. Might remember that next time you have that free lunch at Google.

Fortran, not COBOL

Let’s see, what’s our count so far? That’s Basic, SNOBOL4, Assembly, Pascale, Modula II, C, and Lisp. Seven languages.

It wasn’t long after that I was introduced to the old timer, the granddaddy of them all: Fortran. Fortran (or FORTRAN for FORmula TRANslation) is as old as dirt, and has existed forever–at least as long as man. I kid you not, there are cave paintings that could successfully compile through a Fortran compiler.

Fortran was one of the few languages I learned in college that I used in my professional life. Fortran was the language used for Peace Shield, the Saudi Arabian Air Defense System. My job was to take the Fortran created by three separate companies, and reverse engineer it into a data dictionary in order to facilitate the documentation project.

I loved this job. I would take home Fortran pads (Fortran was position dependent–the position in the page where you typed the characters in the program had a significant impact on what happened with the program) and work on the design of my data dictionary tools in the evenings and weekends. Eventually the company gave me one of the very first Compaq portable computers to use, which had an amber screen with black letter and which would crash, on average, once a week.

To mention ‘structured programming’ and Fortran in one breath would, at the least, generate raised eyebrows among the folks working on Peace Shield. The less polite would guffaw. Fortran, at least in those days, was not known to be a highly structured programming language. In fact, there was most likely only one other language that would be even worse to maintain and that was Cobol (COBOL).

(Now, I never learned Cobol. I caught a whiff of Cobol in college and didn’t like the smell and managed to get my degree and go 20 years in the industry without, once, having to write Cobol. I felt pretty clever, I tell you, for managing this–until I saw friend after friend retire early from all that money they made thanks to the Y2K frenzy. Happiest, smuggest people you ever did see.)

Languages…languages…

Icon, C++, Eiffel, Smalltalk

There was Icon, which was the attempted commercial version of SNOBOL4, but which never had a strong following. But I had a chance to chat with the creator, always fun. And it’s still active. And free.

Speaking of free, when I worked in the Database group at Boeing, they were nuts about Eiffel. Yes, while the rest of the world was heading into C++, they were into Eiffel. I hadn’t heard anything about this language for a while, so I searched around and found a Joel on Software forum entry on Eiffel. Seems like it costs thousands of dollars to get a development environment in this language. Thousands of dollars. For that kind of money, the applications should write themselves, let you go out and have a smoke, drink a latte.

In the Acoustic and Linguistics group, we worked with C++ and Smalltalk. We had one of the first Smalltalk environments in all of Boeing. I remember how we would provide demonstrations for visiting management, each of us with our fingers crossed because the applications would fail as often as not. But hey! No spaghetti code here! This was the Real Thing, babies: we were object-oriented a-l-l-l-l the way.

All the way down, that is.

Our count is now at 12, adding in Smalltalk, C++, Eiffel, Icon, and Fortran.

PowerBuilder, Java, JavaScript

I didn’t get into any new languages until I moved to Oregon. I did work with SQL and QUEL and shell scripting on five different Unix flavors, and though I consider these ‘languages’ others may not, so I won’t count them.

In Oregon, I learned the joys of creating applications with an application environment such as Visual Basic, and especially, PowerBuilder. My first tech book was on PowerBuilder. When I was approached about writing another, the editor gave me a choice between two brand new languages: JavaScript and Java. I asked which she thought would have more of a future and she said JavaScript. I found out later, she meant to say Java, but JavaScript has managed to survive nicely, too.

Java, Java, Java. At one point in time the world ran on Java, and it’s still one of the most common languages for corporate web-based applications. As the language became more popular, more additions were added to the language, and it grew in complexity until our sweet, modern language became this many-headed hydra, otherwise known as J2EE.

No language should become so complex and ever changing that developers in the language have to spend all their time keeping up with the mods. But you know, COBOL lost favor so the suits had to have some language to blame.

As for JavaScript, I ended up writing the book on JavaScript, another on Dynamic HTML, and contributed to others associated with this language. It has also grown in complexity, but it started so simple, there was room for growth. If there was any problem with JavasScript (other than those of security), it was because some companies didn’t believe they needed to play nice with others. Now this same company has promised to be good.

Uh huh.

Perl

It was during this time that I got into web development, which meant Perl. We have a lot of options for web development now, but then it was pretty much Perl and, well, Perl. (Don’t talk to me about applets–misbegotten sons of the devil.)

There were and are a lot of good applications written in Perl. There were and are a lot that are shite, too. Perl is a language easy to use poorly. It is a good language. I’m glad I learned it. I’m glad I used it. I’m glad I no longer have to use it. I paid my Perl dues.

And we’re now at 16, with PowerBuilder, Java, JavaScript, and Perl thrown into the mix.

From Oregon to Vermont, where I worked primarily in PowerBuilder and ASP, writing components in Visual J++, C++, and Basic, so no new languages here. From Vermont to Boston, where PB started to lose favor as Java gained in popularity. It was during this time, too, that I also did some work with Borland’s Delphi–the newest incarnation of Pascal that used to be a cornerstone of the Borland IDE products. That is, until the company dumped them earlier this month.

PHP

Then someone told me about this new web scripting language. I first thought it would be another Perl, and went, “Oh no, I’m into Java. Go away.” But this language was nothing like Perl. If anything, it was like ASP or JSP–it was a language embedded within a web page, and which was processed dynamically when the page was accessed. It was called “PHP”, and I loved it.

The first versions of PHP had significant problems and performance issues, but darn if it wasn’t easy to use! After years of languages that demanded a total life commitment from the developer, here was this cute and furry little language that you only needed to pat on the head now and again. It was so easy to use!

Still, the Java developers and the Perl developers and C++ developers and so on, looked down their nose at this cute little scripting language and ignored it. Ignored it until they looked around one day and noticed something…

PHP was ubiquitous.

PHP was used to create photo galleries and weblogging tool and commerce systems. There were libraries and modules and code samples one could use and they were all easy and free and best of all–you could drop these into your site and use without having to beg your ISP to add them to the system.

Just like with JavaScript, PHP had room to grow when it was originally created. As each new version was released, the language tightened, strengthened, and even popular web sites found that their PHP pages served up just fine.

All in the all, though, the best thing about the language was that developing in PHP didn’t make you cool. There were no developers writing convoluted, obtuse, articles about some little known and barely interesting aspect of the language. Groups of hackers didn’t huddle, late into the night, exchanging PHP horror stories.

No, most of the cool kids stayed with oldtimers like Java, Perl, or C++, or went to new kids like Python–leaving the way open for just anyone to develop with PHP.

And they did.

The Uncool PHP kids

Since the people developing with PHP weren’t cool they did uncool things like demand that the language maintain its simplicity and ease of use. Of course, the fact that anyone could code in PHP meant that the code produced could vary in quality. But there is another odd thing about PHP and the code developed with it–most of it is free. Not only is most of it free, most of it’s open source. So even if the code starts out hinky, doesn’t mean it has to stay hinky.

How do you eat spaghetti? You use a fork.

Python, Java, JavaScript, Ruby, Delphi, PHP

In the last few years, I played around with Python, and I’ve kept my Java dusted, and we all know what happened to JavaScript, the little language that could. But it wasn’t until recently that there’s been a new challenger for my affection. After all, they say Rubies are a girl’s best friend.

And with Ruby, Python, Delphi, and above all, PHP, we have 20. That’s twenty languages. Of course, writing all of this has made it impossible for me to blame the language when my code is crap.

Darn it.

I remember when I was slashdotted for Parable of the Languages, back in 2002. Mark Pilgrim chuckled about the fact that the page was written in PHP, and wondered when it would melt down. At that time, I wondered the same and would have agreed with Tim about PHP being vulnerable.

Now, four years later, PHP bids fair to be the baddest bitch in the ‘hood’.

Don’t Forget…C#

Tcha! And I forgot one language: C#. I actually rather like C# too. Almost wrote a book on it.

The memory is the first to go.

Hee.

Categories
JavaScript

What does work

One of the old DHTML examples that still works is this Dance of the Sugar Plum Divs, using animated objects built on top of cross-browser DHTML objects. Just in case anyone is interested, here are the cross-browser objects, and the Animator classes.

This technology is the same that powers AJAX.