You are on page 1of 9

BS(cs) 5th Visual Programming

Introduction to Visual Programming Language


Any language that uses the graphics or blocks that are already defined with the code and
you just need to use those blocks without worrying about the lines of code is known as a
visual programming language. In today’s era majority of the programming languages are
text-based i.e. we have to write the lines of code to perform the specific task like in C or
C++. programming if you want to print a table of 2 then you have to write the complete
text using syntax and functions of that language but in visual programming language this
task is replaced by graphics or blocks like components then can be joined logically to
perform the task.
Visual Programming language lets the user think in a logical manner unlike in regular
programming language the user has to think about that how he/she can explain the
program to the computer, to do this let’s take one small analogy like if you have to code
multiplication table of 2 then in regular programming language what you will do is you
will take the loop and with the help of it you can print the multiplication table but in the
visual basic language you just have to add the block which has the inbuilt code in it of
loop and you just specify the value and you just have to think logically and your work is
done without worrying about the semicolon, syntax, functions, etc.
Examples of Visual Programming Language:
There are n numbers of visual programming languages and the few which are in the top
list is given below
 Scratch: With the help of this language users can create, stories, games, and
animations without writing any lines of code in this you just have to create the logic
and assemble the blocks.
 Blockly: Used to create block-based programming language and editors, and also to
generate code from blocks to javascript lua dart python and PHP, etc.
 mBlock language: It is used in programming robots.
 Bubble language: It is used to create web applications.
 Minibloq language: It is used as a graphical programming environment.

Examples of Visual Programming Language Interface:

You just have to choose/create and join the blocks and your applications are ready
without writing any lines of code and also in all the visual programming languages, one
thing is common that it will have the graphic blocks like in the given image below.

Applications of Visual Programming language:

VPL can be used in multiple domains like multimedia, educational purpose, video games,
automation. Let’s see them in brief:
BS(cs) 5th Visual Programming

 Multimedia:- VPL helps users create multimedia without worrying about the real
code or other complex features. It narrows down to specific functions and with the
help of those functions, multimedia is created.
 Educational Purpose:-Scratch VPL, etc are used to help students in their projects
and make them familiar with the coding.
 VideoGames:-VPL helps to create the videogames without writing lines of codes Ex-
Scratch VPL is used to make videogames.

Advantages of visual programming language:

 Easy to convert ideas into reality for example you don’t know how to code so you can
start with VPL(Visual Programming Language). and then switch to actual coding.
 Visuals are easy to grasp i.e. to develop something in visual programming language
requires less efforts.
 It includes a variety of built in objects that are required while creating something
using VPL.
 It is a beginner-friendly also anyone will be able to derive the logic without worrying
about writing lines of code.
 Adding a user-specific code is also available and simple as it allows to create of blocks
as per the convenience of the user.

Disadvantages of visual programming language:

 These languages require more memory as they use graphics, as a result, their
execution is also slow and a large amount of memory is occupied by them.
 They can only work in an operating system like windows, mac, or any other operating
system which supports graphics.
 As the inbuilt functions are not sufficient so you have to add your custom code as a
result it is cumbersome.
 Only limited functions are present in these languages.
 Adding our custom code as a block requires coding knowledge or else you have to
work with limited functions which are provided with the language.
 As a computer engineer, it is not a good idea to use VPL as most of the tech giants like
FAANG or other tech companies work on textual languages like JAVA, HTML, etc,
rather than VPL.
 For the long run VPL might not be that much useful as in a regular language you can
explore more in it but in VPL at one point you will get bored by using the same it.
BS(cs) 5th Visual Programming

Difference between regular programming languages and


visual programming languages:

Regular Languages Visual Programming Language

It is a programming language that only It is a programming language that uses


uses text. graphics or blocks in place of text.

It is not beginner-friendly language It is a beginner-friendly language

Customization and flexible applications There are not that much customizable as the
can be created using regular languages blocks or graphics that contain the codes are
limited and after that, we need to add our
custom code as a block.

These are quite fast and efficient This is not fast and efficient as every block has
some code with it so it takes time and also it
has graphics with it.

The interface is not good i.e. only text The interface is great as the user has to just
and syntax of language we have to get join the blocks and frame the logic without
familiar with it. writing the code

requires time to learn as the user has to


get familiar with the language syntax any school student will be able to grasp the
then code in it VPL and create the applications

Requires lot of efforts as a beginner to Doesn’t require a lot of effort and also the
main targeted user of VPL is school level
BS(cs) 5th Visual Programming

Regular Languages Visual Programming Language

start with the language students so that they can love the coding

These are quite fast as compared to VPL These are slow as compared to regular
as they don’t have graphics. languages as it has graphics.

These require less memory as compared This requires more memory as it has graphics
to VPL so to store them more memory is used.

Examples: Javascript, C, C++, Java,


Python Etc. Examples: Mblock, Blockly, Scratch Etc.

Although both Regular and Visual Programming Language is in the trend in their
respective categories the only difference that lies between them is that regular languages
are written first and with the help of visual programming languages the parts of regular
language are taken in according to its functions and the blocks and with the help of block
programming is made simpler.
BS(cs) 5th Visual Programming

Introduction to Events
Events are basically a user action like key press, clicks, mouse movements, etc., or some
occurrence like system generated notifications. Applications need to respond to events
when they occur.
Clicking on a button, or entering some text in a text box, or clicking on a menu item, all are
examples of events. An event is an action that calls a function or may cause another event.
Event handlers are functions that tell how to respond to an event.
VB.Net is an event-driven language. There are mainly two types of events −
 Mouse events
 Keyboard events

Handling Mouse Events


Mouse events occur with mouse movements in forms and controls. Following are the
various mouse events related with a Control class −
 MouseDown − it occurs when a mouse button is pressed
 MouseEnter − it occurs when the mouse pointer enters the control
 MouseHover − it occurs when the mouse pointer hovers over the control
 MouseLeave − it occurs when the mouse pointer leaves the control
 MouseMove − it occurs when the mouse pointer moves over the control
 MouseUp − it occurs when the mouse pointer is over the control and the mouse
button is released
 MouseWheel − it occurs when the mouse wheel moves and the control has focus
The event handlers of the mouse events get an argument of type MouseEventArgs. The
MouseEventArgs object is used for handling mouse events. It has the following properties

 Buttons − indicates the mouse button pressed
 Clicks − indicates the number of clicks
 Delta − indicates the number of detents the mouse wheel rotated
 X − indicates the x-coordinate of mouse click
 Y − indicates the y-coordinate of mouse click

Handling Keyboard Events


Following are the various keyboard events related with a Control class −
 KeyDown − occurs when a key is pressed down and the control has focus
 KeyPress − occurs when a key is pressed and the control has focus
BS(cs) 5th Visual Programming

 KeyUp − occurs when a key is released while the control has focus
The event handlers of the KeyDown and KeyUp events get an argument of
type KeyEventArgs. This object has the following properties −
 Alt − it indicates whether the ALT key is pressed
 Control − it indicates whether the CTRL key is pressed
 Handled − it indicates whether the event is handled
 KeyCode − stores the keyboard code for the event
 KeyData − stores the keyboard data for the event
 KeyValue − stores the keyboard value for the event
 Modifiers − it indicates which modifier keys (Ctrl, Shift, and/or Alt) are pressed
 Shift − it indicates if the Shift key is pressed
The event handlers of the KeyDown and KeyUp events get an argument of
type KeyEventArgs. This object has the following properties −
 Handled − indicates if the KeyPress event is handled
 KeyChar − stores the character corresponding to the key pressed

Event Driven Programming


The development of the ideas of structured and event-driven programming has
significantly increased the productivity of programmers and made it possible to create
applications of hundreds of thousands of lines in a reasonable time frame.

Definition:
Event-driven programming is a programming paradigm in which program execution is
determined by new user events (mouse clicks, keypresses), sensor outputs, or message
passing from other programs. Programmers use Event-driven programming in graphical
user interfaces and other applications that focus on performing user actions in response to
user input (user clicks).

We can also define event-driven programming as a way of building a computer program,


in which, in the essential function of the program, the main event loop of the application is
explicitly highlighted in the code, the body of which consists of two parts:

1. Fetching the event and


2. Event handling
BS(cs) 5th Visual Programming

Event Handlers
An event handler is a function that handles or responds to a specific event. Event-driven
programming uses this feature in software development. So let's take a closer look at the
event handler.

A Trivial Event Handler

A trivial event handler has code that checks for events. The main loop is common to
applications. We can consider calling event listener OnKeyEnter () as an example. This code
contains an argument with a character string corresponding to what the user entered
before pressing the ENTER key.

Algorithm for Creating Event Handlers

The algorithm for creating event handlers includes three steps:

 Writing a series of subroutines or methods. This step is based on the creation of


special codes that will handle events and respond to them. Most often, companies
provide ready-made event templates, which reduces the work time for the
programmer.
 Binding event handlers to the events themselves. If any event occurs,
programmers should trigger the corresponding function. Sometimes graphic editors
combine the first and second steps. Double-clicking a button allows the editor to
create an event handler associated with the user clicking the button. Then it opens a
text box so you can edit the event handler.
 Writing the main loop. The essence of this function is to check for the presence of
an event and call the appropriate event handler. Many companies provide ready-
made main loops or tutorials on how to write the main loop. Therefore, the
programmer can follow the rules or copy the template.

Event-Driven Programming Applications


Event-driven programming is generally used in three cases:

 When programming games in which a set of objects carries out control flow.
 When creating server applications, it is undesirable to spawn service processes if, for
one reason or another.
 When building user interfaces, including graphical ones.
BS(cs) 5th Visual Programming

Programming languages
Different programming languages support Event-driven programming to varying degrees.
The following languages have complete event support:

 JavaScript user actions.


 Perl events and DAEMON daemons and their PRIO priorities.
 Delphi programming language.
 ActionScript 3.0.
 C # events.

The rest of the languages, for the most part, support events as exception handling.

Exception handling is the process of responding to unwanted or unexpected events


when a computer program runs.

Key Features And Characteristics Of Event-driven Programming


Below we will look at the features of event-driven programming that make it stand out
from other programming methods.

Service-Oriented

Service-focused is a key feature in event-driven programming used to create programs


created for services, and it does not slow down the computer. The service-oriented only
take in little of the computer control ability, and usually, services run in the backdrop of
OS.

Time-Driven

In motivated event programming, time influenced is a paradigm. From the code that runs
on a period trigger, time motivated can be considered a specific code that works in a
particular time, which could be once one hour, once a week, or once a month.

Trigger Functions

Trigger functions in event-driven coding are functions that decide on what code to
perform whenever there is a specific event occurs. Programmers use these functions to
BS(cs) 5th Visual Programming

select which event handler to use for the function when you can find specific event
occurred.

Events

Events include mouse, computer keyboard, and user interface, which events have to be
triggered in this program. This means the user has to interact with an object in this
program, for example, click a button by a mouse, use the computer keyboard to choose a
button, etc.

The Simplicity of Programming and Ease of Development

Event-driven programming is simple and much more straightforward to program than


another kind of programming as it's very aesthetic. For example, you can place a button by
selecting it and place it onto a form and write a code for this. Event-driven development is
also easy for the user to place a pre-written code script into an existing application. It
allows the user to pause the code while running. Which makes expanding using event-
driven programming is easy.

Event-Driven Programming vs. Object-Oriented Programming


Events can be user-generated events that arise due to user actions, system events in the
operating system, and software events generated by the program. Event-driven
programming is a development of the ideas of top-down design when the reactions of the
program to various events are gradually determined and detailed.

Object-oriented programming brings together the best ideas embodied in structured


programming and combines them with powerful new concepts to optimally organize
programs. Object-oriented programming allows you to decompose a problem into its
parts. Each component becomes an independent object containing its codes and data that
relate to this object. In this case, the whole procedure is simplified, and the programmer
can operate with much larger programs.

You might also like