Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
The Nim programming
language
unified.diff
Disclaimer
Here be
contrary
opinions!
The Joy of Ruby
5.times { print "Odelay!" }
exit unless restaurant.menu.include? "kebab"
meringue = ['egg', 'sugar', 'milk...
90% = good enough
10% =
performance ||
concurrency ||
parallelism
The trouble with C(++)
❏ int (*(*func())[10])()
❏ 1 / 0;
❏ char s[ ] == char *s == std::string == LPSTR
== wchar
❏ int myI...
Hello world!
puts "hello world!" Ruby
print "hello world!" Python
#include <iostream> C++
int main()
{
std::cout << "hello...
Language bureaucracy
public class HelloWorld { Java
public static void main(String[] args) {
System.out.println("Hello, Wo...
Quest for a new system-level language
Requirements:
● Safe
● Portable
● Performant
● Expressive
● Elegant
Candidates:
1. R...
© Nim In Action, Dominik Picheta, Manning Publications, 2016
Portability
● Nim → Backend (C, JS)
● Backend → Nim (C, JS)
● c2nim = Parse a C file and generate equivalent
Nim code
Interoperability
Statically typed + variable state
● Statically typed / type inference
● Immutable / mutable variables
● whitespace-significant
Types and variables
● Non-tracing GC
● Can be customised
○ GC_setMaxPause(MaxPauseInUs: int)
○ GC_step(us: int, strongAdvice = false, stackSiz...
Functions
Functions: UFC
Function: overloading
Generics
First-class Functions
● First-class citizens
● Closures
● Implicit returns
● Immutable arguments
● Overloading
● Uniform Function Call
● Style-i...
Modules
person.nim
main.nim
● Arrays
● Sequences
● Objects
● Tuples
● Sets
Structured Types
Modules
Functional programming
Side-effect checking
Built-in functional style
Templates as DSLs
Templates can access AST
Macros
Threads
NimScript
Any questions?
Ping me at:
FredAtBootstrap
fred@bootstrap.me.uk
Introduction to Nim
Introduction to Nim
Próxima SlideShare
Cargando en…5
×

Introduction to Nim

Talk given at UnifiedDiff 10/06/2016

Introduction to Nim

  1. 1. The Nim programming language unified.diff
  2. 2. Disclaimer
  3. 3. Here be contrary opinions!
  4. 4. The Joy of Ruby 5.times { print "Odelay!" } exit unless restaurant.menu.include? "kebab" meringue = ['egg', 'sugar', 'milk'].reduce &:+
  5. 5. 90% = good enough
  6. 6. 10% = performance || concurrency || parallelism
  7. 7. The trouble with C(++) ❏ int (*(*func())[10])() ❏ 1 / 0; ❏ char s[ ] == char *s == std::string == LPSTR == wchar ❏ int myInt = 0; fileStream.read (reinterpret_cast<char*>(&myInt), sizeof(int)); ❏ void myfunc() { char *c = malloc(16); }
  8. 8. Hello world! puts "hello world!" Ruby print "hello world!" Python #include <iostream> C++ int main() { std::cout << "hello world!n"; return 0; } fn main() { Rust println!("Hello world!"); } package main Go import "fmt" func main() { fmt.Println("hello world!") }
  9. 9. Language bureaucracy public class HelloWorld { Java public static void main(String[] args) { System.out.println("Hello, World"); } } using System; C# namespace HelloWorld { class Hello { static void Main() { Console.WriteLine("Hello World!"); } } }
  10. 10. Quest for a new system-level language Requirements: ● Safe ● Portable ● Performant ● Expressive ● Elegant Candidates: 1. Rust 2. Go 3. Nim
  11. 11. © Nim In Action, Dominik Picheta, Manning Publications, 2016 Portability
  12. 12. ● Nim → Backend (C, JS) ● Backend → Nim (C, JS) ● c2nim = Parse a C file and generate equivalent Nim code Interoperability
  13. 13. Statically typed + variable state
  14. 14. ● Statically typed / type inference ● Immutable / mutable variables ● whitespace-significant Types and variables
  15. 15. ● Non-tracing GC ● Can be customised ○ GC_setMaxPause(MaxPauseInUs: int) ○ GC_step(us: int, strongAdvice = false, stackSize = -1) ● Can be turned off ○ GC_disable() Garbage Collection
  16. 16. Functions
  17. 17. Functions: UFC
  18. 18. Function: overloading
  19. 19. Generics
  20. 20. First-class Functions
  21. 21. ● First-class citizens ● Closures ● Implicit returns ● Immutable arguments ● Overloading ● Uniform Function Call ● Style-indifferent Functions
  22. 22. Modules person.nim main.nim
  23. 23. ● Arrays ● Sequences ● Objects ● Tuples ● Sets Structured Types
  24. 24. Modules
  25. 25. Functional programming Side-effect checking Built-in functional style
  26. 26. Templates as DSLs
  27. 27. Templates can access AST
  28. 28. Macros
  29. 29. Threads
  30. 30. NimScript
  31. 31. Any questions? Ping me at: FredAtBootstrap fred@bootstrap.me.uk

×