This talk takes a deep dive into asynchronous programming patterns and practices, with an emphasis on the promise pattern.
We go through the basics of the event loop, highlighting the drawbacks of asynchronous programming in a naive callback style. Fortunately, we can use the magic of promises to escape from callback hell with a powerful and unified interface for async APIs. Finally, we take a quick look at the possibilities for using coroutines both in current and future (ECMAScript Harmony) JavaScript.
The document discusses clean coding practices for Java developers. It covers topics such as choosing meaningful names for variables, methods, and classes; writing code that is easy for others to understand; breaking methods down into single logical steps; and using fluent APIs to make code more readable. The presentation provides examples of clean code and ways to refactor code to follow best practices.
The document summarizes Roman Elizarov's presentation on Kotlin coroutines at the JVM Language Summit in 2017. The presentation recapped the initial Kotlin coroutines prototype, discussed issues with its design, and outlined the solutions adopted in Kotlin 1.1. This included using suspending functions instead of async/await keywords, tail suspension to avoid stack overflows, and abstraction to provide a natural coroutine declaration syntax.
자프링(자바 + 스프링) 외길 12년차 서버 개발자가 코프링(코틀린 + 스프링)을 만난 후 코틀린의 특징과 스프링의 코틀린 지원을 알아가며 코프링 월드에서 살아남은 이야기…
코드 저장소: https://github.com/arawn/kotlin-support-in-spring
RxJS is a library for reactive programming that allows composing asynchronous and event-based programs using observable sequences. It provides the Observable type for pushing multiple values to observers over time asynchronously. Operators allow transforming and combining observables. Key types include Observable, Observer, Subject, BehaviorSubject, and ReplaySubject. Subjects can multicast values to multiple observers. Overall, RxJS is useful for handling asynchronous events as collections in a declarative way.
2018.10.18
OKKYCON: 2018 《The Real TDD - TDD 제대로 알기》
정진욱님의 <테스트하기 쉬운 코드로 개발하기> 발표자료입니다.
(PPT 원본 ☞ https://1drv.ms/p/s!ApDGhCqxGI8ohJlUuAk_3_LxpRFz0A )
[연사 소개]
정진욱 - PUBLYTO CPO
8년간 장래 교통량 예측을 하다, 개발에 흥미를 느껴 전업했다. 현재 PUBLYTO에서 백엔드를 맡고 있다. 교통량 계산 실수가 빈번할 때 TDD 방법론을 처음 접했다. 테스트부터 만든다는 TDD의 역발상이 계산 실수를 줄이는 데 도움이 되었다. 그때부터 TDD에 관심을 갖게 되었으며, 현재는 Property-based Testing 기법을 사내 프로젝트에 적용하고 있다.
[발표 소개]
TDD가 어려운 이유는 테스트 기술이 부족해서가 아닙니다. 가장 큰 원인은 테스트 대상 코드(System Under Test, SUT)가 테스트하기 힘들게 디자인되었기 때문입니다. 우리는 테스트하기 쉬운 형태로 SUT를 디자인해야 합니다. 쉬운 테스트 코드가 주도하는 개발 방법을 실전 코드 중심으로 살펴봅니다.
http://okkycon.com
This document summarizes the new features and goals of RxJS version 5, which aims to improve the modularity, performance, debugging, and extensibility of the RxJS library. Key changes include making RxJS fully modular, improving performance by reducing allocations and call stack sizes, enhancing debugging with simpler operator implementations, and allowing better extensibility through subclassing Observables and maintaining Subject bi-directionality. Simpler unit tests using marble diagrams are also highlighted.
The document discusses clean coding practices for Java developers. It covers topics such as choosing meaningful names for variables, methods, and classes; writing code that is easy for others to understand; breaking methods down into single logical steps; and using fluent APIs to make code more readable. The presentation provides examples of clean code and ways to refactor code to follow best practices.
The document summarizes Roman Elizarov's presentation on Kotlin coroutines at the JVM Language Summit in 2017. The presentation recapped the initial Kotlin coroutines prototype, discussed issues with its design, and outlined the solutions adopted in Kotlin 1.1. This included using suspending functions instead of async/await keywords, tail suspension to avoid stack overflows, and abstraction to provide a natural coroutine declaration syntax.
자프링(자바 + 스프링) 외길 12년차 서버 개발자가 코프링(코틀린 + 스프링)을 만난 후 코틀린의 특징과 스프링의 코틀린 지원을 알아가며 코프링 월드에서 살아남은 이야기…
코드 저장소: https://github.com/arawn/kotlin-support-in-spring
RxJS is a library for reactive programming that allows composing asynchronous and event-based programs using observable sequences. It provides the Observable type for pushing multiple values to observers over time asynchronously. Operators allow transforming and combining observables. Key types include Observable, Observer, Subject, BehaviorSubject, and ReplaySubject. Subjects can multicast values to multiple observers. Overall, RxJS is useful for handling asynchronous events as collections in a declarative way.
2018.10.18
OKKYCON: 2018 《The Real TDD - TDD 제대로 알기》
정진욱님의 <테스트하기 쉬운 코드로 개발하기> 발표자료입니다.
(PPT 원본 ☞ https://1drv.ms/p/s!ApDGhCqxGI8ohJlUuAk_3_LxpRFz0A )
[연사 소개]
정진욱 - PUBLYTO CPO
8년간 장래 교통량 예측을 하다, 개발에 흥미를 느껴 전업했다. 현재 PUBLYTO에서 백엔드를 맡고 있다. 교통량 계산 실수가 빈번할 때 TDD 방법론을 처음 접했다. 테스트부터 만든다는 TDD의 역발상이 계산 실수를 줄이는 데 도움이 되었다. 그때부터 TDD에 관심을 갖게 되었으며, 현재는 Property-based Testing 기법을 사내 프로젝트에 적용하고 있다.
[발표 소개]
TDD가 어려운 이유는 테스트 기술이 부족해서가 아닙니다. 가장 큰 원인은 테스트 대상 코드(System Under Test, SUT)가 테스트하기 힘들게 디자인되었기 때문입니다. 우리는 테스트하기 쉬운 형태로 SUT를 디자인해야 합니다. 쉬운 테스트 코드가 주도하는 개발 방법을 실전 코드 중심으로 살펴봅니다.
http://okkycon.com
This document summarizes the new features and goals of RxJS version 5, which aims to improve the modularity, performance, debugging, and extensibility of the RxJS library. Key changes include making RxJS fully modular, improving performance by reducing allocations and call stack sizes, enhancing debugging with simpler operator implementations, and allowing better extensibility through subclassing Observables and maintaining Subject bi-directionality. Simpler unit tests using marble diagrams are also highlighted.
Here I discuss about reactive programming, observable, observer and difference between observable and promise.
Also discuss some of important operators like forkJoin, switchMap, from, deboucneTime, discardUntilChanged, mergeMap. I discuss some of observable creation function.
Rust is a systems programming language that provides memory safety without using a garbage collector. It achieves memory safety through rules of ownership, borrowing, and lifetimes that are checked at compile time. These rules prevent common memory bugs like memory leaks, dangling pointers, and use-after-free errors that are common in C and C++.
All you need to know about the JavaScript event loopSaša Tatar
The document discusses the JavaScript event loop and call stack. It explains that JavaScript is single-threaded with an event loop that processes tasks in the order they are received. There is a call stack that processes code synchronously, and an event queue that holds asynchronous callbacks from events like timers, promises, etc. The event loop continually checks the call stack and event queue, running tasks from the queue after the stack is empty. This allows asynchronous code to run without blocking synchronous code.
The document discusses principles and best practices for writing clean code, including using meaningful names, separating commands and queries, avoiding repetition, using exceptions instead of return codes, and following object-oriented principles like polymorphism instead of switch statements on objects. It provides examples of good and bad code for concepts like single responsibility, primitive obsession, and refused bequest. The overall goal is to write code that is readable, maintainable, and extendable.
본 장표는 인프콘 2022 / 코틀린 멀티플랫폼, 미지와의 조우 세션에 대한 강연 자료입니다.
코틀린은 멀티플랫폼을 지원하는 언어로 Server-side와 Android뿐만이 아니라 JavaScript 엔진이 있는 브라우저나 Node.js도 지원하며, Native 등 다양한 플랫폼에서 쓸 수 있습니다. 이를 이용해 코틀린 코드를 공유하는 단일 코드베이스로 모바일부터 웹과 데스크톱, 서버에 이르기까지 다중 플랫폼 애플리케이션을 작성할 수 있습니다.
본 핸즈온 세션을 통해 코틀린 멀티플랫폼과 함께 리액트, 스프링부트로 웹 애플리케이션의 프론트엔드부터 백엔드까지 직접 개발하며 친해져 보는 시간을 가져보세요. 참가자는 코틀린 멀티플랫폼 프로젝트를 이해하고, 더 나아가 프론트엔드와 백엔드 간의 공유 로직 작성, Kotlin/JS 기반 리액트 및 스프링 웹 프로그래밍을 경험할 수 있습니다.
https://github.com/arawn/building-fullstack-webapp-with-kotlin-multiplatform
https://infcon.day/speaker/박용권-김지헌-코틀린-멀티플랫폼/
The document provides an introduction to asynchronous JavaScript. It discusses callbacks and their disadvantages like callback hell. Promises are introduced as a better way to handle asynchronous code by making it easier to write and chain asynchronous operations. Async/await is described as syntactic sugar that allows asynchronous code to be written more readably in a synchronous style using await and try/catch. Key aspects like the event loop, microtask queue, and Promise methods like all and race are explained. Overall the document aims to help understand what makes asynchronous code different and newer methods like promises and async/await that improve handling asynchronous operations in JavaScript.
Promises provide a consistent way to write asynchronous code in JavaScript by abstracting callbacks into objects. Some key benefits of promises include: handling errors through rejection instead of nested callbacks, ability to chain operations together through promise methods like .then(), and restoring synchronous-like control flow. The document discusses how promises improve on traditional callback-based patterns and provides examples of converting common asynchronous patterns to use promises.
Optional was introduced in Java 8 to help deal with null references in a safer way. Optional wraps an object that may or may not be present, and supports methods like map, filter, and flatMap to operate on the wrapped value in a functional style. Using Optional helps avoid NullPointerExceptions and makes it clear whether a value is present or absent, improving code readability and safety over directly using null references.
The document discusses the JavaScript event loop, which is how JavaScript handles concurrency. It explains that JavaScript is single-threaded but uses an event loop model to simulate parallelism. Key points are:
- JavaScript uses a single thread of execution but handles I/O asynchronously by placing callbacks into a queue to be executed later.
- This allows I/O-heavy operations like networking to occur "in parallel" without blocking the main thread.
- The event loop continuously runs through the call stack and queue, executing functions and callbacks.
- While efficient for I/O, CPU-intensive tasks would block the single thread, so JavaScript is not ideal for those types of applications.
The document discusses the benefits of using RxJS observables over promises and events for managing asynchronous and reactive code in Angular applications. It explains key concepts like observers, subscriptions, operators, cold vs hot observables, and using RxJS with services and components. Example code is provided for creating observable data services to share data between components, composing asynchronous logic with operators, and best practices for managing subscriptions and preventing memory leaks. Overall, the document promotes a reactive programming style with RxJS for building maintainable and testable Angular applications.
Asynchronous JavaScript Programming with Callbacks & PromisesHùng Nguyễn Huy
This presentation is about JavaScript Promise. Topics covered in this session are:
1. Asynchronous processing in JavaScript
2. Callbacks and Callback hell
3. Promises arrive in JavaScript!
4. Constructing a Promise
5. Promise states
6. Promises chaining and transformation
7. Error handling
8. Promise.all() and Promise.race()
The document discusses React hooks and how they can be used to manage state and other features in function components without writing classes. It provides examples of how common lifecycle methods and state management in classes can be re-written using hooks like useState, useEffect, and useContext. Specifically, it walks through converting a chat component that subscribes to new messages and manages local state from a class to a function component using these React hooks.
Asynchronous API in Java8, how to use CompletableFutureJosé Paumard
Slides of my talk as Devoxx 2015. How to set up asynchronous data processing pipelines using the CompletionStage / CompletableFuture API, including how to control threads and how to handle exceptions.
Rust is a systems programming language focused on three goals: safety, speed, and concurrency. It is open source and provides top-tier performance like C/C++ while ensuring memory safety and preventing issues like memory leaks through its ownership and borrowing model that is checked at compile time. Rust also supports features like enums, pattern matching, generics, traits, and has a built-in test system to help ensure correctness.
Here I discuss about reactive programming, observable, observer and difference between observable and promise.
Also discuss some of important operators like forkJoin, switchMap, from, deboucneTime, discardUntilChanged, mergeMap. I discuss some of observable creation function.
Rust is a systems programming language that provides memory safety without using a garbage collector. It achieves memory safety through rules of ownership, borrowing, and lifetimes that are checked at compile time. These rules prevent common memory bugs like memory leaks, dangling pointers, and use-after-free errors that are common in C and C++.
All you need to know about the JavaScript event loopSaša Tatar
The document discusses the JavaScript event loop and call stack. It explains that JavaScript is single-threaded with an event loop that processes tasks in the order they are received. There is a call stack that processes code synchronously, and an event queue that holds asynchronous callbacks from events like timers, promises, etc. The event loop continually checks the call stack and event queue, running tasks from the queue after the stack is empty. This allows asynchronous code to run without blocking synchronous code.
The document discusses principles and best practices for writing clean code, including using meaningful names, separating commands and queries, avoiding repetition, using exceptions instead of return codes, and following object-oriented principles like polymorphism instead of switch statements on objects. It provides examples of good and bad code for concepts like single responsibility, primitive obsession, and refused bequest. The overall goal is to write code that is readable, maintainable, and extendable.
본 장표는 인프콘 2022 / 코틀린 멀티플랫폼, 미지와의 조우 세션에 대한 강연 자료입니다.
코틀린은 멀티플랫폼을 지원하는 언어로 Server-side와 Android뿐만이 아니라 JavaScript 엔진이 있는 브라우저나 Node.js도 지원하며, Native 등 다양한 플랫폼에서 쓸 수 있습니다. 이를 이용해 코틀린 코드를 공유하는 단일 코드베이스로 모바일부터 웹과 데스크톱, 서버에 이르기까지 다중 플랫폼 애플리케이션을 작성할 수 있습니다.
본 핸즈온 세션을 통해 코틀린 멀티플랫폼과 함께 리액트, 스프링부트로 웹 애플리케이션의 프론트엔드부터 백엔드까지 직접 개발하며 친해져 보는 시간을 가져보세요. 참가자는 코틀린 멀티플랫폼 프로젝트를 이해하고, 더 나아가 프론트엔드와 백엔드 간의 공유 로직 작성, Kotlin/JS 기반 리액트 및 스프링 웹 프로그래밍을 경험할 수 있습니다.
https://github.com/arawn/building-fullstack-webapp-with-kotlin-multiplatform
https://infcon.day/speaker/박용권-김지헌-코틀린-멀티플랫폼/
The document provides an introduction to asynchronous JavaScript. It discusses callbacks and their disadvantages like callback hell. Promises are introduced as a better way to handle asynchronous code by making it easier to write and chain asynchronous operations. Async/await is described as syntactic sugar that allows asynchronous code to be written more readably in a synchronous style using await and try/catch. Key aspects like the event loop, microtask queue, and Promise methods like all and race are explained. Overall the document aims to help understand what makes asynchronous code different and newer methods like promises and async/await that improve handling asynchronous operations in JavaScript.
Promises provide a consistent way to write asynchronous code in JavaScript by abstracting callbacks into objects. Some key benefits of promises include: handling errors through rejection instead of nested callbacks, ability to chain operations together through promise methods like .then(), and restoring synchronous-like control flow. The document discusses how promises improve on traditional callback-based patterns and provides examples of converting common asynchronous patterns to use promises.
Optional was introduced in Java 8 to help deal with null references in a safer way. Optional wraps an object that may or may not be present, and supports methods like map, filter, and flatMap to operate on the wrapped value in a functional style. Using Optional helps avoid NullPointerExceptions and makes it clear whether a value is present or absent, improving code readability and safety over directly using null references.
The document discusses the JavaScript event loop, which is how JavaScript handles concurrency. It explains that JavaScript is single-threaded but uses an event loop model to simulate parallelism. Key points are:
- JavaScript uses a single thread of execution but handles I/O asynchronously by placing callbacks into a queue to be executed later.
- This allows I/O-heavy operations like networking to occur "in parallel" without blocking the main thread.
- The event loop continuously runs through the call stack and queue, executing functions and callbacks.
- While efficient for I/O, CPU-intensive tasks would block the single thread, so JavaScript is not ideal for those types of applications.
The document discusses the benefits of using RxJS observables over promises and events for managing asynchronous and reactive code in Angular applications. It explains key concepts like observers, subscriptions, operators, cold vs hot observables, and using RxJS with services and components. Example code is provided for creating observable data services to share data between components, composing asynchronous logic with operators, and best practices for managing subscriptions and preventing memory leaks. Overall, the document promotes a reactive programming style with RxJS for building maintainable and testable Angular applications.
Asynchronous JavaScript Programming with Callbacks & PromisesHùng Nguyễn Huy
This presentation is about JavaScript Promise. Topics covered in this session are:
1. Asynchronous processing in JavaScript
2. Callbacks and Callback hell
3. Promises arrive in JavaScript!
4. Constructing a Promise
5. Promise states
6. Promises chaining and transformation
7. Error handling
8. Promise.all() and Promise.race()
The document discusses React hooks and how they can be used to manage state and other features in function components without writing classes. It provides examples of how common lifecycle methods and state management in classes can be re-written using hooks like useState, useEffect, and useContext. Specifically, it walks through converting a chat component that subscribes to new messages and manages local state from a class to a function component using these React hooks.
Asynchronous API in Java8, how to use CompletableFutureJosé Paumard
Slides of my talk as Devoxx 2015. How to set up asynchronous data processing pipelines using the CompletionStage / CompletableFuture API, including how to control threads and how to handle exceptions.
Rust is a systems programming language focused on three goals: safety, speed, and concurrency. It is open source and provides top-tier performance like C/C++ while ensuring memory safety and preventing issues like memory leaks through its ownership and borrowing model that is checked at compile time. Rust also supports features like enums, pattern matching, generics, traits, and has a built-in test system to help ensure correctness.
[Hello world 오픈세미나]실시간웹을위한comet과socket.ioNAVER D2
The document discusses different types of users (A, B, C) and their perspectives on real-time web technologies. Type A users prefer simple explanations, while Type B users like examples and case studies. Type C users want discussions of principles and performance. The presenter then provides a high-level overview comparing the client-server approach of Comet to the true real-time model of Socket.io.
Pick up the low-hanging concurrency fruitVaclav Pech
The document discusses various approaches for dealing with concurrency and parallelism in programming. It highlights that while threads and locks make concurrency difficult, there are better solutions like fork/join pools, dataflow programming, and actors. These approaches allow programmers to write code without worrying about threads and synchronization, making parallelism easier to implement. The key milestone approaches mentioned are asynchronous calculations, parallel collection processing using fork/join, dataflow programming using variables and streams, and using actors to isolate concurrent operations.
The document discusses the beauty of JavaScript and its many features. It covers how JavaScript offers classless object-oriented programming and functional programming. It also discusses how JavaScript can run on both the client-side and server-side. The document provides examples of JavaScript syntax like variables, functions, objects, prototypes and more to demonstrate JavaScript's capabilities. It emphasizes that libraries help create abstractions and beautiful patterns in JavaScript code.
The document discusses the beauty of JavaScript and its many features. It covers how JavaScript offers classless object-oriented programming and functional programming. It also discusses how JavaScript can run on both the client-side and server-side. The document provides examples of JavaScript syntax like variables, functions, objects, inheritance through prototypes, and AJAX requests. It emphasizes how libraries help create abstractions and beautiful patterns in JavaScript code.
Mobl is a programming language for building mobile web applications. It aims to provide portability across different mobile platforms and browsers by compiling to JavaScript and HTML5. Mobl supports common mobile features like location services, camera, contacts and more through a simple object-oriented syntax. It also includes tools for building user interfaces, accessing data through entities and queries, and making web service requests. The goal is to enable complete coverage of mobile development needs while avoiding platform-specific code.
Wiktor Toporek: Pomimo tego że JavaScript mocno ewoluował na przestrzeni ostatnich lat, zakorzeniona w nim jego asynchroniczna natura wciąż może sprawiać problem programistom i to zarówno początkującym jak i tym zaawansowanym. W prezentacji przyjrzymy się jednemu z bohaterów programowania asynchronicznego jakim jest Promise, przeanalizujemy niektóre z pułapek oraz zastanowimy się również czy w pełni wykorzystujemy jego potencjał.
The document discusses different patterns for handling asynchronous code in JavaScript: callbacks, promises, and AMD (Asynchronous Module Definition). It outlines issues with nested callbacks and inflexible APIs. Promises and AMD aim to address these by allowing composition of asynchronous operations and defining module dependencies. The document provides examples of implementing PubSub with events, making and piping promises, and using AMD to load dependencies asynchronously. It concludes that callbacks should generally be avoided in favor of promises or AMD for asynchronous code.
Async/await is a new language feature that will ship with Swift 5.5 this year. There’s no doubt it will have a significant impact on how we write asynchronous code.
In this talk, we’re going to look at some use cases for async/await, how we can call existing Swift APIs using this new feature, and why your decision to write your SDK in Objective-C might turn out to have been a very clever move.
We’ll also have a look at the refactoring support Apple is adding to Xcode and how it will help you migrate your existing code base.
Think Async: Asynchronous Patterns in NodeJSAdam L Barrett
JavaScript is single threaded, so understanding the async patterns available in the language is critical to creating maintainable NodeJS applications with good performance. In order to master “thinking in async”, we’ll explore the async patterns available in node and JavaScript including standard callbacks, promises, thunks/tasks, the new async/await, the upcoming asynchronous iteration features, streams, CSP and ES Observables.
The document discusses the mobl programming language for building mobile web applications. Mobl is a statically-typed language that compiles to HTML and JavaScript. It aims to provide features for building reactive user interfaces and uses techniques like continuation-passing style and observables to support asynchronous programming in a synchronous-looking way. The document provides examples of coding common mobile app patterns like data binding, network requests, and user input handling in mobl.
The document discusses how JavaScript frameworks like MooTools can be leveraged in Joomla sites to provide features like DOM manipulation, classes, event listeners, and effects. It describes how MooTools is the default framework used by Joomla and provides examples of its key capabilities. Additionally, it offers suggestions for optimizing framework usage, such as implementing the Google Loader API to decrease page load times.
Not so long ago Microsoft announced a new language trageting on front-end developers. Everybody's reaction was like: Why?!! Is it just Microsoft darting back to Google?!
So, why a new language? JavaScript has its bad parts. Mostly you can avoid them or workaraund. You can emulate class-based OOP style, modules, scoping and even run-time typing. But that is doomed to be clumsy. That's not in the language design. Google has pointed out these flaws, provided a new language and failed. Will the story of TypeScript be any different?
Promises are a popular pattern for asynchronous operations in JavaScript, existing in some form in every client-side framework in widespread use today. We'll give a conceptual and practical intro to promises in general, before moving on to talking about how they fit into Angular. If you've ever wondered what exactly $q was about, this is the place to learn!
This document discusses best practices for handling errors and callbacks in Node.js applications. It covers techniques like error delegation, exception handling, error-first callbacks, avoiding nested callbacks, and using control flow libraries. It also discusses deployment strategies like using screen, restarting crashed processes, and innovating with platforms like Joyent, Nodejitsu and Heroku.
The document summarizes the key features of ES6 (ECMAScript 2015), the next version of JavaScript. It discusses new features like block scoping with let and const, arrow functions, classes, enhanced object literals, template strings, and promises. It also covers iterators and generators, which allow iterable objects to be looped over and asynchronous code to be written more cleanly. The presentation provides examples to illustrate how developers can take advantage of these new language features in their code.
Sample JavaScript Code Laurence Svekis
JavaScript Closure
A closure in JavaScript is a function that has access to the variables in its parent scope, even after the parent function has completed execution. This allows for data to be “closed over” or remembered by the inner function, even after the outer function has returned.
Here, the makeCounter function returns an inner function that has access to the count variable declared in its parent scope, and can “remember” the current count value even after the makeCounter function has completed execution. Each time the inner function is called, it returns the current value of count and increments it by 1.
JavaScript Closure Advanced
In this example, the makeAdder function takes in a single argument x and returns an inner function that takes in a second argument y. The inner function has access to the x variable declared in the parent scope and uses it to add x and y together and return the result.
We can see here that the outer function makeAdder has been executed twice and it returns two different inner functions which are assigned to different variables add5 and add10 and these inner functions are able to remember their respective parent scope values of x.
The next version of JavaScript, ES6, is starting to arrive. Many of its features are simple enhancements to the language we already have: things like arrow functions, class syntax, and destructuring. But other features will change the way we program JavaScript, fundamentally expanding the capabilities of the language and reshaping our future codebases. In this talk we'll focus on two of these, discovering the the myriad possibilities of generators and the many tricks you can pull of with template strings.
Learn how to write scripted load tests in PHP to run against your system without breaking the bank. Jason will cover not only the importance of load testing, but share stories of how load tests uncovered problems that would otherwise not have been discovered until production. Also, learn how to use load testing to learn how to deal with large traffic sites without needing to be employed by a large scale site first. We’ll be using RedLine13, an almost free load testing tool that is at the same time inexpensive, easy, and effective.
This document provides an overview of the Griffon framework for building desktop applications in Groovy and Java. It discusses key Griffon concepts like conventions over configuration, MVC patterns, built-in testing support, and automation of repetitive tasks. The document also covers Griffon features such as lifecycle scripts, binding, threading, and popular plugins. Resources for learning more about Griffon and its community are provided at the end.
Similar to Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patterns in JavaScript (20)
- JavaScript has come a long way from its early days of form validation and image rollovers in 1995 to modern innovations like ES2015, Promises, async/await, and Web Assembly.
- Today, JavaScript features like classes, arrow functions, and template strings in ES2015 are widely adopted, and new standards like Promises, generators, and async programming have revolutionized asynchronous JavaScript.
- Emerging web platform technologies like Web Components, Service Workers, and CSS Paint enable new kinds of custom elements, offline/progressive web apps, and painting APIs, while proposals like decorators, value types, and module loading continue pushing the language forward.
Slowly but surely, promises have spread throughout the JavaScript ecosystem, standardized by ES 2015 and embraced by the web platform. But the world of asynchronous programming contains more patterns than the simple single-valued async function call that promises represent. What about things like streams, observables, async iterators—or even just cancelable promises? How do they fit, both in the conceptual landscape and in your day-to-day programming?
For the last year, I've been working to bring an implementation of I/O streams to the browser. Meanwhile, designs for a cancelable promise type (sometimes called "tasks") are starting to form, driven by the needs of web platform APIs. And TC39 has several proposals floating around for more general asynchronous iteration. We'll learn about these efforts and more, as I guide you through the frontiers of popular libraries, language design, and web standards.
Two years ago I inherited jsdom, a project of breathtaking scope. In essence, it aims to simulate a browser in JavaScript, by implementing JavaScript versions of a wide variety of web standards (much more than just the DOM). While maintaining jsdom for the last two years, and eventually bringing it to a 1.0 release, I learned an incredible amount about the web. I want to share with you what I’ve learned: the history of the standards and implementations of them that make up the web; the interaction between seemingly-disparate parts of the platform; and all about the strange APIs we’ve come to know and love. You should walk away from this talk with a new appreciation for how browsers work—and how, through the ongoing effort of a community of contributors and package maintainers, we’ve been able to recreate one in pure JavaScript.
In 2010, a photo-sharing startup launched—on a single, closed platform. Over the next two years, it gained over 100 million active users, before being acquired by Facebook for one. billion. dollars.
Only half a year after *that* did they finally release a web app.
Instagram's main purpose was sharing photos and commenting on them. If this isn't a perfect fit for the open web platform, I don't know what is. And yet the app was planted neatly within Apple's walled garden, without even an API to speak of. How did things go so wrong?
The web needs to catch up, and fast. If we want to preserve all the virtues of the web—shareable URLs, indexable content, open standards, instantly deployed updates, and so on—then we need to make the web platform more attractive, both to developers and users. We need to explore the final frontier of web development: *true* web apps, of the kind that will delight our users (and our investors). But we're not quite there … yet.
In this talk, I want to explore the efforts underway to bring the web platform up to speed as a genuine competitor. We have the most momentum of any platform in history, but there are still many unanswered questions. What are the major functionality gaps, and how are we closing them? Can we make app development as easy for web as it is for native? How do we fix mobile performance? Can you even use a web app while you're offline? I want to tell you about that not-too-distant future where these problems have been solved. Editors are speccing up new APIs; implementers are leveling up their browsers; and the community is building new frameworks. Together, we're slowly but surely pushing into that final frontier. And once we're past it, the mobile web will be a natural choice for the next big content-sharing app, enabling us to share by simply sending a URL—from any browser, to any device, on any platform.
The document discusses using ES6 features in real-world applications. It provides examples of using arrow functions, classes, destructuring, template literals, and default parameters to write cleaner code. It also discusses tools for enabling ES6 features that are not yet fully supported, such as transpilers, and flags in Node.js and Chrome to enable more experimental features. Overall, the document advocates adopting ES6 features that make code more concise and readable.
Streams are a fundamental programming primitive for representing the flow of data through your system. It's time we brought this powerful tool to the web. What if we could stream data from a HTTP request, through a web worker that transforms it, and then into a <video> tag? Over the last year, I've been working on the WHATWG streams specification, which builds upon the lessons learned in Node.js, to provide a suitable abstraction for needs of the extensible web.
I'll discuss briefly why streams are important, what they enable, and the role we envision them playing in the future of the web platform. Mostly, though, I want to help you understand streams, at a deep level. In the course of writing this specification, I've learned a lot about streams, and I want to share that knowledge with you. At the core, they are a very simple and beautiful abstraction. I think we've done a good job capturing that abstraction, and producing an API the web can be proud of. I'd love to tell you all about it.
Our favorite language is now powering everything from event-driven servers to robots to Git clients to 3D games. The JavaScript package ecosystem has quickly outpaced past that of most other languages, allowing our vibrant community to showcase their talent. The front-end framework war has been taken to the next level, with heavy-hitters like Ember and Angular ushering in the new generation of long-lived, component-based web apps. The extensible web movement, spearheaded by the newly-reformed W3C Technical Architecture Group, has promised to place JavaScript squarely at the foundation of the web platform. Now, the language improvements of ES6 are slowly but surely making their way into the mainstream— witness the recent interest in using generators for async programming. And all the while, whispers of ES7 features are starting to circulate…
JavaScript has grown up. Now it's time to see how far it can go.
How to Win Friends and Influence Standards BodiesDomenic Denicola
# How to Make Friends and Influence Standards Bodies
The greatest strength of the web is its openness. But not everyone appreciates how we arrived at the open web of today. A recent trend has cast standards bodies as bureaucracies that never accomplish anything of substance, while the heroic community innovates and implements “from scratch.”
Reality is much less black-and-white: sandboxes like Node.js have received much from the web platform and language that spawned them, and have a lot to contribute back. Standards bodies are composed of implementers and community members willing to engage, not ivory tower philosophers handing down bad, never-tested APIs from on high. And real gains could be made for both sides—with some effort.
This talk is part stories, and part lessons; it’s meant both to teach, and to open the floodgates for collaboration. You’ll hear about ways in which community input has had great impact on the standards process for the better, as in the case of web audio or adding promises to ES6. But you’ll also be taught communication and coalition-building skills that, from what I see, are sorely needed by many community members. How can you get involved and shape the future of the web and JavaScript platforms in a direction that will help everyone? Who are the key players and processes that they follow?
Finally, together we’ll brainstorm on and identify some key areas where your expertise and hard-learned lessons could help the web platform toward future solutions for problems it’s encountered.
In June 2013, we published the Extensible Web Manifesto, declaring that the web platform should be built a series of extensible layers. Low-level capabilities, like hardware access, cryptography, or the parser, should be exposed to web developers through JavaScript, and higher-level features, like HTML tags or animations, should be explained in terms of those primitives. This allows JavaScript developers to extend the web platform without rewriting it from scratch in JavaScript, customizing it for the needs of their applications and creating a virtuous cycle wherein web developers prototype higher-level features that implementers can later pull in.
In this talk, I want to explore the concrete meaning of the extensible web. What initiatives already under way can we see through this lens? What ideas are still gestating, and need your input as a web developer? How will this new philosophy end up impacting you? I want to show you the future of the web platform, where developers like you are involved from the beginning in designing and prototyping APIs, and have enough low-level tools at your fingertips to solve any problem you face. And I want to bring it all back to our favorite language, JavaScript, which is the glue that makes this all work together.
In text format at http://domenic.me/2013/10/07/the-extensible-web/
(Presented at JSConf US 2013. Be sure to check out the speaker notes!)
Frustration, a rant, a test suite, a gist. Then, community awesomeness. Boom! Promises/A+ was born.
Promise are an old idea for abstracting asynchronous code, but have only recently made their way into JavaScript. We'll look at the power they provide via two striking examples that go beyond the usual "escape from callback hell" snippets. First we'll show how, with ES6 generators, they can act as shallow coroutines to give us back code just as simple as its synchronous counterpart. Then we'll look at how they can be used as proxies for remote objects, across <iframe>, worker, or web socket boundaries.
However, the most interesting aspect of Promises/A+ is not just the code it enables, but how we worked to create it. We didn't join a standards body, but instead formed a GitHub organization. We had no mailing list, only an issue tracker. We submitted pull requests, made revisions, debated versions tags, etc.—all in the open, on GitHub. And, we succeeded! Promises/A+ is widely used and implemented today, with its extensible core forming the starting point of any discussions about promises. Indeed, this community-produced open standard has recently been informing the incorporation of promises into ECMAScript and the DOM. I'd like to share the story of how this happened, the lessons we learned along the way, and speculate on the role such ad-hoc, community-driven, and completely open specifications have for the future of the web.
Domains were added to Node.js in 0.8, but their use and workings have been a relative mystery. In short, domains are a structured way of reacting to uncaught exceptions; for example, when creating an HTTP server, you can use domains to send 500 errors when exceptions occur instead of crashing your server. This talk will go over what domains are, how to use them, and some of the subtleties behind how they work.
This document discusses client-side JavaScript packages and module systems. It begins by describing CommonJS and AMD module systems, noting problems with AMD including configuration complexity and inability to easily consume third-party code. It then introduces the concept of packages as a better unit of code reuse than modules alone. NPM is presented as a package manager that solves problems of downloading, installing dependencies, and accessing other packages' code. Key aspects of NPM packages like directory structure and package.json are outlined. The document concludes by briefly covering NPM features like dependency hierarchies, Git dependencies, and using NPM without publishing to the public registry.
This document discusses best practices for creating RESTful APIs. It covers three main topics: representing resources with URLs and HTTP verbs, using the HTTP protocol machinery like status codes and caching, and linking resources together through hypermedia. URLs should represent resources, verbs should represent actions, and standard HTTP features like status codes and conditional requests should be used. Well-designed REST APIs represent application state through linked resources and relationships rather than embedding actions in URLs.
Although Web and mobile apps are getting more capable every day, often your application makes the most sense on the desktop. In this talk, we’ll look at some recent technologies that have allowed significant desktop apps — like Barnes & Noble’s NOOK Study e-textbook reader, or Adobe’s Brackets IDE — to be written in HTML5 and JavaScript. Projects like the Chromium Embedded Framework, node-webkit, and AppJS provide an excellent native-to-JS bridge. With them in hand, you can bring the full power of the Node.js and front-end ecosystems to bear, while still gaining the advantages of running as a native app.
ES6 is Nigh is a presentation on the future of JavaScript. It discusses the history of JavaScript and why ES6 is important for advancing the language. The presentation outlines many new features being added in ES6, such as arrow functions, classes, modules, template strings, symbols, generators, and proxies. It emphasizes that ES6 is purely additive and introduces these features without breaking backwards compatibility.
Let’s talk about what Microsoft has given us for building ambitious, real-world Windows 8 apps in HTML5 and JavaScript—but also what’s missing, and how we can fill in the gaps.
The discovery of unit testing and test-driven development was one of the most important parts of my growth as a developer. The ability to write simple, small pieces of code that could verify the behavior of my application was in itself quite useful. And the ability to refactor without fear, just by running the test suite, changed how I program. But the real benefits come in how unit tests shape your application code: more testable code is often more well thought-out, more decoupled, and more extensible.
In this talk, I'll give a whirlwind introduction to unit testing as a concept and as a practice. I want you fully convinced it's the best thing to happen to software development, if you aren't already. Once we're on the same page there, I'll take a deep dive into what makes a good unit test. This involves testing tools such as spies, stubs, and mocks, concepts like code coverage, and practices like dependency injection that shape your application code. The most important lesson will be on how to focus on singular, isolated units of code in your testing, as this guides you toward building modular, flexible, and comprehensible applications.
Node.js is an exciting new platform for building web applications in JavaScript. With its unique I/O model, it excels at the sort of scalable and real-time situations we are increasingly demanding of our servers. And the ability to use JavaScript for both the client and server opens up many possibilities for code sharing, expertise reuse, and rapid development.
This class is intended for those with some basic knowledge of JavaScript, interested in an introduction to the Node.js ecosystem and development platform. We'll discuss how to get started with Node, and why you would want to. We'll then explore Node's module and package system, demonstrating several of the more popular and impressive packages that exemplify the type of tasks Node excels at. These include low-level HTTP streaming with the http module, high-level bidirectional websocket communication with socket.io, and server-browser code sharing with browserify, jsdom, and node-canvas.
Dev Dives: Mining your data with AI-powered Continuous DiscoveryUiPathCommunity
Want to learn how AI and Continuous Discovery can uncover impactful automation opportunities? Watch this webinar to find out more about UiPath Discovery products!
Watch this session and:
👉 See the power of UiPath Discovery products, including Process Mining, Task Mining, Communications Mining, and Automation Hub
👉 Watch the demo of how to leverage system data, desktop data, or unstructured communications data to gain deeper understanding of existing processes
👉 Learn how you can benefit from each of the discovery products as an Automation Developer
🗣 Speakers:
Jyoti Raghav, Principal Technical Enablement Engineer @UiPath
Anja le Clercq, Principal Technical Enablement Engineer @UiPath
⏩ Register for our upcoming Dev Dives July session: Boosting Tester Productivity with Coded Automation and Autopilot™
👉 Link: https://bit.ly/Dev_Dives_July
This session was streamed live on June 27, 2024.
Check out all our upcoming Dev Dives 2024 sessions at:
🚩 https://bit.ly/Dev_Dives_2024
Tool Support for Testing as Chapter 6 of ISTQB Foundation 2018. Topics covered are Tool Benefits, Test Tool Classification, Benefits of Test Automation and Risk of Test Automation
Database Management Myths for DevelopersJohn Sterrett
Myths, Mistakes, and Lessons learned about Managing SQL Server databases. We also focus on automating and validating your critical database management tasks.
Coordinate Systems in FME 101 - Webinar SlidesSafe Software
If you’ve ever had to analyze a map or GPS data, chances are you’ve encountered and even worked with coordinate systems. As historical data continually updates through GPS, understanding coordinate systems is increasingly crucial. However, not everyone knows why they exist or how to effectively use them for data-driven insights.
During this webinar, you’ll learn exactly what coordinate systems are and how you can use FME to maintain and transform your data’s coordinate systems in an easy-to-digest way, accurately representing the geographical space that it exists within. During this webinar, you will have the chance to:
- Enhance Your Understanding: Gain a clear overview of what coordinate systems are and their value
- Learn Practical Applications: Why we need datams and projections, plus units between coordinate systems
- Maximize with FME: Understand how FME handles coordinate systems, including a brief summary of the 3 main reprojectors
- Custom Coordinate Systems: Learn how to work with FME and coordinate systems beyond what is natively supported
- Look Ahead: Gain insights into where FME is headed with coordinate systems in the future
Don’t miss the opportunity to improve the value you receive from your coordinate system data, ultimately allowing you to streamline your data analysis and maximize your time. See you there!
CNSCon 2024 Lightning Talk: Don’t Make Me Impersonate My IdentityCynthia Thomas
Identities are a crucial part of running workloads on Kubernetes. How do you ensure Pods can securely access Cloud resources? In this lightning talk, you will learn how large Cloud providers work together to share Identity Provider responsibilities in order to federate identities in multi-cloud environments.
An Introduction to All Data Enterprise IntegrationSafe Software
Are you spending more time wrestling with your data than actually using it? You’re not alone. For many organizations, managing data from various sources can feel like an uphill battle. But what if you could turn that around and make your data work for you effortlessly? That’s where FME comes in.
We’ve designed FME to tackle these exact issues, transforming your data chaos into a streamlined, efficient process. Join us for an introduction to All Data Enterprise Integration and discover how FME can be your game-changer.
During this webinar, you’ll learn:
- Why Data Integration Matters: How FME can streamline your data process.
- The Role of Spatial Data: Why spatial data is crucial for your organization.
- Connecting & Viewing Data: See how FME connects to your data sources, with a flash demo to showcase.
- Transforming Your Data: Find out how FME can transform your data to fit your needs. We’ll bring this process to life with a demo leveraging both geometry and attribute validation.
- Automating Your Workflows: Learn how FME can save you time and money with automation.
Don’t miss this chance to learn how FME can bring your data integration strategy to life, making your workflows more efficient and saving you valuable time and resources. Join us and take the first step toward a more integrated, efficient, data-driven future!
In this follow-up session on knowledge and prompt engineering, we will explore structured prompting, chain of thought prompting, iterative prompting, prompt optimization, emotional language prompts, and the inclusion of user signals and industry-specific data to enhance LLM performance.
Join EIS Founder & CEO Seth Earley and special guest Nick Usborne, Copywriter, Trainer, and Speaker, as they delve into these methodologies to improve AI-driven knowledge processes for employees and customers alike.
Building an Agentic RAG locally with Ollama and MilvusZilliz
With the rise of Open-Source LLMs like Llama, Mistral, Gemma, and more, it has become apparent that LLMs might also be useful even when run locally. In this talk, we will see how to deploy an Agentic Retrieval Augmented Generation (RAG) setup using Ollama, with Milvus as the vector database on your laptop. That way, you can also avoid being Rate Limited by OpenAI like I have been in the past.
The "Zen" of Python Exemplars - OTel Community DayPaige Cruz
The Zen of Python states "There should be one-- and preferably only one --obvious way to do it." OpenTelemetry is the obvious choice for traces but bad news for Pythonistas when it comes to metrics because both Prometheus and OpenTelemetry offer compelling choices. Let's look at all of the ways you can tie metrics and traces together with exemplars whether you're working with OTel metrics, Prom metrics, Prom-turned-OTel metrics, or OTel-turned-Prom metrics!
Quality Patents: Patents That Stand the Test of TimeAurora Consulting
Is your patent a vanity piece of paper for your office wall? Or is it a reliable, defendable, assertable, property right? The difference is often quality.
Is your patent simply a transactional cost and a large pile of legal bills for your startup? Or is it a leverageable asset worthy of attracting precious investment dollars, worth its cost in multiples of valuation? The difference is often quality.
Is your patent application only good enough to get through the examination process? Or has it been crafted to stand the tests of time and varied audiences if you later need to assert that document against an infringer, find yourself litigating with it in an Article 3 Court at the hands of a judge and jury, God forbid, end up having to defend its validity at the PTAB, or even needing to use it to block pirated imports at the International Trade Commission? The difference is often quality.
Quality will be our focus for a good chunk of the remainder of this season. What goes into a quality patent, and where possible, how do you get it without breaking the bank?
** Episode Overview **
In this first episode of our quality series, Kristen Hansen and the panel discuss:
⦿ What do we mean when we say patent quality?
⦿ Why is patent quality important?
⦿ How to balance quality and budget
⦿ The importance of searching, continuations, and draftsperson domain expertise
⦿ Very practical tips, tricks, examples, and Kristen’s Musts for drafting quality applications
https://www.aurorapatents.com/patently-strategic-podcast.html
Transcript: Details of description part II: Describing images in practice - T...BookNet Canada
This presentation explores the practical application of image description techniques. Familiar guidelines will be demonstrated in practice, and descriptions will be developed “live”! If you have learned a lot about the theory of image description techniques but want to feel more confident putting them into practice, this is the presentation for you. There will be useful, actionable information for everyone, whether you are working with authors, colleagues, alone, or leveraging AI as a collaborator.
Link to presentation recording and slides: https://bnctechforum.ca/sessions/details-of-description-part-ii-describing-images-in-practice/
Presented by BookNet Canada on June 25, 2024, with support from the Department of Canadian Heritage.
Multimodal Retrieval Augmented Generation (RAG) with MilvusZilliz
We've seen an influx of powerful multimodal capabilities in many LLMs. In this talk, we'll vectorize a dataset of images and texts into the same embedding space, store them in Milvus, retrieve all relevant data using multilingual texts and/or images and input multimodal data as context into GPT-4o.
4. var fileNames = Directory.EnumerateFiles("C:");
foreach (var fileName in fileNames)
{
using (var f = File.Open(fileName, FileMode.Open))
{
Console.WriteLine(fileName + " " + f.Length);
}
}
5. using (var client = new WebClient())
{
string html =
client.DownloadString("http://news.ycombinator.com");
Console.WriteLine(html.Contains("Google"));
Console.WriteLine(html.Contains("Microsoft"));
Console.WriteLine(html.Contains("Apple"));
}
6. Thread.Start BackgroundWorker
Control.InvokeRequired
This often causes us some pain…
… but hey, there’s always threads!
Dispatcher.Invoke
ThreadPool
.AsParallel()
7. Q: What are these threads doing, most of the time?
A: waiting
19. Event Loop Subtleties
Async’s not sync
var hi = null;
$.get("/echo/hi", function (result) {
hi = result;
});
console.log(hi);
// null
20. Event Loop Subtleties
Errors
console.log("About to get the website...");
$.ajax("http://sometimesdown.example.com", {
success: function (result) {
console.log(result);
},
error: function () {
throw new Error("Error getting the website");
}
});
console.log("Continuing about my business...");
21. Event Loop Subtleties
It’s not magic
function fib(n) {
return n < 2 ? 1 : fib(n-2) + fib(n-1);
}
console.log("1");
setTimeout(function () {
console.log("2");
}, 100);
fib(40);
// 1 ... 15 seconds later ... 2
http://teddziuba.com/2011/10/node-js-is-cancer.html
24. What we’ve seen so far has been doing
asynchronicity through callbacks.
25. Callbacks are OK for simple operations, but
force us into continuation passing style.
26. Recurring StackOverflow question:
function getY() {
var y;
$.get("/gety", function (jsonData) {
y = jsonData.y;
});
return y;
}
Why doesn’t it work???
var x = 5;
var y = getY();
console.log(x + y);
27. After getting our data, we have to do
everything else in a continuation:
28. function getY(continueWith) {
$.get("/gety", function (jsonData) {
continueWith(jsonData.y);
});
}
var x = 5;
getY(function (y) {
console.log(x + y);
});
29. CPS Headaches
• Doing things in sequence is hard
• Doing things in parallel is harder
• Errors get lost easily
30. CPS Headaches
Doing things in sequence is hard
$("#button").click(function () {
promptUserForTwitterHandle(function (handle) {
twitter.getTweetsFor(handle, function (tweets) {
ui.show(tweets);
});
});
});
31. CPS Headaches
Doing things in parallel is harder
var tweets, answers, checkins;
twitter.getTweetsFor("domenicdenicola", function (result) {
tweets = result;
somethingFinished();
});
stackOverflow.getAnswersFor("Domenic", function (result) {
answers = result;
somethingFinished();
});
fourSquare.getCheckinsBy("Domenic", function (result) {
checkins = result;
somethingFinished();
});
32. CPS Headaches
Doing things in parallel is harder
var finishedSoFar = 0;
function somethingFinished() {
if (++finishedSoFar === 3) {
ui.show(tweets, answers, checkins);
}
}
33. CPS Headaches
Errors get lost easily
function getTotalFileLengths(path, callback) {
fs.readdir(path, function (err, fileNames) {
var total = 0;
var finishedSoFar = 0;
function finished() {
if (++finishedSoFar === fileNames.length) {
callback(total);
}
}
fileNames.forEach(function (fileName) {
fs.readFile(fileName, function (err, file) {
total += file.length;
finished();
});
});
});
}
47. Promises are Awesome
Cleaner method signatures
Uniform return/error semantics
getAsPromise(url, [data], [dataType]).then(
function onFulfilled(result) {
var data = result.data;
var status = result.status;
var xhr = result.xhr;
},
function onBroken(error) {
console.error("Couldn't get", error);
}
);
79. They clean up our method signatures.
They’re composable, they’re joinable,
and they’re dependably async.
They unify various callback conventions
into something very much like return
values and exceptions.
82. “Coroutines are computer program
components that generalize subroutines
to allow multiple entry points for
suspending and resuming execution at
certain locations.”
http://en.wikipedia.org/wiki/Coroutine
90. Q: OK well… can’t the interpreter do this for me?
A: yes… if you’re willing to wait for the next version of JS.
91. The next version of JavaScript (“ECMAScript
Harmony”) has a limited form of coroutines that can
be twisted to do something like what we want.
92. ECMAScript Harmony generators
function* fibonacci() {
var [prev, curr] = [0, 1];
for (;;) {
[prev, curr] = [curr, prev + curr];
yield curr;
}
}
for (n of fibonnaci()) {
console.log(n);
}
http://wiki.ecmascript.org/doku.php?id=harmony:generators
93. ECMAScript Harmony generators
var eventualAdd = Q.async(function* (pA, pB) {
var a = yield pA;
var b = yield pB;
return a + b;
});
https://github.com/kriskowal/q/tree/master/examples/async-generators
94. ECMAScript Harmony generators
// Can only use yield as we want to within
// Q.async'ed generator functions
Q.async(function* () {
// Talk to the server to get one and two.
var three = yield eventualAdd(getOne(), getTwo());
assert.equal(three, 3);
})();
https://groups.google.com/d/topic/q-continuum/7PWKbgeFA48/discussion
95. ECMAScript Harmony generators
// Given promise-returning delay(ms) as before:
var animateAsync = Q.async(function* (el) {
for (var i = 0; i < 100; ++i) {
element.style.left = i;
yield delay(20);
}
});
http://wiki.ecmascript.org/doku.php?id=strawman:async_functions
96. ECMAScript Harmony generators
Q.async(function* () {
var el = document.getElementById("my-element");
yield animateAsync(el);
console.log("it's done animating");
})();
https://groups.google.com/d/topic/q-continuum/7PWKbgeFA48/discussion
97. So coroutines are a bit of a mess, but
we’ll see how things shape up.
98. Recap
• Async is here to stay
• But you don’t have to dive into callback hell
• Use promises
• Use Q
• Maybe use coroutines if you’re feeling brave