29
Programming languages Trends in software development Ganesh Samarthyam [email protected]

About programming languages

Embed Size (px)

Citation preview

Programming languages

Trends in software development

Ganesh Samarthyam [email protected]

Agenda

n  Why languages matter n  Language popularity n  Domain Specific Languages

(DSLs) ¡  Case study: LaTeX

n  New and emerging languages ¡  Case study: Go language

n  Learning new languages n  That’s it!

Why languages matter?

n  There are numerous languages in the programming world ¡  See list of 2500 languages in

http://people.ku.edu/~nkinners/LangList/Extras/langlist.htm

n  Hundreds of languages released every year! ¡  Well-known recent languages include Go, Scala,

and Clojure languages n  People are passionate about languages

¡  Sometimes even emotional

Languages in programmer’s life n  Languages have special place in

programmer’s life ¡  Unlike “gizmos” or “technologies” ¡  We use languages on day-to-day basis ¡  Languages we use shapes our thoughts

n  Programming is a creative activity ¡  that separates computer science from other

engineering disciplines ¡  Learning programming is not just about

learning the language features n  it is more about creative problem solving using

the existing features

Example: Creativity in Programming

Sierpinski triangle fractal!

n  The word ‘fractal’ was coined by a mathematician named Mandelbrot in 1975.

n  Fractals are created based on some simple patterns and simple rule(s).

n  This program creates Sierpinski triangle fractal by printing @ and . characters to the console!

Programming languages and research

n  Approx 50% of Turing award winners closely associated with programming or languages ¡  Turing award is highest award in CS ¡  Dijkstra & Peter Naur (Algol) ¡  Backus (Fortran) ¡  Iverson (APL) ¡  Ritchie (C) ¡  Dahl & Nygaard (Simula) ¡  Alan Kay (Smalltalk) ¡  …

Power of a language!

n  Which language is more powerful? ¡  C, Pascal, Fortran, Assembly or Basic?

n  A meaningless question! ¡  Fundamentally, languages are equally powerful

n  But languages differ in their ability to perform some specific tasks easier! ¡  By providing different language features or same

language features in different ways

A simple example: String replacement

n  Simple string rewriting based on a set of rules.

n  An interesting application ¡  Converting a binary to unary by string

replacement by applying a set of rules. n  So what’s the big deal?

¡  This algorithm is shown to be “Turing complete”!

Markov’s string replacement algorithm

Let us see the rules first: Rule 1: "#0" => "0##" Rule 2: "1" => "0#" Rule 3: "0" => "" Rule 4: "#" => "1"

Input string: "11" Step 1: "0#1" (apply rule 2) Step 2: "0#0#" (apply rule 2) Step 3: "00###" (apply rule 1) Step 4: "0###" (apply rule 3) Step 5: "###" (apply rule 3) Step 6: "1##" (apply rule 4) Step 7: "11#" (apply rule 4) Step 8: "111" (apply rule 4) Terminate.

"100" => "0#00" => "00##0" => "00#0##" => "000####" => "00####" => "0####" => "####" => "1###" => "11##" => "111#" => "1111"

Language influence and evolution

n  A new language is not created from nowhere ¡  It is influenced by many other languages,

technologies or ideas n  Language evolution tree

¡  Graphical representation of how languages are influenced by others

¡  Almost all here know C; but do you know how many languages it got influenced from?

Language popularity

n  Many languages have started getting more popular ¡  Those were relatively unknown in just recent past ¡  E.g. Ruby, Python, Lua, …

n  How to we know the popularity of a language? ¡  Tiobe “language popularity index” is most widely

referred (http://www.tiobe.com/) ¡  Latest status is in next slide

TIOBE Index (as on Jan 2016)

Language popularity …

n  Popularity depends on so many factors ¡  Like company sponsorship/backing

n  Best example is Swift ¡  It is popular because of Apple

¡  Does it solve new problems or changes in the world around us n  For example, Java became popular when released in 1995

because of web n  Concurrent languages will become popular because of multi-

core processors

¡  …

Language popularity: Observations

n  C is the second most popular language! ¡  And its >3 decades old ¡  Continues to be popular for embedded programming

n  C++ is steadily losing popularity ¡  C#, Java, etc ate from C++ pie

n  Popular company related languages ¡  ActionScript (Adobe), C# (MS), Obj-C & Swift

(Apple) n  OO languages are very popular (55%)

¡  Procedural languages (40%) ¡  Functional, logic and other languages (5%)

Language popularity: Observations

n  Statically typed languages are very popular (57% share) ¡  Losing steadily to dynamic languages (42%)

n  Web is becoming more & more pervasive ¡  PHP popularity reflects that

n  Scripting languages are more popular than ever before ¡  Loser: Perl; Gainers: Python & Ruby

n  Non-GC languages losing popularity ¡  C++, Cobol, Fortran etc; except for C

Domain Specific Languages (DSLs)

n  Surprisingly general purpose languages (like C, Java…) are not best languages for specific uses ¡  Domain Specific Languages (DSLs) are best suited

for specific uses n  DSLs are about a specific domain, and provides

solutions for that domain ¡  E.g.: HTML, SQL, LaTeX, GraphViz, VHDL Verilog… ¡  The main problem is the time taken to learn

n  and become productive

DSL Case study: LaTeX

n  I’ve written full-length books using MS Word ¡  Bitten by the problems in managing a large

document ¡  MS Word not well suited for a specific purpose

like writing a book n  LaTeX is a markup language for document

preparation ¡  Like writing papers, letters, articles, thesis … ¡  Its macros on top of TeX (created by D.Knuth)

LaTeX vs. MS Word n  Can you find which document is created

with LaTeX and with MS Word? MS Word LaTeX

Sample LaTeX program

\documentclass[12pt]{article} \begin{document} \centering{

\textbf{Hello world!} } \end{document}

$ latex hello $ dvips hello $ gv hello.ps $ ps2pdf hello.ps

The best programming language?

n  Most of the programmers know which is the best programming language. ¡  Each programmer has different answer! ¡  “the most favourite” is not “the best”

It is C you know – there is

nothing like that

Python! Its so intuitive to program in it

its PHP - I think you haven't used it – if you use it you'll agree that its the best

New and emerging languages

n  The computing world is changing fast ¡  Old languages (C, Fortran…) are not very suitable

n  Major trends ¡  More pervasive web/internet ¡  Multi-core processors ¡  Larger and more complex software ¡  Need for more reusable/pluggable software ¡  Wider use of embedded systems ¡  Reliability more important (e.g. s/w in pacemaker

device) ¡  ...

What are the new languages?

n  Many new languages getting designed with this new world order in mind ¡  Scala, Go, Swift etc

n  General trend in new languages ¡  Garbage collected, concurrent, more

dynamic, higher-level, … ¡  Less importance for efficiency, OO, …

n  Case study: Go language

Go: Background

n  Go is from Google (Sep 09) ¡  Created lots of excitement in the programming community

n  Many tout it as the next C language ¡  ‘C’ evolved from ‘B’; many languages are named as ‘D’, or

want to be the ‘D’ language ¡  But nothing has made the cut so far; “Go” might (or will it be “Gone” in a few years ;-) )

n  Go won Tiobe’s ‘language of the year award 2009’

n  Robert Griesemer, Ken Thompson (of Unix fame), and Rob Pike are the creators of the language. ¡  All three are well-known in programming community

Go: Important characteristics

n  Simplicity: Go has a clean and concise syntax ¡  Characteristic of Google products ¡  For example, light-weight type system

n  Use it to believe it

n  Separation of interface and the implementation ¡  I know it’s often misused statement, but Go has it! ¡  Arguably a novel feature of Go

n  Goroutines ¡  Is based on CSP: much safer than lock-based, like Java

n  And more: ¡  E.g. Reflection (yes! but this is systems prog. lang!)

Go Interfaces: A novel feature

n  Interfaces specified with ‘interface’ keyword ¡  Not same as in C#/Java

n  The structs doesn’t have to say it implements an interface ¡  Any struct that

implements the methods as specified by any interface satisfies that interface

¡  Strict static type checking & “duck typing”!

Learning new languages

n  Its worth learning new languages ¡  New ways of thinking or solving problems ¡  ‘As I write a program, I should use a

language that minimizes the distance between the problem solving strategies that I have in my head and the program text I eventually write on paper’ -  Jon Bentley (Programming Pearls)

n  Go beyond learning the mainstream languages ¡  Take the road less travelled!

Wrapping up

n  Programming languages is an exciting topic ¡  From research as well as practical usage

perspectives

n  Consider learning a new language ¡  New like Swift, Scala, Go, Clojure … ¡  Or different ones like Lisp, Prolog,

Python, LaTeX…