Index 04 (601) Books Dav Cialdini Raobert Wywieranie wpływu na ludzi Teoria i pra (2) Nisargadatta Maharaj Rozmowy z medrcem (brak wstępu) 19 (386) 19 (347) Aronson Elliot, Wilson Timothy D., Akert Robin M. Psychologia społeczna (11) Gleen Cook Czarna Kompania Bram Stoker Dracula rozdzial 06 (242) |
[ Pobierz całość w formacie PDF ] .Also, by avoiding procedural languageprinciples, Java designers can ignore many of the startup and initialization aspectsof programming, again making the source code smaller and faster.Learning Java isnot especially difficult.If you know an OO language such as C++, you will probablyfind Java easier to learn than if you've worked only in procedural languages suchas C or BASIC.Java may be an OO language, but it's not strict about it.SmallTalk, for example,is considered a pure OO language because all aspects of SmallTalk are dealt withas either objects or messages, and all data are object classes.Java doesn't go quiteas far, primarily to avoid an overly large language.Java implements all the simpleC data types (integers, floating points, and characters) outside of the OO method,but everything else is object-based.This is both a benefit, because it leads tosmaller, faster code, and a problem, because it means you can't subclass Java dataobjects.As mentioned earlier, Java is interpreted.When you develop Java applications,you write the Java code as you would with any other language, then pass it througha Java processor to produce the binary object file.The binary object file, calleda class file in Java, is not directly readable, but it can be transmitted fasterthan the source code from which it was derived.When a Java-equipped browser receivesthe class file, it runs the class file through the Java interpreter, which decodesand executes the class file instructions.In one sense, Java is both a compiler andan interpreter, in much the same way as many early languages that produced pseudo-coderequiring a runtime module were.The Java client that decodes the class file performsa conversion from the generic instructions contained in the class file to machine-specificinstructions for the client's hardware and operating system.Programming in the Java language takes a little while to become comfortable.Thecode often seems like a hybrid of C and C++, and experience with both is handy.BecauseJava is a fairly simple language, however, even nonprogrammers can pick it up witha little practice.The most difficult aspects of learning Java for most people arethe need to understand object-oriented design and programming, and the somewhat awkwardsyntax requirements (these are also familiar to C and C++ programmers).For example,here's a simple Java program:// HelloWorldApp.javaclass HelloWorldApp {public static void main (String args[]){system.out.println("Hello World!");}}This program (called HelloWorldApp) defines a single method called mainthat returns nothing (void) and consists of a single Java instruction toprint the message Hello World! The first line in the code is a comment.To compile this source code into a class file, you invoke the Java compiler withthe following command line:javac HelloWorldApp.javaThe compiler then grinds away and produces a class file (HelloWorldApp.class).This class file can be run in a Java-equipped browser or from the command-line clientwith the commandjava HelloWorldAppwhich instructs Java to load and execute the.class file.As you probably expect, Java is a lot more complicated than that in real life,but if you have programmed before, you will see the similarities to other languages(especially C and C++).The Java language is quite rich.You might need a coupleof weeks to wade through it, becoming familiar with its nuances as you go, but formost people, Java is much more easily learned than other programming languages.JavaScript and HTMLYou embed JavaScript commands inside HTML documents (see Chapter 53, "HTMLProgramming Basics," for more details on HTML) by enclosing them in the HTMLtags <SCRIPT> and </SCRIPT>.The general syntax fora JavaScript program inside an HTML document looks like this:<SCRIPT language="JavaScript">JavaScript statements</SCRIPT>The language option inside the <SCRIPT> tag is optional, but itis a good idea to use it to make sure that the browser knows what is incoming.Ifyou want to load the JavaScript from a URL, you need to embed the URL in the <SCRIPT>tag like this:<SCRIPT language="JavaScript" src="http://www.where.com">If the JavaScript source is embedded in the HTML file, you can leave off the SRCcomponent.For example, here's a simple JavaScript applet in some HTML code (whichhas been trimmed down to the essentials):<HTML><HEAD>.<SCRIPT language="JavaScript">alert("Welcome to my Web site!");</SCRIPT></HEAD></HTML>The alert() function in JavaScript displays the message in a window withan exclamation mark icon next to it.This is usually used to catch your attentionwhen you try to do something critical or illegal, or something that might cause problems.JavaScript's functions, as you can see, are much like those in C.You can definea complete function within a JavaScript file, similar to in a C program.If you are calling a file with the JavaScript source in it from your HTML code,the convention is to name the file with the.js filetype at the end (sample.js,for example).This is because several applications, including MIME, already recognizethe.js filetype and can handle them properly.We don't have the space here to go into details about JavaScript programming,but many good books have been published on the subject, including Web Programmingwith Java and Teach Yourself Java in 14 Days (both Sams.net, 1995).SummaryWe've taken a quick look at Java and JavaScript, both of which are available forLinux platforms in both server and client versions.Programming both Java and JavaScriptrequires a bit of past programming experience, but if you've programmed before, youcan use them both to add a lot of features to Web pages and HTML documents.Givethem a try! After all, the software is free [ Pobierz całość w formacie PDF ] |
||||
Wszelkie Prawa Zastrzeżone! Kawa była słaba i bez smaku. Nie miała treści, a jedynie formę. Design by SZABLONY.maniak.pl. | |||||