My Youtube Channel

Please Subscribe

Flag of Nepal

Built in OpenGL

Word Cloud in Python

With masked image

Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Wednesday, September 27, 2023

Difference between JAVA and JAVASCRIPT

 Java and JavaScript are two distinct programming languages that share a similar name but are used for different purposes and have significant differences. Here's a breakdown of the key differences between Java and JavaScript:


1. **Origin and History**:

   - **Java**: Java was created by James Gosling at Sun Microsystems in the mid-1990s. It


is a statically-typed, compiled programming language that was originally designed for developing applications for embedded systems. It later gained popularity for its "Write Once, Run Anywhere" capabilities.

   - **JavaScript**: JavaScript, often abbreviated as JS, was developed by Brendan Eich at Netscape in the early 1990s. It is a dynamically-typed, interpreted scripting language primarily used for web development. Despite its name, JavaScript has no direct relationship with Java.


2. **Usage**:

   - **Java**: Java is a general-purpose programming language used for various applications, including desktop applications, mobile app development (Android), server-side applications (Java EE), and more. It's known for its platform independence and strong type checking.

   - **JavaScript**: JavaScript is mainly used for web development. It is the primary scripting language for building interactive web pages and web applications, enabling dynamic content, user interactions, and client-side functionality within web browsers.


3. **Typing**:

   - **Java**: Java is statically typed, which means that variable types are declared at compile time, and type checking is done at compile time. This helps catch type-related errors early in the development process.

   - **JavaScript**: JavaScript is dynamically typed, which means that variable types are determined at runtime. Type checking occurs during program execution, which can lead to flexibility but may also introduce runtime errors if not handled carefully.


4. **Execution Environment**:

   - **Java**: Java applications are typically compiled into bytecode and run on the Java Virtual Machine (JVM). This allows Java code to be platform-independent, as long as there's a compatible JVM for the target platform.

   - **JavaScript**: JavaScript is executed directly by web browsers, making it a client-side scripting language. It can also be used on the server side through technologies like Node.js.


5. **Syntax and Semantics**:

   - **Java**: Java has C-like syntax and uses classes and objects for organizing code. It follows a more traditional programming language structure.

   - **JavaScript**: JavaScript has a C-like syntax as well, but it is often described as a prototype-based language. It supports dynamic object creation and manipulation, making it well-suited for building interactive web applications.


6. **Common Libraries and Frameworks**:

   - **Java**: Popular Java frameworks and libraries include Spring, Hibernate, and JavaFX for various application types.

   - **JavaScript**: JavaScript has numerous libraries and frameworks, such as React, Angular, and Vue.js for front-end web development, and Node.js for server-side development.


In summary, while Java and JavaScript share some superficial syntactical similarities, they are fundamentally different languages with distinct purposes, execution environments, and ecosystems. Java is a versatile, statically-typed language used for various applications, while JavaScript is primarily used for building dynamic, interactive web applications.

Tuesday, December 18, 2018

How to make a simple picture gallery using lightbox library in web?




HTML code

<!DOCTYPE html>
<html>
<head>
<title>PicGallery</title>
<link rel="stylesheet" type="text/css" href="css/picgallery.css">
<link rel="stylesheet" type="text/css" href="css/lightbox.min.css">
<script type="text/javascript" src="js/lightbox-plus-jquery.min.js"></script>
</head>
<body>
<h1>Image Gallery</h1>
<div class="gallery">
<a href="gallery/1.jpg" data-lightbox="MyGallery" data-title="Red flower"><img src="gallery/1.jpg"></a>
<a href="gallery/2.jpg" data-lightbox="MyGallery" data-title="Car"><img src="gallery/2.jpg"></a>
<a href="gallery/3.jpg" data-lightbox="MyGallery"><img src="gallery/3.jpg"></a>
<a href="gallery/4.jpg" data-lightbox="MyGallery"><img src="gallery/4.jpg"></a>
<a href="gallery/5.jpg" data-lightbox="MyGallery"><img src="gallery/5.jpg"></a>
<a href="gallery/6.jpg" data-lightbox="MyGallery"><img src="gallery/6.jpg"></a>
<a href="gallery/7.jpg" data-lightbox="MyGallery"><img src="gallery/7.jpg"></a>
<a href="gallery/8.jpg" data-lightbox="MyGallery"><img src="gallery/8.jpg"></a>
</div>
</body>
</html>


CSS code

h1{
color: aqua;
text-align: center;
}

.gallery img{
width: 150px;
height: 150px;
padding: 20px;
transition: 1s;
}

.gallery img:hover{

transform: scale(1.5);
}


click here to download a complete file.