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.
Näytetään tekstit, joissa on tunniste DartCode. Näytä kaikki tekstit
Näytetään tekstit, joissa on tunniste DartCode. Näytä kaikki tekstit

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

torstai 26. joulukuuta 2013

Just working; Future, event, Stream

Small code samples.. and again losing hours to stupid things...
Futures, events, strems...


& Planning new article...BIG!!   but lost appetitte on it, when losing five minutes when
trying to subscribe to my blog.  That article.. it might become great.. i hope.

In my Wordpress blog I use to write 10 articles at a time ( FuckWordressNewStyle_01... FuckNewWordPressStyle_10)  then you can fast take one of these, to write, what you want to.

Now I was close to do the same in Blogger.   lol  I DONT want to lose time.
.

sunnuntai 30. kesäkuuta 2013

Tämä blogi ja DART-opintojeni edistyminen. DART M5 vaihe. Linkkejä.

Tämän blogin tarkoitus siis on vain dokumentoida Dart-kielen syntyvaiheet ja oma oppimiseni. Tällä ei ehkä ole paljon annettavaa kielen opiskelijalle.  Kun 1.0 versio tulee, ei taida olla enään mitään syytä ylläpitää tätä.. kai..

DART linkkejä:
https://github.com/jpedrosa/reluzir/blob/master/learn_dart_in_15_minutes/learn_dart_in_15_minutes.dart   Hieno DART-ohjelma joka käy läpi ominaisuuksia ja rakenteita.

http://www.dartlang.org/docs/tutorials/indexeddb/   Upea esitys DART Indexed-DB aiheesta.  Hienot kuvat, todella havainnollinen esitys.

STREAMS  ja  EVENTS  ovat aika keskeinen aihe DART-kielessä.  Opiskeluni keskittyy Web-UI:n lisksi aika paljon siihen.  Missä vaiheessa olen?  Ehkä voisi sanoa, että.. 80%,  se on hyvin varovainen arvio... Käytännön ohjelmointitaitoni on varsin alkeellinen, teoriatietoa ja muistitietoa sensijaan on...  niiden yhdistäminen käytäntöön on sitten eri asia.
http://www.dartlang.org/slides/2013/06/dart-streams-are-the-future.pdf  diasarja,
Asynchronous programming in Dart, Streams are The future.

http://dartlangfr.net/dart-cheat-sheet/   DART-lunttilappu.  Olisi syytä tehdä itselleen tällainen nelipalstainen, printattava, missä olisi tärkeimmät rakenteet.  Aloin jo tekemään sitä kynällä...


DART EDITORI:   Editorissa on syytä tarkkailla oikeaa alakulmaa:  Tämä, "Building Workspace" vaihe voi joskus kestää aika kauan.  Hakemistoissa voi määritellä: "Älä analysoi", jolloinka editorilla voi työskennellä paremmin jonkun muun koodin kimpussa.  Äkkinäinen voi muuten tuskastua DART:in toimimattomuuteen.  Edellinen uudistus teki DART-editorista huikean nopean,  se oli tämä  M5 vaihe.  Todella upeata.

Asiat rullaavat vakaasti eteenpäin; Uuutta materiaalia tulee viikoittain huikeat määrät ja kysymykset StackOverflowssa lisääntyvät.    Koskahan  1.0 versio tulee, ja millaiset uudet apuvälineet siinä on mukana?   Jännän äärellä ollaan.
.

maanantai 18. maaliskuuta 2013

Tietokanta keskustelua ja linkkejä Dart ohjelmointikielessä.

Se on kaikki tietokantaa..  it's all about data.

Hyvä ja pitkä ihmettely tietokantojen puuttumisesta Dart:ista.
https://groups.google.com/a/dartlang.org/d/msg/misc/Uv05GvFTsLU/UsMABfztF4sJ

Hyvä kooste tietokanta-elementeistä ja ohjelmista Dartissa. Linkkejä...
https://groups.google.com/a/dartlang.org/d/msg/misc/Uv05GvFTsLU/wcz8hF4anhUJ

Tietokanta on juuri se alue, joka minua kiinnostaa eniten.
.

perjantai 8. maaliskuuta 2013

Yksinkertainen DART ohjelmointi esimerkki, Luokkien periyttäminen. Extending DART Classes.


DART esimerkki, luokkien periyttäminen.  Extending DART Classes
Tarkista koodin viimeinen versio linkistä:
https://github.com/heiklap/Simple-DART-Examples/blob/master/ape_man.dart

//  apeman.dart   5.3.2013.   simple dart example.
//  for presenting how dart classes are created, extended and instantiated.
//  developing this still further...

// This class exists simply for others to extend
class Ape {
  String apeFood = "Eating juicy banana...  ";
  String apeJob  = "Scratching my back..... ";
  bool wannaMoreBananas = true;
  num weightKg = 28;
}

//  Human class learns something from apes and gives it forward..
//  class human do not get instantiated (used) in this example..
class Human extends Ape {
  String humanThinking = "What do others think about me..?  ";
  num weightKg = 78;
 }

class HumansWife {        //  This class is here just to celebrate international Womans Day  8.3.
  num weightKg = 67;      //  Will use this class in later programs
  String OuSheIs = "Ou!  She Is so...   Eternal Inner Beauty...  ";
}

// this class will have an instance AND it uses properties
// inherited from other classes
class Programmer extends Human {
  String progJob = "Solving problems. And producing new and more complicated problems...";
  num weightKg = 102;                 //  and counting  :(     LOL!!
}
/*
  main is where every DART program begins to execute.  TYPE Void is strictly a note to You and your
  programmer friends.  It tells that main is not intended to return any value.
  If there is num or String instead of void, THEN main would return a value.
*/
void main() {
  print("Hei, Apina!!  Terve, Ihminen!  Moikka, ohjelmoija!!  ");

// here Programmer class will be instantiated with keyword: new, to p.
// note, that class type: Programmer is with BIG P. Its instance is with SMALL p.  !!
  var p = new Programmer();

// Class programmer, p. !! uses some ancient ape skills witch it inherited..
// BUT NOTE:  all these  (p.apeFood and p. apeJob..)  are now p. :s properties!!
  print(p.apeFood);                                     //  Eating juicy banana...
  print(p.apeJob);                                      //  Scratching my back.....
  if (p.wannaMoreBananas) print('I Wanna More Bananas !!');     //  I Wanna More Bananas !!

 // Programmer class have also inherited all of human properties..
  print(p.humanThinking);                               //  What do others think about me..?

  // this programmer do not have many his OWN skills yet,
  // He thinks only his Job.  Should give him more properties...
  print(' You asking what I am doing?? ');
  print(p.progJob);                      //  "Solving problems. And producing new and more
                                                   //   complicated problems..."
  print(p.weightKg);                     // ( WTF!!  This must be a BUG!!)  Stomach overflow..

  print("===   End of program   ===");
}

/*   Output of program should be this:
Hei, Apina!!  Terve, Ihminen!  Moikka, ohjelmoija!!
Eating juicy banana...
Scratching my back.....
What do others think about me..?
I Wanna More Bananas !!
 You asking what I am doing??
"Solving problems. And producing new and more complicated problems..."
===   End of program   ===

NEXT:   Maybe some functions and more properties...
*/

torstai 27. syyskuuta 2012

Simple DART DEMO, Yksinkertainen DART esimerkki ohjelma

// Simple DART demo to show use of Control Flow-structure and varables
 // that give it some control control. Done with Editor 12784 27.9.2012
 // This is gonna be changed during coming days... Not happy with it..
 // Also here is simple class and its instance in main structure.
 // When buildin first DART programs it is better to begin with these small ones...
// Output of this is seen in editor Output windows


#import('dart:html');

var jobs   = ['+1-Coffee','+2-Play Computer','3-Read Posts','4-Window watching','5-Hmmm'];
num jCount = jobs.length;
num jNow   = 0;


class Listjobs  {
//   not so elegant...

  num doJobs()   {
  num     _i      = 0;
  for (_i = 0; _i < jCount; _i++){
    print('Job To do now:   ');
    print(jobs[jNow]);
    print('OK.');
    jNow = jNow + 1;
  }
  return(jNow);
  }
}


void main() {

print('listing jobs...  $jCount');

var myListJobs = new Listjobs();
myListJobs;
myListJobs.doJobs();

  print(' Lets DART AGAIN!!  ');
}


In try dartlang  http://try-dart-lang.appspot.com/   this seems to collect 5 errors,
but in my editor it runs without errors...

keskiviikko 22. elokuuta 2012

Yksinkertainen DART-koodi Videon esittämiseksi ja siihen liittyvä keskustelu


    Dart keskustelussa on yksinkertainen esimerkki videon esittämisestä:
    show a simple video using VideoElement
      #import('dart:html');

      void main () {
      var videoClip = new VideoElement();
      videoClip.src = "http://slides.html5rocks.com/src/chrome_japan.webm";
      videoClip.height = 100;
      videoClip.width = 100;
      videoClip.on['canplay'].add((_) {
      videoClip.play();
      });
      document.body.nodes.add(videoClip);
      }
Pastasin tämän koodin editoriin:  10993  ja se toimi. 


Bob Nyström esitti paremman version:   (joka tosin ei toimi minulla...  piti palata edelliseen )
    Vanhempi editori vaati päivitystä, ennenkuin suostui ajamaan koodin. 

sunnuntai 17. kesäkuuta 2012

Hieno DART-Examples blogi. Hyviä DART esimerkkejä.

Brandon Donnelson on tehnyt erinomaisen ja havainnollisen blogin.  Tässä kopio siitä Google+:aan kirjoittamastani jaosta.  Jos olisin puoli vuotta sitten saanut tällaista kamaa ja säännöllisen verkkoyhteyden, niin minähän jo osaisin DARTia.  Ehkä.

http://c.dart-examples.com/home 




Dart-Examples blogi.  Rakenteista verkko-ohjelmointia. #Ohjelmointi 
Brandon Donnelson on yhdistänyt oivalla tavalla tekstiinsä kielen syntaksit ja havainnolliset esimerkit; tuloksena on selkeälukuisia blogikirjoituksia, joiden avulla aloittelijankin on helppo perehtyä DART-kieleen.  Blogi Dart-examples näyttää laajenevan vauhdilla, ja olen todella tyytyväinen sen sisältöön, ja siihen, että vihdoin osuin löytämään tämän blogin. Kaikkea en ole ehtinyt edes vielä lukea.  
     Editorin asettelu sisennyksineen ja väreineen tekee lukemisen erityisen hauskaksi.  Ruudulla on myös tämä TRY -linkki, jonka avulla koodia voi käydä kokeilemassa käytännössä.  
     Dartlang on erinomainen sivusto, mutta tätä Donnelsonin blogia on vaikea sivuuttaa, kun esim. valitaan oppimateriaalia DART-kielen kurssille tai itseopiskeluun.  
.

maanantai 27. helmikuuta 2012

Variables in DART, DartLang spec 0.07.


This is from Dartlang spec 0.07 and i brought this gtext to my blog for to be able to analyze this when i am travelling and cant use my computer.  So; DART EasyToUse with Mobile.



Variables

Variables are storage locations in memory.
variableDeclaration:
     declaredIdentifier (',' identifier)*
   ;

initializedVariableDeclaration:
     declaredIdentifier ('=' expression)? (',' initializedIdentifier)*
   ;

initializedIdentifierList:
     initializedIdentifier (',' initializedIdentifier)*
   ;

initializedIdentifier:
     identifier ('=' expression)?
   ;
declaredIdentifier:
     finalVarOrType identifier
   ;
finalVarOrType:
     final type?
   | var
   | type
   ;
A variable that has not been initialized has the initial value null.
A final variable is a variable whose declaration includes the modifier final. A final variable can only be assigned once, when it is initialized, or a compile-time error occurs.

A static variable is a variable that is not associated with a particular instance, but rather with an entire library or class.
A variable that is marked both static and final must be initialized to a compile-time constant or a compile-time error occurs.

Why tie together two orthogonal concepts like static and final by requiring the use of constants? Because we do not want a language where one tends to define expensive initialization computations, causing long application startup times. This is especially crucial for Dart, which is designed for coding client applications.

One time initializations using constants should incur negligible cost at run time.
If a variable declaration does not explicitly specify a type, the type of the declared variable(s) is Dynamic, the unknown type.

A top-level variable is implicitly static. It is a compile-time error to preface a top level variable declaration with the built-in identifier static.  It is a compile-time error if a top level variable is initialized with an expression that is not a compile-time constant.

So this was it, directly from Dartlang spec 0.07.  

Notes come here soon:

Concurrency and Isolates in DART.

Tässä lyhyessä tekstinpätkässä on paljon asiaa.  Sen lisäksi siinä on useita termejä, joihin aloittelija helposti kompastuu.  Tämä on DartLang spec 0.07.


Concurrency

Dart code is always single threaded. There is no shared-state concurrency in Dart. Concurrency is supported via actor-like entities called isolates.

An isolate is a unit of concurrency. It has its own memory and its own thread of control. Isolates communicate by message passing. No mutable state is ever shared between isolates. Isolates are created by spawning.


So this was directly from dartlang spec 0.07

Kirjoitan tästä aiheesta tähän postaukseen vielä lisää.  Tarkempi analysointi vie hieman aikaa, nyt kerään materiaalia muista aiheista...

keskiviikko 15. helmikuuta 2012

DART uutisia, linkkejä, työkaluja ja ohjelmointi-projekteja

Dart projekti etenee ja tuottaa nyt kiintoisaa materiaalia monella taholla. Dart produces very interesting material now in many places.
Dart Team wekly newsletter http://news.dartlang.org/2012/02/dart-teams-weekly-digest.html

Building Web Apps? Check out our Field Guide
http://www.html5rocks.com/webappfieldguide/toc/index/
This comprehensive guide provides an introduction to many of the skills and best practices you need to build modern web apps. This field guide is designed to help you create great user experiences in your web apps.

10 Dart projects from the community We put out a call to learn what the community is building, and we heard some really interesting projects. Dart is being used for UI frameworks, games, cryptography, 3D, MVC frameworks, and more!
http://news.dartlang.org/2012/02/10-dart-projects-from-community.html 

Ja muistakaa myös;
http://ajlopez.wordpress.com/2012/02/14/tdd-links-news-and-resources-2/
AjLopez kerää uskomattoman määrän erilaisia ohjelmointiin liittyviä linkkejä.

 Minä seuraan edelleen tiiviisti DART-kielen syntyprosessia. Jopa niin tiiviisti, että se häiritsee varsinaista kielen opiskelua. MUTTA tämä on ainutkertainen tilaisuus. Uusia ohjelmointikieliä tekniikan huipulle syntyy vain harvoin. Siksi opiskelu on tämän tutkimuksen rinnalla toisarvoinen. Siinä ei pieni viivästyminen haittaa.
Kaipaisin materiaalia, jonka voi helposti lukea mobiili-laitteella, siis puhelimessa. Kielellisiä rakenteita, luokkia, funktioita jotka voi esittää parilla ruudulla. Minun olisi syytä tehdä tästä aloite keskusteluun; se olisi minun 2-pence, minun panokseni. Olisi helppo jakaa kavereille vinkkejä ja itsekin opiskella bussilla matkustellessa.
Opiskeluni siis junnaa 50% vaiheessa, mutta projeksi silti etenee. Tää on kivaa!

maanantai 6. helmikuuta 2012

Kuinka Dartboard sovellusta käytetään suoraan omalta verkkosivulta


    Keskustelu ryhmässä oli tarjolla tällainen koodi; katsotaanpas...
    <html>
    <head>
    <title>Example Dartboard</title>
    </head>
    <body>
    <code class="codes">
    main() {
    print('Hello, Dart!');
    }
    </code>
    <script type="text/javascript" src="http://try.dartlang.org/
    dartboard.dart.app.js"> </script>

    </body>
    </html>

perjantai 18. marraskuuta 2011

Uusi DART-editori 1584 valmis ladattavaksi.



DartWatch on hieno blogi, joka seuraa tiiviisti dart-kielen kehitystä. 
Tämä editorista kertova uutinen jukaistiin siellä: 


A new Dart Editor build (1584) is available for download. Changes include:
  • New menu command produces significantly smaller JS using DartC –optimize
  • For the Clock sample, 6.7M JS file during development –> 127k JS using new “Tools > Generate Optimized Javascript…” command, less than 2% of original size
  • Omnibox search now includes cross-file text search
  • Properly show getters and setters in Outline view
  • Sort private members to bottom of outline view
  • Updated New Application template to use dart:html (rather than dart:dom)
  • Enable Run button only when HTML file is present
  • Open Declaration from #source(…) now properly opens source in subfolder
  • Open Declaration cannot find window or document
  • Cache artifacts across sessions to improve first compile after session start
  • Code Completion enhancements and fixes
  • Added Mac OSX 32 bit build
  • Compiler improvements





lauantai 15. lokakuuta 2011

Ensimmäiset rivini Dart-ohjelmaa DartBoardilla

Näin tuotat omalla sivullasi ensimmäiset rivisi omaa Dart-koodiasi.

main() {
  var paikka = 'Strömsinlahti';
  var Tervehdys = 'Moikka!';
  print('Hello, ${paikka}!');
  var toimipiste = 'Rantakahvila';
  print('${Tervehdys}, ${toimipiste}');
}

TUOTOS:

Hello, Strömsinlahti!
Moikka!, Rantakahvila

Koodit ovat sivustosta;  http://www.dartlang.org/docs/getting-started/
"Follow this tutorial to modify and run small Dart programs inside your browser window, using the Dartboard app."

Tällä DartBoard taululla voit siis kokeilla pieniä Dart-ohjelmia omassa selaimessasi.

No, tämähän on jo hyvä alku.

keskiviikko 12. lokakuuta 2011

Hello World! Testing first Dart programcode

Seuraava koodinpätkä on peräisin osoitteesta:   http://www.dartlang.org/  Se siis toimii DarthBoard nimisessä api:ssa.  Kun koodi on suoritettu, se palaa dartland.org-sivulle.  Näin minulle ainakin kävi, eipä siis hämmästytä, jos äkkiä pompahdat toiselle verkkosivulle.  Kopioituna tämän blogin sivulle, tuo koodi ei näköjään kuitenkaan toimi.  Se vaatii tuon DartBoardin.  

Examples of Dart code
The Dart code below is inside an app called Dartboard. If you click the Run button at Dartboard's upper left—go ahead, you know you want to—you'll see the expected output (Hello, Dart!) at the bottom.
1
2
3
main() {
print('Hello, Dart!');
}

What next?

.