Tuesday, December 30, 2014

Map of Dart learning subjects and their values, exercise for cloning Anagram example.

When cloning / theming dart-html example: anagram, I wanted to make it like Dart-learning course, I made this map of casual Dart keywords, that popped to my mind, and setted some time / effort values to them.  These values present 1-9 numbers of time / effort / importance, of ao. learning subject... just my opinion.

Here is original anagram HTML dart example in gitHub
I'm now on phase 2 / 10 on this cloning, and next should put this map in use; instead of ..what..?  and how..?   Long way to go..

here are  all tutorial samples:   https://github.com/dart-lang/dart-tutorials-samples

// Dart learn subjects and their values
Map dartLearnSubjects = {
          'await' : 6,  'analyzer' : 1, 'as' : 2, 'assert' : 4, 'abstract' : 3,
          'build' : 02, 'bool' : 0, 'button' : 5,

          'continue' : 2,  'client' : 5, 'comment' : 1, 'css' : 3, 'class' : 7,
          'case' : 2, 'const' : 3, 'closure' : 5, 'cascade' : 3, 'constructor' : 4,

          'default' : 3,  'do' : 2, 'datetime' : 3, 'dynamic' : 3, 'double' : 2,
          'debugger' : 2,
          'equality' : 2,  'extend' : 3, 'export' : 3, 'error' : 5, 'element' : 5,
          'external' : 9, 'enum' : 4,
          'factory' : 8,  'final' : 2, 'for' : 2, 'future' : 9, 'function' : 7,
          'generics' : 6, 'get' : 4,

          'hint' : 1, 'html' : 8,
          'implement' : 3,  'io' : 8, 'int' : 3, 'import' : 3, 'iterate' : 4,
          'intl' : 2, 'isolates' : 5, 'immutable' : 3, 'interface' : 3,

          'json' : 3, 'joke :)' : 0, 'joker :)' : 0, 'join?' : 0,
          'key' : 2,
          'lazy loading' : 2, 'label' : 3, 'library' : 5, 'list' : 2,

          'metadata' : 3,  'mixin' : 9, 'math' : 3, 'main' : 1, 'map' : 2,
          'methods' : 2,
          'new' : 2, 'null' : 1, 'num' : 2,
          'objcet' : 3,  'output' : 1, 'or?' : 1, 'operators' : 05, 'on--?' : 3,

          'parameter' : 4,  'parse' : 5, 'pub' : 7, 'print' : 1, 'part' : 2,
          'problems' : 1,
          'query' : 4, 'queue' : 2,

          'rune' : 2, 'run?' : 2, 'random' : 2, 'return' : 2,
          'server' : 8,  'static' : 5, 'sdk' : 5, 'string' : 1, 'set' : 2,
          'system?':4, 'switch' : 1, 'super' : 4, 'symbol' : 2, 'scope' : 2,

          'this' : 3,  'throw' : 3, 'task' : 1, 'type' : 7, 'try' : 2,
          'typedefs' : 6, 'typecast' : 6, 'todo' : 2,

          'unordered' : 0,
          'void' : 1, 'value' : 1, 'var' : 3,
          'web sql' : 7,  'web audio' : 7, 'while' : 1, 'worker' : 4, 'with' : 3,

          'x1' : 0, 'y1' : 0, 'yield?' : 0, 'z1' : 0

//TODO  howTo :  Print a map :)
dartLearnSubjects.forEach((k, v) { print('$k, $v'); });
You can run above code putting it directly inside main function.
void main()  {
print('.. hello here we go!! ');
  //  code here

Saturday, February 15, 2014

Quick tips for Dart newcomers (to be continued...)

- Abreviations- Know Internet Slang- ALL Wikipedia stuff about web, server, programming... - Basic idea and control flow of programming.

At the beginning of 2014 DartLang is still a work in progress. It do not yet have all the goodies that older lanquages have, but it is gonna go far. Dart may not be the best-laquage-possible to-bebuilt-now, BUT it is best, that can survive now, and to get great bunch of developers behind it.

Writing this in Nexus... numbering... must fix it in laptop. (lost in transition lol)

Put jre in jre folder in your dart-program folder, if you don't use path variable. if problems, read:
Read ALL here: dartlang.org AND read it again. Consider keeping notes in Evernote, Google Keep, Springpad, GTask or...

Choose short names for your main data folders, you use them daily, you learn them. EXAMPLE here. (coming)

Trust editor tools; ctrl-tab for advices on subject. You do not have to memorize all

Trust Google search. try: dart foreach print ...xx
DartEditor keyboard shortcuts: choose, wich ones you need from HERE (coming)
" Play with Darteditors windows, until you got Happy state.
LEFT: Files, under: Object inspector. Middle: edit, Under: Problems, output, progress, breakpoints aso... Right: Debugger, Outline"

(...) Use Google spreadsheets to scetch, analyze and plan your programs and their classes, functions and variables, and their naming conventions.

Take time and plan NAMES for you variables and classes: MEANING.

Love your lanquage. Dont be angry to other languages. Trust it. Trust the community. It will develope; every week something new.

Make a cheatSheet for usual stuff. HERE sample.(coming) Until Darteditor gets templates.

Dont start to build a bridge until you see, where is other end. Build first a small bridge.

Give Dart editor time to analyze sometimes. Prevent analyzing in other folders, when you want to work.

Start writing, when you have clear picture in your mind about the reality (or tale) which you want to program,

Plan variables, which you need when you BUILD and plan your prog.

Make BASE library, which is for all your programs. Make (local)BASE library, which is for you current work.

Make MyPackage_Use -program which all the time uses and tests your package.

Dont use cryptic names, which you do not remember later.


Be ready to change names, if they do not feel good. Refactoring!!
Close editor, when you make BIG changes in folder structures. Destroying Metadata, darteditor -folder, is not a bad idea.

Trust dart documentation.... Be with community. use Github and StackOverFlow.

Ready? So sit, take a little cup... start writing and let the ideas come to reality....

(to be continued.. and modified..)

Originally pubished in etdart.blogspot.fi

Sunday, February 9, 2014

Collection of small Pub packages, for learning purposes, best suited to study Dartlang.

Collecting links to Pub packages, in ordxer to find those, which are best suited for learning purposes, and to present different Dart properties.
- Trying to avoid using BIG environmets, like Polymer, Angular, Hop, Bot aso.

game_loop http://pub.dartlang.org/packages/game_loop This main loop is responsible for processing inputs from keyboards, mice, gamepads, and time. Also, the main loop manages browser state, e.g., pointer lock and fullscreen.

mailer https://pub.dartlang.org/packages/mailer Compose and send emails from Dart. Supports file attachments, HTML emails and multiple transport methods.

solitaire http://pub.dartlang.org/packages/solitaire Solitaire card game.

Next I have not tested:

chess http://pub.dartlang.org/packages/chess A port of chess.js to Dart. chess.dart is a library for legal chess move generation, maintenance of chess game state, and conversion to and from the formats FEN and PGN.

bulls_eye http://pub.dartlang.org/packages/bulls_eye Bulls-Eye is an Dart-IO Extension to build up an WebServer (like node.js and Express)

image http://pub.dartlang.org/packages/image Provides server and web apps the ability to load, manipulate, and save images with various image file formats including PNG, JPEG, GIF and WebP.

more http://pub.dartlang.org/packages/more Various extension libraries that make Dart a better place. More Dart — Literally

mongo_dart http://pub.dartlang.org/packages/mongo_dart MongoDB driver for Dart

eventable http://pub.dartlang.org/packages/eventable simple event system for implementing model->event->view design pattern.

streamable http://pub.dartlang.org/packages/streamable a library of helpful custom stream candies

geo http://pub.dartlang.org/packages/geo A set of geographic's functions

dartminer http://pub.dartlang.org/packages/dartminer A Bitcoin miner with Dart language.

stillshot http://pub.dartlang.org/packages/stillshot A simple, bare-bones static site generator with markdown and mustache templating support.

color http://pub.dartlang.org/packages/color A simple Dart package exposing a Color class which can be used to create, convert, and compare colors.

chrome http://pub.dartlang.org/packages/chrome An library for accessing the Chrome APIs in a packaged app or extension.

ace http://pub.dartlang.org/packages/ace High performance code editor for the web.

dartcoin http://pub.dartlang.org/packages/dartcoin A Bitcoin library for Dart. Pud-test release.

lawndart http://pub.dartlang.org/packages/lawndart An easier way to access storage APIs in the browser.

intl http://pub.dartlang.org/packages/intl internationalization and localization facilities, including message translation, plurals and genders, date/number formatting and parsing, and bidirectional text.

watch http://pub.dartlang.org/packages/watch Simple file watcher

Just 20 links now... most of them I have not tested.

To be continued.... most likely..    published originally in  etdart.blogspot.fi

Monday, February 3, 2014

My note: Dart. Functions. A bunch of instructions, which executes sequentially.

Class. You can pick class methods one at a time, and execute it.

Function. wikipedia; Function: (subroutine)

In computer programming, a subroutine is a sequence of program instructions that perform a specific task, packaged as a unit.


Commands are fullfilled in sequential order. Nothing can stop functions execution. "When a function that returns a Future is invoked, two things happen:

The function queues up work to be done and returns an uncompleted Future object immediately.
Later, when the value is available, the Future object completes with that value or with an error."

spec 1.1 Functions abstract over executable actions. Because Dart is optionally typed, we cannot guarantee that a function that does not return a value will not be used in the context of an expression. Therefore, every function must return a value. A return without an expression returns null.
A function declaration is a function that is neither a member of a class nor a function literal. Function declarations include library functions, which are function declarations at the top level of a library, and local functions, which are functions declarations declared inside other functions. Library functions are often referred to simply as top-level functions.

If a function does not declare a return type explicitly, its return type is dynamic.

From: https://www.dartlang.org/articles/event-loop/
Once a Dart function starts executing, it continues executing until it exits. In other words, Dart functions can’t be interrupted by other Dart code.

A closure is a function object that has access to variables in its lexical scope, even when the function is used outside of its original scope. Functions can close over variables defined in surrounding scopes.

In Dart,functions are objects, just like strings and numbers are objects. A typedef, or function-type alias, gives a function type a name that you can use when declaring fields and return types. A typedef retains type information when a function type is assigned to a variable.

My note: Nowhere (or where?) in Dart doc is clearly said "Function is a collection of elements/code, which are all evaluated in sequence"
".. bunch of logic".

Published originally  in  etdart.blogspot.fi   

Sunday, February 2, 2014

Understanding Dart Futures and Isolates; their different way to work in time factor

Different cheme to use time factor to enhance programs effeciency.

Some clips gathered from dartlang.org pages:
Understanding Isolates:

Isolate api: https://api.dartlang.org/docs/channels/stable/latest/dart_isolate.html

Note: A Dart command-line app can run code in parallel by creating isolates. (Dart web apps can’t currently create additional isolates, but they can create workers.) Isolates don’t share memory; they’re like separate apps that communicate with each other by passing messages. With the exception of code that an app explicitly runs in additional isolates or workers, all of an app’s code runs in the app’s main isolate. For more information, see Use isolates or workers if necessary, later in this article.

How many isolates should you use? For compute-intensive tasks, you should generally use as many isolates as you expect to have CPUs available. Any additional isolates are just wasted if they’re purely computational. However, if the isolates perform asynchronous calls—to perform I/O, for example—then they won’t spend much time on the CPUs, so having more isolates than CPUs makes sense.


Dart replaces shared-memory threads with isolates
Concurrency is great, but shared-memory threads are error prone. Dart implements an isolate system for safer concurrent programming. Isolates are “isolated memory heaps” that can be spawned from a top-level function or URI. Isolates communicate by passing messages, which are copied before they are sent.
Understanding Futures:
Future is here: https://api.dartlang.org/docs/channels/stable/latest/dart_async.html

https://www.dartlang.org/articles/event-loop/#use-isolates-or-workers-if-necessary :

Fun facts about Future:
The function that you pass into Future’s then() method executes immediately when the Future completes. (The function isn’t enqueued, it’s just called.)
If a Future is already complete before then() is invoked on it, then a task is added to the microtask queue, and that task executes the function passed into then().
The Future() and Future.delayed() constructors don’t complete immediately; they add an item to the event queue.
The Future.value() constructor completes in a microtask, similar to #2.
The Future.sync() constructor executes its function argument immediately and (unless that function returns a Future) completes in a microtask, similar to #2.

The event queue has entries from both Dart (futures, timers, isolate messages, and so on) and the system (user actions, I/O, and so on).
My conclusion:
Summary: Futures are: Asked my frend to do it, he returns with result .
I started the process, I get a response in due course.
Are part of (BIG) async.api
Isolates are: Outside workers to enhance our work. And to bring safety.
Are in (small) dart:isolate library api
Command line... parallel
Concurrent programming, independent workers similar to threads

Futures and Isolates work with time factor differently, to enhance programs effectiveness.

Questions arise: to be continued....