0% found this document useful (0 votes)
10 views

2 History and Overview of D programming language

Uploaded by

Grace Anyanwu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

2 History and Overview of D programming language

Uploaded by

Grace Anyanwu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

COSC 306 PRESENTATION

Group 16

COMPUTER SCIENCE GROUP A

DLANG PROGRAMMING LANGUAGE


GROUP MEMBERS:
ANYANWU CHIAMAKA GRACE 21/1972
BISHOP KING OJONUGWA 21/0590
AYENI OLUWATOSIN 21/1556
AMOSUN PHILIP ADEAYO 21/2531
CHAPTER 1
1.0 History and Overview of D Programming Language
D, also known as dlang is a multi-paradigm system programming language created by Walter
Bright at Digital Mars in 2001. Andrei Alexandrescu joined the design and development
effort in 2007. D programming combines a wide range of powerful programming concepts
from the lowest to the highest levels. It originated as a reengineering of C++, D is now a
language which has drawn inspiration from high level programming languages which include
Java, Python, Ruby, C# and Eiffel. It is a statically typed language and supports automatic
and manual memory management. It emphasises safety, program correctness and
pragmatism. It is a high-level programming language, and it uses a compiler for translation.

The official D documentations describe it this way:


D is a general-purpose systems programming language with a C-like syntax that compiles to
native code. It is statically typed and supports both automatic (garbage collected) and manual
memory management. D programs are structured as modules that can be compiled separately
and linked with external libraries or executables.

Early Development (2001-2007): D started as a reinterpretation of C++, aiming to offer more


modern features while simplifying some of C++’s complexities. Walter Bright led the
development, with the language gradually gaining features such as garbage collection,
modules, and template metaprogramming.
D1 (2007): The first major version, D1, was released, focusing on the core language and
basic standard library. However, it faced criticism for its reliance on garbage collection and
lack of certain features found in other languages.
D2 (2010): In response to feedback, the D2 version was released with significant
improvements, including better support for concurrency, enhanced template capabilities, and
improved safety features. This version addressed many of the criticisms of D1 and positioned
D as a serious contender in systems and application programming.
Standard Library and Ecosystem Growth: Over the years, the standard library (Phobos) and
the ecosystem around D have grown, with contributions from the community enhancing its
capabilities and usability.
Current Status: Today, D continues to evolve with a strong community and active
development. It is used in various domains, from game development to web applications, and
benefits from a range of modern programming features and a robust standard library.
1.1 Reasons behind the development of Dlang
The D programming language is designed as a higher-level alternative to C++, initially
developed by Walter Bright in 2001. His purpose was to improve C++ by refining syntax, and
he brought some features from other languages like Java and Python. (Ataman & Ataman,
2024)
Overview
 Design Goals: D was designed to be easy to learn and use, offering a balance between
efficiency, control, and productivity. It incorporates features from C++ and other
languages while aiming to avoid their complexities and pitfalls.
 Syntax: D’s syntax is like C and C++, which makes it familiar to programmers
experienced with these languages. However, it includes several enhancements to
improve safety and reduce boilerplate code.
 Performance: As a statically typed, compiled language, D provides high performance
comparable to C and C++. It includes a garbage collector but also allows manual
memory management when needed.
 Safety and Modern Features: D supports many modern programming paradigms,
including object-oriented, functional, and concurrent programming. It also includes
features like contract programming, unit testing, and ranges.
 Tooling and Ecosystem: The D language is supported by a range of tools and libraries.
The DMD (Digital Mars D) compiler is the reference compiler, and there are other
compilers like GDC (GNU D Compiler) and LDC (LLVM-based D Compiler).
1.2 Benefits of D Programming Language
 Multi-paradigm language
 D comes with multiple paradigms:
 Concurrent programming: has language constructs for concurrency, these may involve
multi-threading, etc.
 Functional programming: uses the evaluation of mathematical functions andstate and
mutable data.
 Meta programming: writing programs that write or manipulate other programs (or
themselves) as their data.
 Generic programming: uses algorithms written in terms of to-be-specified-later types
that are then instantiated as needed-for- specific-types provided as parameters.
 Imperative programming: explicit statements that change a program state.
 Object-oriented programming: uses data structures, that consist of data fields and
methods, together with their interactions (objects) to design programs.
1.3 Applications and uses
D is majorly used in the following areas:
Industry: D has features that help keep a codebase clean and boilerplate-free which increases
productivity. It is used in the following:
Games: D has become popular among game developers. Binary compatibility with existing
libraries has enabled this as it is important to large scale projects.
Web Applications:
D's ability to combine low and high-level code in one language, asynchronous features like
Fibers, and compile-time function execution, makes it well suited for high-performance
asynchronous I/O, concurrency and web applications.
D is also used in Systems Programming.
CHAPTER 2
COMPARATIVE ANALYSIS

2.0 D POGRAMMING LANGUAGE AND C PROGRAMMING LANGUAGE

 C standard library ‘stdio.h’ provides basic functionalities like I/O operations, memory
management, and string manipulation while D standard library offers wide
functionalities including I/O operations (‘std.studio’), concurrency (‘core.thread’) and
more.
 Additional libraries for C standard library for specific tasks need to be included
explicitly but D’s standard library is more extensive and modern providing higher-
level abstractions and utilities.
 C programming language print statement ‘printf()’ function is used to output to the
console while in D programming language, ‘writefln()’ function is used for formatted
output.
Both C and D programming languages use third-party libraries for database connectivity
In C, third party libraries such as MySQL Connector/C, OBDC and PostgreSQL libpq are
used. For example using MySQL Connector/C, you can connect to a MySQL database by
establishing a connection with mysql_real_connect().
In D, Database connectivity is made easier with Vibe.d, which makes it easier to access
databases in your backend services. MongoDB and Redis support come directly with vibe.d.
Access to MongoDB is modelled around the class MongoClient. Implementation doesn’t
have external dependencies and is implemented using vibe.d’s asynchronous sockets.
D also supports MySQL and Postgresql
Compilers for D include:
 DMD (Digital Mars D)
 GDC (GNU D Compiler)
 LDC (LLVM D compiler)
Compilers for C include:
Turbo C
Clang
GNU CCompiler

//A single line comment in Dlang //This is a single line comment in c


import std.stdio; //include library

// main method #include <stdio.h> //include library


void main () {
write ("Enter your name: "); //main method
auto name = readln().chomp;
int main (){
//print statement char name [20];
writeln("Hello, ", name, "!");
}
printf("What is your name?");// print
statement
scanf("%s",&name);

2. D PROGRAMMING LANGUAGE AND JAVA

Comparison of D programming language to Java programming language:


INPUT STATEMENT:
 In Java, reading input from the user typically involves using classes from the
‘java.util.Scanner’ package or other input stream readers.
Example:
import java.util.Scanner;

public class InputExample {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.print("Enter your name: ");


String name = scanner.nextLine();

System.out.println("Hello, " + name + "!");

scanner.close();
}
}

while In D, input handling can be achieved using the ‘std.stdio’ module, which
provides functions like ‘readln’ for reading input from the console.
Example:
import std.stdio;

void main() {
write("Enter your name: ");
auto name = readln().chomp;

writeln("Hello, ", name, "!");


}
2.2 Main Method:
 In Java, the ‘main’ method must be ‘public’, ‘static’, return ‘void’, and accept an array
of ‘String’ arguments (‘args’), which can be used to pass command-line arguments:
public static void main(String[] args) {
// Program logic
}
and in D, the ‘main’ function in D does not require specific modifiers like ‘public’ or
‘static’. It simply needs to return ‘void’ and accept an array of ‘string’ arguments
(‘args’):
void main(string[] args) {
// Program logic
}

2.3 Include Libraries


For Java, including libraries allows you add functionalities provided by external libraries or
packages. The import statement is used to bring in specific classes or packages from Java
Standard Library or other libraries. Example
import java.util.Scanner;
import java.util.ArrayList;

Print Statements
System.out.println(“This is a print statement in Java”);
COMMENTS
Comments in java can be single line or multi line

Database Connectivity
Java has its in-built database connectivity which is Java Database Connectivity

//A single line comment in Dlang import java.util.Scanner;


import std.stdio; //include library
public class InputExample {
// main method public static void
void main() { main(String[] args) {
write("Enter your name: "); Scanner scanner = new
auto name = readln().chomp; Scanner(System.in);

//print statement System.out.print("Enter


writeln("Hello, ", name, "!"); your name: ");
} String name =
scanner.nextLine();

System.out.println("Hello,
" + name + "!");

scanner.close();
}
}
2.4 Dlang and C++
Input Statement:
 In C++, reading input from the user typically involves using the cin object from the
<iostream> library and used with the extraction operator (>>)
Example:
#include <iostream>
#include <string>
Using namespace std;
Int main(){
string name
cin>>name;

return 0;
}
while In D, input handling can be achieved using the ‘std.stdio’ module, which
provides functions like ‘readln’ for reading input from the console.
Example:
import std.stdio;

void main() {
write("Enter your name: ");
auto name = readln().chomp;

writeln("Hello, ", name, "!");


}
Main Method:
In C++, the main function is the entry point of any program, Execution starts from the main
function. It is important to note that:
 The main function must be declared in the global namespace and cannot be a member
of the class.Int main(){}
 The return type must be int.

Include Libraries in C++


In C++, there are standard libraries and external libraries. External libraries use the #include
directive while external libraries need to be downloaded and the header file included.
Example
Standard library - #include <iostream>
External library- #include “library_name.h”
Print Statements
In C++, you use the cout object from the iostream library to print output to the console.
Here’s a simple example:
#include <iostream>
Using namespace std;

int main() {
cout << "Hello, World!" << std::endl;
return 0;
}
Comments
Comments in C++ are used to explain code. There are single line comments and multi-line
comments which are like D.

Database Connectivity
Connecting a C++ program to a database involves using libraries that provide the necessary
functions to interact with the database. The most common libraries are MySQL and SQLite.
D C++

//A single line comment in Dlang #include<iostream>


import std.stdio; //include library
#include <string>
// main method using namespace std;
void main() {
write("Enter your name: "); int main(){
D Language and Visual Basic

Input Statement:
Input statements can be used to get data from the user. There are two ways to handle input in
Visual Basic, the InputBox function and Input function for file input

Dim userInput As String


userInput = InputBox("Please enter your name:", "Input Required")
MsgBox("Hello, " & userInput & "!")
Input Function for file input

Dim MyChar As String


Open "TESTFILE" For Input As #1 ' Open file for input.
Do While Not EOF(1) ' Loop until end of file.
MyChar = Input(1, #1) ' Read one character at a time.
Debug.Print MyChar ' Print to the Immediate window.
Loop
Close #1 ' Close file. Dim MyChar As String
Open "TESTFILE" For Input As #1 ' Open file for input.
Do While Not EOF(1) ' Loop until end of file.
MyChar = Input(1, #1) ' Read one character at a time.
Debug.Print MyChar ' Print to the Immediate window.
Loop
Close #1 ' Close file.

Main Method:
In Visual Basic, the Main method is the entry point of a program. It is the starting point of an
application and can be used open databases and determine the form to load first. The main
method can be declared using the Sub Procedure or the Function Procedure.
Example
Module mainModule
Sub Main()
MsgBox(“Main Applicationn”)
End Sub
End Module

Include Libraries in Visual Basic


In C++, there are standard libraries and external libraries. External libraries use the #include
directive while external libraries need to be downloaded and the header file included.
Example
Standard library - #include <iostream>
External library- #include “library_name.h”
Print Statement
In Visual Basic, methods are used to print output. Using
MsgBox(),Console.WriteLine(),Debug.Print(), or print #
Example:
MsgBox(“Hello,World”);
Comments
Comments in Visual Basic are different compared to other languages we have studied, for
single line comments, it is written this way:
' This is a single-line comment
Dim myVariable As Integer = 42
Multi line comments are written this way:
' This is a multi-line comment
' that explains something in more detail.
Dim anotherVariable As String = "Hello, world!"
Database Connectivity
In Visual Basic, a connection needs to be established to the database before accessing its data.
SQL Server Management Studio is used to create a new database.
//A single line comment in Dlang
import std.stdio; //include library

// main method
Imports System
void main() {
write("Enter your name: ");
auto name
Module = readln().chomp;
MainModule

//print Sub Main()


statement
writeln("Hello, ", name, "!");
' This is a single-line comment
}
Console.WriteLine("Hello, World!")
' Print statement

' Prompt the user for input


Console.Write("Enter your name: ")
Dim Dlang
userName As StringC= C++ Java Visual
Console.ReadLine() Basic
Input write("Enter scanf("%s #include <iostream> Import * Dim
Statement your name: "); ",&name); #include <string> Scanner userInput
auto name = Using namespace sc = new As String
readln().chom std; Scanner( userInput =
Console.WriteLine($"Welcome,
p; Int main(){ System.i InputBox("
{userName}!") string name n); Please enter
cin>>name; int name your
= name:",
' This is another comment return 0; sc.next() "Input
} Required")
MsgBox("H
ello, " &
userInput &
"!")

Main Void main() Int main() Int main() Public Sub main()
Method static
void
main(Stri
ng[]
args)
Include import #include #include import import
Library
Print writeln("Hello, ", cout>>”Hello ” +
Statement name, "!"); printf("Wh name>>endl; System.o Console.Wr
} at is your ut.println iteLine($"W
name?"); ("Hello, elcome,
" + name {userName
+ "!"); }!")

Database Dlang uses third-party C Connecting a C++ Java has In Visual


Connectivity libraries for database programm program to a its in- Basic, a
connectivity ing database involves built connection
language using libraries that database needs to be
also uses provide the connecti established
third-party necessary functions vity to the
libraries to interact with the database
for database before
database accessing
connectivi its data
ty

Comment //A single line //This is a //A single line //A


comment in Dlang single line comment in C++ single '
comment line This is a
in c comment single-line
in Java comment in
Visual
Basic
References
Introduction - D Programming Language. (n.d.). https://dlang.org/spec/intro.html

Ataman, S. C., & Ataman, S. C. (2024, May 7). D Programming Language: a hidden gem |

Coding and Beyond. Coding and Beyond | a Software Developer’s Blog.

https://www.codingandbeyond.com/2024/03/09/d-programming-language-a-hidden-

gem/#:~:text=The%20D%20programming%20language%20%28or%20sometimes

%20referred%20as,features%20from%20other%20languages%20like%20Java

%20and%20Python.

Educative. (n.d.). What is the D programming language?

https://www.educative.io/answers/what-is-the-d-programming-language

The GNU C Reference Manual. (n.d.). https://www.gnu.org/software/gnu-c-manual/gnu-c-

manual.html

Itsourcecode. (2023, November 21). How to connect Access Database in VB.Net. Itsourcecode.com.

https://itsourcecode.com/tutorials/visual-basic-tutorial/connect-access-database-in-vb-net/

#google_vignette
Java Packages and How to import them? (n.d.).

https://www.programiz.com/java-programming/packages-import

C++ Standard Library - CpPreference.com. (n.d.).

https://en.cppreference.com/w/cpp/standard_library

KathleenDollard. (2021, September 15). Language reference - Visual basic. Microsoft Learn.
https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/

You might also like