advertisement

Language Design Trade-offs

67 %
33 %
advertisement
Information about Language Design Trade-offs
Technology

Published on June 14, 2013

Author: abreslav

Source: slideshare.net

Description

If your programming language is small, you’re probably born before 1950, and your first computer was bigger than your present apartment. And even those languages are not so small. One spends quite some time to master a programming language. Why?

Because there are very many decisions “compressed” into the form of a language. Nothing limits a programmer’s imagination like a compiler, and nothing limits a language design like a real world with all of its “legacy”, compatibility concerns, performance limitations, generations-old habits and leaky abstractions.

This talk is about tradeoffs: why we, as language designers, do (or rather did) this and not that.
advertisement

LanguageDesignTrade-Offsandrey.breslav@ .comis

Simply Universal

Full of Shortcuts

Simply Universal

Full of Shortcuts

Trade-Off #0Elegance Convenience

TimeComplexity1968

Cool Practical

Clever ReadableSimple FastShiny New Good OldGround-Breaking Compatible

Shiny New Good Old

As Java Evolved…Foo<? extends T>new Foo()new Foo<T>()new Foo<>()SAM-ConversionsDefaultmethods

Lambdas & SAM-Conversionsvoid foo(Function<? super Bar, ? extends Baz> g)SAM-typefoo(g -> new SubBaz(g));

Compatibilityis a drag,son…

Simple Fast

Boxing for Primitivesnew Foo()The Age of (Auto)Boxing

LanguageRuntimeJITx86 amd64 ARMGCx86 amd64 ARMThreadsLinux Windows MacHardVeryHard

Ground-Breaking Compatible

JDK Collections interface List<E> {E get(int index);E set(int index, E value);}Read-only /** read-only */List<Foo> getFoos() {return unmodifiableList(l);}Errors At Runtime

Cool Collections interface List<E> {E get(int index);}interface MutableList<E>extends List<E> {E set(int index, E value);}Read-only List<Foo> getFoos() {return l; // may be mutable}Errors At Compile Time

Safe CompatibleCool Collections JDK Collectionscatch errors earlyself-documenting codeno wrapping/repackagingexisting API’s workIntuitive ? extends Fooprint(List<? extends Foo> foos)print(foos: List<Foo>)

Iterable<out T>Collection<out T>List<out T> Set<out T>MutableIterable<T>MutableCollection<T>MutableList<T> MutableSet<T>java.lang.ArrayList<T> java.util.HashSet<T>KotlinCollectionsJDKCollections

Kotlin Collections = &SafeCompatibleCo-variant

Java String s = null;s.length();Errors At RuntimeKotlin val s: Strings.length()val s: String? = nulls.length()Errors At Compile Time= nullNullabletype

Check and use val s: String? = …if (s != null) {s.length()}Check and exit if (s == null) returns.length()Rock’n’Roll s?.length()

JAR Fileclass Foo {String getName() { … }}Nullable or Not?<XML/>@NotNullKAnnotator

Dynamic Static

LibraryLocked*Util class

Util class Collections2.transform(Collections2.filter(list,(foo) -> foo.isValid()),(foo) -> new Bar(foo)));No Util Class scala.collection.Iterable[T]declares 116 methods

Ugly Interfaces Ugly Code

Java static char last(String s)Usage “abc”.last()C# static char last(string this)Kotlin fun String.last(): Char {return this[this.size - 1]}

Access privates NoVirtual NoOwner PackageMany Applicable Overloading errorMember Clashes Member wins= static utility

Theory Practice

Java new List<String>()Collections.<String>emptyList()Why different?Scala new List[String]()emptyList[String]()arr(0)Why square brackets?

foo(bar<A, B>(x + 1))foo(bar < a, b > (x + 1))

Java Familiar (from C++)Sometimes uglyScala Always prettyUnfamiliarC# andKotlinFamiliarAlways* prettyemptyList<String>()* foo((bar < A), B > (x+1))

Practiceis nicer thanTheory

LanguageDesignTrade-Offsandrey.breslav@ .comiskotlin.jetbrains.org

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Programming language trade-offs | GarfieldTech

Programming language trade-offs. ... Again, it's not a question of can you implement a given design but how easily you can do so, and at what cost.
Read more

Language Design Tradeoffs - iRi - jerf.org

Language Design Tradeoffs posted Sep 27, 2007 in Programming. This entry is part of the BlogBook called "Programming Wisdom". 4. Nothing is Free. 1 ...
Read more

What is language design trade-offs of principles of ...

What is language design trade-offs of principles of programming languages? ... (graphical) language i … n the design process. ...
Read more

Language Design Trade Offs ~ jleBooks

Language Design Trade Offs Download Book: Language Design Trade Offs Download or Read Online Book Language Design Trade Offs Book Collections in PDF Format ...
Read more

Design Tradeoffs to Support the C Programming Language in ...

Design Tradeoffs to Support the C Programming Language in the CRISP Microprocessor,10.1145/36206.36198,Sigplan Notices,David R. Ditzel,Hubert R. McLel
Read more

Programming Language design tradeoffs between Java and C ...

Programming Language design tradeoffs between Java and C in terms of efficiency and safety (reliability)? Can you describe (and possibly ...
Read more

Resolving Design Trade-offs with the BIGT Concept ...

Resolving Design Trade-offs with the BIGT Concept. Conference: PCIM Europe 2014 - International Exhibition and Conference for Power Electronics ...
Read more

4.1 Design Tradeoffs - klabs.org

4.1 Design Tradeoffs . Conceptual design involves a series of tradeoff decisions among significant parameters - such as operating speeds, memory size ...
Read more

Trade–off | Definition of Trade–off by Merriam-Webster

See trade–off defined for English-language learners. See trade–off defined for kids. 1961. First Known Use of trade–off. 1961. Rhymes with trade–off.
Read more