Moses  Jast

Moses Jast


Iterators. And Why You Should Use Them (More)

Welcome back to another video. A couple of days ago I was with a friend of mine that is currently doing an internship at one of the big banks here in Canada. And we were looking over some code that his manager wanted him to optimize.

Find me elsewhere:

Late Bloomers by Rich Karlgaard:
Disclaimer, this is an affiliate link

The code was interacting with Apache Spark and was using too much memory (500,000 entries).
After taking a look at the code with no knowledge of Spark, I proposed they use an iterator to reduce unnecessary data copying.
My friend looked at me like I was speaking a different language.

So I will be talking about what iterators are, their advantages, why they aren’t used more and finally go through my solution with you.

Iterators are an abstraction over iterations. For example, traditionally, if we wanted to go through all the elements in an array one by one, we would have an index that goes from 0 to length - 1. Then we would access the array elements using it.

But this makes the code a little more complicated than it needs to be; if we only want the element and not the index, then the index is unnecessary. Iterators allow us to just access the elements.
Now at first, that doesn’t seem very useful. And you’re right.

But when the data structure gets more complex, say a hashmap and you need to traverse all the keys.
The keys could be stored in a binary tree, in which case you will need to create your own traversal algorithm to get all the keys. With iterators, all that is done for you and all you need to do is loop over it with a for loop.
Another solution to this is that you can do the traversal and store the keys in an array. The problem with this approach is that it takes up additional memory; we now have 2 copies of our keys. Iterators on the other hand, does not do any copying, and only goes over the keys one by one.

The last thing is iterators work really well with functional programming features, such as map, reduce, filter, fold, etc. These tools reduce the amount of loops and edge cases you need to code out yourself, saving you time and headaches.

So if there are all these advantages, why are they not used very often?

The first reason I think, is because its not taught extensively in school. Professors rarely go over iterators in detail because a for loop or traversal algorithm will work. And they probably want you to use those traversal algorithms that is being taught instead of using code that’s already built for you. So the most you’ll use in school are probably elemental for loops. Unless you take a course on functional programming where they teach you Haskell.

The second reason is because many languages being taught does not support iterators very well. Some popular languages taught in school are Python, Java and C. Python being used to introduce students to programming. Java being used to introduce OOP to students. And C being used to introduce systems programming and memory management.
Out of these, only Python’s iterators are easy to pick up and use on the fly. C does not have any facilities for iterators unless you make your own.
Java iterators are very lacking in features. And with the release of Java 8 in 2014, developers can finally use functional programming features with Java streams. But stream’s ergonomics are still poor; being added so late to the language, switching between streams and iterators can be non-trivial, which discourage developers from using them and just use a for loop instead.

Compare that to more modern languages like Javascript, Scala, and my favourite, Rust. There are many functions available to their iterators.
Just take Rust iterators:

  • Any: returns true or false if any of the elements in our iterator satisfies a predicate
  • Chain: combines two iterators into one that goes through the first one, then the second
  • Count: counts the number of elements in our iterator
  • Enumerate: adds indices to the elements
  • Filter: filter out all elements that do not satify a predicate
  • Find,Min,Max
  • Partition: splits the iterator into two collections that is defined by a predicate
  • Skip: skips the first n elements
  • Take/Take While: take the first n elements, keep taking until the element doesn’t satisfy a predicate
  • Zip: combines two iterators into one that goes through both together
    More at:

Hope you enjoyed the video!

Apricity by lukrembo
Michikusa by PeriTune (Licensed under

#iterators #apache spark

Iterators. And Why You Should Use Them (More)

Why Use WordPress? What Can You Do With WordPress?

Can you use WordPress for anything other than blogging? To your surprise, yes. WordPress is more than just a blogging tool, and it has helped thousands of websites and web applications to thrive. The use of WordPress powers around 40% of online projects, and today in our blog, we would visit some amazing uses of WordPress other than blogging.
What Is The Use Of WordPress?

WordPress is the most popular website platform in the world. It is the first choice of businesses that want to set a feature-rich and dynamic Content Management System. So, if you ask what WordPress is used for, the answer is – everything. It is a super-flexible, feature-rich and secure platform that offers everything to build unique websites and applications. Let’s start knowing them:

1. Multiple Websites Under A Single Installation
WordPress Multisite allows you to develop multiple sites from a single WordPress installation. You can download WordPress and start building websites you want to launch under a single server. Literally speaking, you can handle hundreds of sites from one single dashboard, which now needs applause.
It is a highly efficient platform that allows you to easily run several websites under the same login credentials. One of the best things about WordPress is the themes it has to offer. You can simply download them and plugin for various sites and save space on sites without losing their speed.

2. WordPress Social Network
WordPress can be used for high-end projects such as Social Media Network. If you don’t have the money and patience to hire a coder and invest months in building a feature-rich social media site, go for WordPress. It is one of the most amazing uses of WordPress. Its stunning CMS is unbeatable. And you can build sites as good as Facebook or Reddit etc. It can just make the process a lot easier.
To set up a social media network, you would have to download a WordPress Plugin called BuddyPress. It would allow you to connect a community page with ease and would provide all the necessary features of a community or social media. It has direct messaging, activity stream, user groups, extended profiles, and so much more. You just have to download and configure it.
If BuddyPress doesn’t meet all your needs, don’t give up on your dreams. You can try out WP Symposium or PeepSo. There are also several themes you can use to build a social network.

3. Create A Forum For Your Brand’s Community
Communities are very important for your business. They help you stay in constant connection with your users and consumers. And allow you to turn them into a loyal customer base. Meanwhile, there are many good technologies that can be used for building a community page – the good old WordPress is still the best.
It is the best community development technology. If you want to build your online community, you need to consider all the amazing features you get with WordPress. Plugins such as BB Press is an open-source, template-driven PHP/ MySQL forum software. It is very simple and doesn’t hamper the experience of the website.
Other tools such as wpFoRo and Asgaros Forum are equally good for creating a community blog. They are lightweight tools that are easy to manage and integrate with your WordPress site easily. However, there is only one tiny problem; you need to have some technical knowledge to build a WordPress Community blog page.

4. Shortcodes
Since we gave you a problem in the previous section, we would also give you a perfect solution for it. You might not know to code, but you have shortcodes. Shortcodes help you execute functions without having to code. It is an easy way to build an amazing website, add new features, customize plugins easily. They are short lines of code, and rather than memorizing multiple lines; you can have zero technical knowledge and start building a feature-rich website or application.
There are also plugins like Shortcoder, Shortcodes Ultimate, and the Basics available on WordPress that can be used, and you would not even have to remember the shortcodes.

5. Build Online Stores
If you still think about why to use WordPress, use it to build an online store. You can start selling your goods online and start selling. It is an affordable technology that helps you build a feature-rich eCommerce store with WordPress.
WooCommerce is an extension of WordPress and is one of the most used eCommerce solutions. WooCommerce holds a 28% share of the global market and is one of the best ways to set up an online store. It allows you to build user-friendly and professional online stores and has thousands of free and paid extensions. Moreover as an open-source platform, and you don’t have to pay for the license.
Apart from WooCommerce, there are Easy Digital Downloads, iThemes Exchange, Shopify eCommerce plugin, and so much more available.

6. Security Features
WordPress takes security very seriously. It offers tons of external solutions that help you in safeguarding your WordPress site. While there is no way to ensure 100% security, it provides regular updates with security patches and provides several plugins to help with backups, two-factor authorization, and more.
By choosing hosting providers like WP Engine, you can improve the security of the website. It helps in threat detection, manage patching and updates, and internal security audits for the customers, and so much more.

Read More

#use of wordpress #use wordpress for business website #use wordpress for website #what is use of wordpress #why use wordpress #why use wordpress to build a website

Why Use WordPress? What Can You Do With WordPress?
Coy  Roberts

Coy Roberts


Javascript ES6 Iterators: Complete Guide on Iterables and Iterators

Javascript iterators is a new concept of ES6 in which it processes each of the items in the collection, which is a pervasive operation. Iterators are a new way to _loop _over any collection in JavaScript.

They were introduced in ES6 and have become popular since they are widely JavaScript provides several ways of iterating over the collection, from simple for loops to map() and filter() Iterators and  Generators bring the concept of iteration directly into the core language and provide a mechanism for customizing the behavior of loops.

Iterators in Javascript

An iterator is a new concept of ES6. An Iterator is an object that lets us iterate through an Array, an Object, a String, or even custom Objects.

The Iterator allows us to effectively loop over a collection of objects like an arraystringobjects, or other data structures.

The most common Iterator in Javascript is the Array iterator, which returns each value in the associated array in sequence.

#javascript #javascript es6 #iterators #iterables

Javascript ES6 Iterators: Complete Guide on Iterables and Iterators
Alayna  Rippin

Alayna Rippin


Iterable and Iterators In Dart


In this article, we are going to talk about Itrables and how it uses the iterator to access the elements sequentially.

What is an iterable

It’s a **collection, **A collection of values, or “elements”, that can be accessed sequentially each element at a time.

_For Example, _List and Set classes are both Iterable, as are most classes in the dart:collection library.

Each element of the iterable is accessed by getting an Iterator using the iterator getter and using it to step through the values. Stepping with the iterator is done by calling Iterator.moveNext, and if the call returns true, the iterator has now moved to the next element, which is then available as Iterator.current. If the call returns false, there are no more elements.

We can also iterate over the elements of an Iterable using the for-in loop construct, which uses the iterator getter behind the scenes.

For example, you can iterate over all of the keys of a Map, because Map keys are iterable.

Image for post

Note:_ Although Map doesn’t implement Iterable, you can get Iterables from it using the Map _keys_ and _values_ properties._

Advantages of iterables

Besides being able to use them with a for-in loop, an iterable gives you access to lots of other features.

For example, Because of some methods available, such as mapwhereany, and takeWhile etc.

The _Iterable_ class provides two methods that you can use to verify conditions:

_any()_: Returns true if at least one element satisfies the condition.

_every()_: Returns true if all elements satisfy the condition.

#iterables #dart #collection #iterators #lists

Iterable and Iterators In Dart

What are Iterables and Iterators in Python

While writing an article about Generators, I realized that though iteration, iterable and iterator are so commonly used in programming; there is a certain degree of confusion around them. It’s crucial to understand the underlying concept for a better implementation. This is going to be a short and quick article to help us determine what is an iterable and what is an iterator.


  • In layman’s language it is ‘repeating steps’.
  • Iteration in programming is a repetition of a block of code for a certain number of times.
  • This can be achieved by using loops.


  • Iterable is an object which can be looped over or iterated over.
  • e.g. List, Tuple, Set, Dictionary, File.
  • In simpler words, iterable is a container which has data or values and we perform iteration over it to get elements one by one. (Can traverse through these values one by one)
  • Iterable has an in-built dunder method iter. A simpler way to determine whether an object is iterable is to check if it supports iter. How? Using dir( ), it returns the list of attributes and methods supported by an object.


  • Iterator is an iterable object with a state so it remembers where it is during iteration.
  • e.g. Generator
  • Iterator performs the iteration to access the elements of the iterable one by one. As it maintains the internal state of elements, iterator knows how to get the next value.
  • Iterators can only move forward using _next _. It cannot go back or cannot be reset.
  • Iterator supports in-built dunder methods _iter _and next.

#iteration #python #data-science #programming #iterators

What are Iterables and Iterators in Python
Monique  Larson

Monique Larson


ES6 Deep Dive: Iterables & Iterators

Looping over data structures in JavaScript ES6

Today I am going to take a closer look at the new ways we can navigate data structures in the 6th edition of the ECMAScript standard — commonly referred to as ES6. Among all the upgrades and syntactical sugar added to JavaScript in 2015, there is also now support for iterators and iterable objects. These not only allow for less code when iterating over arrays and strings, but support new collections, like maps and sets, and the creation of custom objects and iterators for them. You could think of these as similar to (but not the same as) the looping that happens in a for-in loop on steroids.

Okay, you might be wondering, what even are iterators and iterable objects? An iterable is a sequential data structure that can be iterated over. Iterables can also have their own access method, which defines its iterator. This allows iterables to be publicly accessible. An iteratoris like a pointer that traverses the collection in a particular way. As we will get into in a bit, these new custom iterators in ES6 can loop through more than just a simple array.

This is a lot of jargon that I will break down in a few minutes with an example. But for starters, let’s take a look at the default use of ES6 iterators in the for-of loop.

The for-of loop

In ES5 and before, we’re used to seeing for and while loops to iterate over arrays or strings. Now, with ES6, we can hop around an array or a string without having to set the parameters for these loops. The for-of loop by default knows how to iterate over these data types sequentially:

#iterables #for-of-loop #iterators #javascript #es6

ES6 Deep Dive: Iterables & Iterators