javascript intro

Kenapa  belajar javascript?
gak ada alasan tertentu kenapa sekarang saya tertarik buat mengutak atik javascript. Dulu, javascript tidak bisa menarik minat saya, mungkin karena kebanyakan javascript hanya dipake untuk mempercantik website yang menurut saya hampir gak ada gunanya, akan tetapi sekarang sepertinya tetap sama (lho ???) javascript kebanyakan hanya dipake untuk web scripting. Yang berubah adalah minat saya untuk mempelajari detail2 dari bahasa pemrograman. Javascript menarik minat saya mungkin dikarenakan banyak hal2 yang unik dan menarik di spesifikasi javascipt. Javascript itu sendiri adalah bahasa yang spesifikasinya berdasarkan ecmascript.

javascript itu sendiri terbagi menjadi dua bagian besar :

  • core javascript
    core javascript ini dibuat berdasarkan specifikasi dari ecmascript.

  • client-side javascript.
    client-side javascript ini yang biasa digunakan dalam web scripting,

  • server-side javascript
    javascript yang berjalan di server.

karena hanya tertarik pada core javascript, menggunakan browser untuk mengoprek javascript sangat tidak menyenangkan, setelah mencari-cari, ternyata mozilla sudah menyediakan javascript engine standalone yang dapat digunakan untuk belajar/membuat applikasi core javascript. Ada 2 module javascript compiler yang pertama rhino yang kedua spidermonkey, kalo rhino menggunakan java sedangkan spidermonkey menggunakan c++.

Dan mulailah perjalanan untuk belajar javascript dengan menggunakan tools2:

  •  Any deccent Text Editor (Tentu saja Emacs :))

  • Rhino (karena java :P)

Hanya saja ada 1 pertanyaan yang masih mengganjal, kira2 applikasi apa saja yang bisa dibuat dari core javascript (selain untuk web scripting)?….. hmm mungkin itu bisa dijawab lain waktu, karena skr ada javascript yang harus dioprek :).

Advertisements

praise the emacs

Praise for emacs, I never use emacs before,
but I stumble on emacs, since I learn so many
“minor” language such as haskell, ocaml, scheme
and each of that language use a different IDE/editor.
at that time, I haven’t found emacs, and if I want to use a language I have to swith the IDE.

I asked myself, is there any IDE that can be “IDE that rule them all”, first I tried eclipse,simply because I am a java programmer and eclipse is my number one choice. it support plugin and most of those minor language is supported by eclipse. however those plugins is in beta version and somethime behave strangely, not to mention that my ‘grumpy old’ laptop is working really hard when I run eclipse. so I looked around,amd tried my self emacs, despite of the strange way to operate, with lot of big capital C and big capital M in the manual.

When I was trying the tutorial I almost gave up, but one thing that struck me really hard is emacs can be operated without mouse, wow I never found that piece of softaware that really elegant (perhaps because it was designed a long time ago when mouse hasn’t invented yet :P). so I was hooked up until now, I am still feeling awkward when using emacs, but i’m perfecting my skill and hoping not need a long time to make my self fluent in make and also make some emacs extension 🙂

praise the EMACS.

java and Animated GIF

Recently, I got a question about how to draw an animated gif using java. Drawing an image is not trivial in Java, you can use graphics.drawImage, but to draw an animated gif?

I look up in javadoc, and curious about ImageObserver, well I never use this object, and always pass a null object when drawing an image. Apperently ImageObserver object has a ImageUpdate method, so I tried when drawing animated gif, I specified and extend the ImageUpdate method.
Whoalla, the fact is when an image need to update (change the frame in animated gif), it will call imageUpdate method, so to refresh the image, the hook is in ImageObsert imageUpdate.

perhaps the code is

public void paint(Graphics g)
  {
    g.drawImage(img,0,0,this);
  }

  public boolean imageUpdate( Image img, int flags, int x, int y,
    int w, int h )
  {

    repaint();
    return true;
  }