Why Clojure? Adrian Miron. Using Java since Found both on a CD from Professionally (getting payed :-) since 2001 Back then I knew nothing.

Slides:



Advertisements
Similar presentations
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Advertisements

Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 9 Strings.
Chapter 1 Object-Oriented Concepts. A class consists of variables called fields together with functions called methods that act on those fields.
Contest format 5 hours, around 8-12 problems One computer running (likely)Linux, plus printer 3 people on one machine No cell phones, calculators, USB.
Lecture 10: Part 1: OO Issues CS 540 George Mason University.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Object Orientation Chapter SixteenModern Programming Languages, 2nd ed.1 Spring 2012.
Object Orientation Chapter SixteenModern Programming Languages, 2nd ed.1.
23-Apr-15 Abstract Data Types. 2 Data types I We type data--classify it into various categories-- such as int, boolean, String, Applet A data type represents.
Chapter 7:: Data Types Programming Language Pragmatics
Simple Introduction to Clojure with Analysis By: Shannon Birchell.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Introduction to a Programming Environment
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Inheritance and Polymorphism CS351 – Programming Paradigms.
C++ fundamentals.
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
Language Evaluation Criteria
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Implement High-level Program Language on JVM CSCE 531 ZHONGHAO LIU ZHONGHAO LIU XIAO LIN.
September 19, 2012Introduction to Artificial Intelligence Lecture 5: Functional Programming with Haskell 1 Functional Programming Symbolic AI is based.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Clojure 4 Sequences 20-Oct-15. Clojure errors (NO_SOURCE_FILE:12) Useless--just means you’re running from the REPL shell java.lang.Exception: EOF while.
Clojure 2 Feb 7,
Feb 7, 2015 Thinking in Clojure. Jumping in We’ll quickly go through Clojure’s data types, some basic functions, and basic syntax Then we’ll get to the.
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
More on Polymorphism. Ever have one of those days?
1/26 On-demand Learning Series Software Engineering of Web Application - Object-Oriented Development & UML Hunan University, Software School.
Language Translation A programming language processor is any system that manipulates programs expressed in a PL A source program in some source language.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
1 6th Workshop "SEERE", Ravda, September 2006 OOJava course materials – what happened during last year? M. Ivanovic, K. Bothe.
1.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Chapter 20 Concepts for Object-Oriented Databases Copyright © 2004 Pearson Education, Inc.
Java Inheritance in Java. Inheritance Inheritance is a mechanism in which one object acquires all the properties and behaviors of parent object. The idea.
Skill Area 311 Part B. Lecture Overview Assembly Code Assembler Format of Assembly Code Advantages Assembly Code Disadvantages Assembly Code High-Level.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
1 n Object Oriented Programming. 2 Introduction n procedure-oriented programming consists of writing a list of instructions and organizing these instructions.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Fall 2016 Images from Sebesta: Copyright © 2012 Addison-Wesley. All rights reserved. The mind is everything. What you think you become. Buddha.
Clojure Macros. Homoiconicity All versions of Lisp, including Clojure, are homoiconic This means that there is no difference between the form of the data.
Fall 2016 Images from Sebesta: Copyright © 2012 Addison-Wesley. All rights reserved.
Behavior trees & The C# programming language for Java programmers
Basic Concepts: computer, program, programming …
Concepts of Object Oriented Programming
Java Primer 1: Types, Classes and Operators
Clojure: Why is it interesting?
Object-Oriented Programming & Design Lecture 14 Martin van Bommel
Object Oriented Programming in Java
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
Clojure to Haskell (It’s mostly syntax).
Clojure 4 Sequences 27-Nov-18.
Clojure 4 Sequences 5-Dec-18.
Object Oriented Programming
Abstraction in Object-Oriented Programming
Go.
Python Tutorial for C Programmer Boontee Kruatrachue Kritawan Siriboon
Introduction to Data Structure
(Computer fundamental Lab)
Recursion, Higher-order-functions
Getting Ready for Java version Apr-19.
Clojure 3 1-Jun-19.
Abstraction and Objects
Presentation transcript:

Why Clojure? Adrian Miron

Using Java since Found both on a CD from Professionally (getting payed :-) since 2001 Back then I knew nothing

Clojure is a Lisp dialect Lisp is old… ’58 Runs on the JVM Production ready, general purpose, functional Opinionated Read: build to please Rich Hickey :-)

(defn words [text] (re-seq #"[a-z]+" (.toLowerCase text))) (defn train [features] (reduce (fn [model f] (assoc model f (inc (get model f 1)))) {} features)) (def *nwords* (train (words (slurp "big.txt")))) (defn edits1 [word] (let [alphabet "abcdefghijklmnopqrstuvwxyz", n (count word)] (distinct (concat (for [i (range n)] (str (subs word 0 i) (subs word (inc i)))) (for [i (range (dec n))] (str (subs word 0 i) (nth word (inc i)) (nth word i) (subs word (+ 2 i)))) (for [i (range n) c alphabet] (str (subs word 0 i) c (subs word (inc i)))) (for [i (range (inc n)) c alphabet] (str (subs word 0 i) c (subs word i))))))) (defn known [words nwords] (let [result (set (for [w words :when (nwords w)] w))] (if (empty? result) nil result))) (defn known-edits2 [word nwords] (let [result (set (for [e1 (edits1 word) e2 (edits1 e1) :when (nwords e2)] e2))] (if (empty? result) nil result))) (defn correct [word nwords] (let [candidates (or (known [word] nwords) (known (edits1 word) nwords) (known-edits2 word nwords) [word])] (apply max-key #(get nwords % 1) candidates)))

~ I was looking for a greener field Kinda like a programmer midlife crisis Because all my code was full of for’s and Map’s and List’s and I was shoving data in and out of them using tons of syntax for almost nothing Everything seemed leaky I was looking at Scala, F# and Clojure Clojure won

Most influential Out of the Tar Pit Are we there yet – a talk by Rich Hickey On Understanding Data Abstraction, Revisited Lots and lots of articles about the downsides of OOP The cornerstone Simple made Easy – a talk by Rich Hickey at Strangeloop

Clojure is designed from the ground up to manipulate data Which is what most programs do A basic set of data types and data structures Integer, Double, BigDecimal, Ratio, String, Character, Symbol, Keyword, Boolean, Nil list (), vector [], map {}, set #{} Lots and lots of functions that can manipulate them (->> persons (map :height) (filter #(> % 10)) (reduce +))

All data structures are immutable They are persistent data structures There is no copy-on-write when you create a new structure from an old one Represented as shallow trees Marketed complexity for operations is O(1) In reality is O(log32 n) Because the nodes have a length of 32

Clojure is not OO Which is a plus IMO Here’s a secret: Objects are not that good for programming :D Leaky Objects hide data behind a specific “interface” for every single type Combine data and behavior Combine identity and state Combine inheritance and polymorphism How do you solve problems then? ;) Data and functions Grouped in namespaces

Clojure has specific constructs to deal with state and processes Immutability No update-in-place Well defined semantics of how state evolves over time Based on observing a succession of values Values are propagated via channels (core.async) Like queues with additional semantics Based on CSP (Communicating Sequential Processes)

Clojure is a dynamic language Dynamically typed Runtime Offers much more freedom of doing things that are impossible in Java Riemann as an example for code as configuration “Shallow” (my terminology) statically typed languages like Java do not offer enough advantages for forcing a type system Most of errors caught by types can also be caught by basic testing

Clojure is design to be easy to reason about the code Does that by Less verbose Immutable Functional Less LOCs Easier to test

References Out of the Tar Pit On Understanding Data Abstraction, Revisited Are We There Yet? Simple Made Easy Clojure Made Simple