DART on Googlen avoimen lähdekoodin ohjelmointikieli, joka toimii verkkosivuilla ja servereissä, ja jolla voi JavaScriptiä paremmin hoitaa suurten verkkosovellusten koodaamisen. DART kielen kehitys aloitettiin 9/2011 ja 1.0-versio kielestä julkistettiin loppuvuodesta -2013. Nyt jo on olemassa lähes valmiit työkalut Chrome selainta varten. Blogger-blogien pitäjiä varten saamme ehkä kiintoisia Gadgetteja sivupalkkeihin ja muuta toiminnallisuutta verkkosivuille.
TÄMÄ blogi sisältää pääosin omia pohdintojani ja muistiinpanoja, eikä se varmaankaan tuo kovinkaan paljon uutta DART-kielen opiskeluun. Materiaali on pääosin KOPIOITU :( Dartlang-sivustoilta, josta kannattaa KÄYDÄ TARKISTAMASSA kielen viimeiset syntaksit.

lauantai 15. helmikuuta 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.

Logic.

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..)

sunnuntai 9. helmikuuta 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..
 .

maanantai 3. helmikuuta 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. 


https://www.dartlang.org/docs/dart-up-and-running/contents/ch02.html
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.

Typedefs

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".

sunnuntai 2. helmikuuta 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

https://www.dartlang.org/articles/event-loop/#use-isolates-or-workers-if-necessary
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.


http://programming.oreilly.com/2013/05/8-dart-features-those-fat-cats-dont-want-you-to-know.html 

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/docs/dart-up-and-running/contents/ch03.html#ch03-futures

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

Fun facts about Future:
  1. 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.)
  2. 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().
  3. The Future() and Future.delayed() constructors don’t complete immediately; they add an item to the event queue.
  4. The Future.value() constructor completes in a microtask, similar to #2.
  5. 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....
.