JNTU
JNTU B.Tech III SCRIPTING LANGUAGES Previous Question Paper (August - 2022 - R18)
Answer any five questions
All questions carry equal marks
Main
Compare ruby language with Perl with respect to various features and list the advantages of Ruby language.
Answer
Ruby and Perl are both powerful scripting languages, but they differ significantly in design philosophy and syntax. Perl was designed as a "glue" language for text processing and system administration, emphasizing "There is more than one way to do it" (TMTOWTDI). Ruby, conversely, is a pure object-oriented language designed for programmer productivity and code readability, emphasizing the "Principle of Least Astonishment."
Key comparisons:
- Object-Orientation: Ruby is purely object-oriented; every piece of data is an object. Perl supports object-oriented programming but is primarily procedural.
- Syntax: Ruby features a clean, English-like syntax. Perl syntax is often considered cryptic due to its heavy use of sigils ($, @, %) and complex regular expression integration.
- Consistency: Ruby provides a consistent API across its standard library, whereas Perl's library can be inconsistent due to its long history and evolution.
Advantages of Ruby include:
- Pure Object-Orientation: Simplifies code maintenance and promotes modularity.
- Readable Syntax: Reduces the learning curve and makes code easier to debug.
- Metaprogramming: Ruby allows developers to write code that writes code, offering extreme flexibility.
- Rich Ecosystem: The RubyGems package manager and the Rails framework provide extensive support for rapid web application development.
- Block and Iterator Support: Ruby's elegant handling of blocks and iterators makes collection processing highly efficient and expressive.
What is a cookie? Write the code in Ruby to demonstrate handling of cookies.
Answer
A cookie is a small piece of data stored by the web browser on the client's machine. It is used by web servers to maintain state information, such as user sessions, preferences, or tracking data, across multiple HTTP requests. Because HTTP is a stateless protocol, cookies provide a mechanism to "remember" information about the user.
In Ruby, particularly when using the CGI library, cookies can be handled as follows:
require 'cgi'
cgi = CGI.new
# Setting a cookie
cookie = CGI::Cookie.new('name' => 'user_session', 'value' => '12345', 'expires' => Time.now + 3600)
cgi.out('cookie' => cookie) { "Cookie has been set!" }
# Retrieving cookies
cookies = cgi.cookies
if cookies['user_session']
puts "Session ID: " + cookies['user_session'].value.to_s
endWhat are web services and how do we use SOAP to implement web services in Ruby?
Answer
Sign in to view the complete answer paper.
Describe different canvases available in Ruby-Tk.
Answer
Sign in to view the complete answer paper.
How do we embed a ruby language interpreter in C program?
Answer
Sign in to view the complete answer paper.
Explain about Ruby type system.
Answer
Sign in to view the complete answer paper.
Write the syntax and explain the usage of different memory allocation functions available in Ruby.
Answer
Sign in to view the complete answer paper.
Explain about global variables concept in Ruby with an example.
Answer
Sign in to view the complete answer paper.
How do we create a list and tuple in Perl? Demonstrate with a suitable coding example.
Answer
Sign in to view the complete answer paper.
Discuss about defining regular expressions in Perl with examples.
Answer
Sign in to view the complete answer paper.
Enumerate various usages of Scripting languages.
Answer
Sign in to view the complete answer paper.
Discuss about different conditional and iterative statements available in Perl with their syntaxes.
Answer
Sign in to view the complete answer paper.
Explain about pack and unpack commands in Perl with examples.
Answer
Sign in to view the complete answer paper.
Write the steps for interfacing with operating system in Perl.
Answer
Sign in to view the complete answer paper.
Describe the control flow structures available in TCL.
Answer
Sign in to view the complete answer paper.
Explain about event binding in Tk applications.
Answer
Sign in to view the complete answer paper.