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

lauantai 28. joulukuuta 2013

DartEditor; pakettien tuonti Pub:sta ja niiden käyttö.

Dart pakettien käyttö ohjelmissa on kaksivaiheinen prosessi:

Ensin ne tuodaan yaml -tiedoston avulla PUB-paketinjakelijasta käyttäjän ko. packages -hakemistoon.

Sitten ne otetaan .dart ohjelmassa käyttöön (tuodaan) import-lausekkeella.


Using Dart-packages in programs is two-phase process:

First you bring them from Pub to your packages-folder with .yaml -file.
then you use them with import-clause.

perjantai 27. joulukuuta 2013

DartEditor Keyboard Shortcuts 12-2013, from Pop-Up window in Editor

Dart Editor KeyBoard Shortcuts 12/2013
Find And ReplaceCtrl+ Shift + Fa
InlineAlt + Shift + Ia
RefreshF5a
Open Class HierarcyF4a USE
Show Key AssistCtrl + Shift + La USE
Content AssistCtrl + SpaceHelp
Extract Local VariableAlt + Shift + LLearn
Extract MethodAlt + Shift +MLearn
Quick FixCtrl + 1Learn
RedoCtrl Shift ZLearn
Rename RefactoringAlt Shift RLearn
Run ScriptCtrl + Shift + F1Learn
Save AllCtrl + Shift + SLearn
Search BoxCtrl + 3Learn
Show in FinderCtrl Alt Shift FLearn
Toggle BreakpointCtrl + Shift + BLearn
Open GlanceCtrl + F Learn __
CloseCtrl + WMenu
Manage LaunchesCtrl + Shift + MMenu
Reanalyze SourcesCtrl Alt Shift B --Menu
Who need these __NoNee
Activate EditorF12NoNeed
Backward HistoryAlt+ LeftNoNeed
Maximize Active Viev of EdCtrl + MNoNeed
Close allCtrl + Shift + WNoUse
Format ElementCtrl + Shift + RNoUse
Forward HistoryAlt+ RightNoUse
Generate JavaScriptCtrl + Shift + GNoUse
Next EditorCtrl + F6NoUse
Previous EditorCtrl + Shift + F6NoUse
Quick Switch EditorCtrl + ENoUse
PropertiesAlt + EnterObious )
No need to learn< easy to rememberObviou
CopyCtrl + CObvious
CutCtrl + XObvious
DeleteDeleteObvious
New FileCtrl + NObvious
Open Existing folderCtrl + OObvious
PasteCtrl + VObvious
RunCtrl + RObvious
SaveCtrl + SObvious
Select AllCtrl + AObvious
UndoCtrl + ZObvious

In this table is information from DartEditors keyboard-shortcyts, as they are in the end of year 2013.  Checked two times... but errors may still be...
I use them, want to learn, No-Use, or use menu instead.  Many are obvious...
For the case you do not want to memorize them all....
Check, if they are changed.  And be thankful co's this was not easy to do.. lol..
Maybe in SDK-folder there is easy copy of this information...


Here it is in Google-Docs for everybody to see and comment.
.

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

perjantai 20. joulukuuta 2013

Pub dartlang path dependencies, how to use them locally without publishing in pub

Nice: with path dependencies I can locally tie 4 my packages together, so that they can use each others resources during developement, without publishing in Pub. One of them is kinda "base_library_routines",  one totally independent, and 2 closely tied-together-programs. 
Path: C:/Users/Public/myproject/base_library  is quite obvious.(not to me ) points to folder, where .yaml-file is. 

Now I can produce much reusable code. Changes in one package are immediately visible in other packages. 

http://pub.dartlang.org/doc/dependencies.html#path-packages

This was not right away obvious to me.. tried many paths..  lol 

Now seems it rquires still some get/build..  something missing from one of them...Not clear, in which order this should be done.

baselib   resources, that other packages use
prog_new, prog_old   are tight tied together and are meant to use each others resources,
they are html / browser based.  

prog_poly   is polymer based, and it is not clear to me, how I make it a package,

.yaml file is place, where I announce these path-dependencies, in overvew, and/or source-screen. 
This is the way I will work with all my coming programs. 
.

torstai 19. joulukuuta 2013

Some notes: what I know about Pub package manager:

Dartlang Pub is complicated system.. for beginner..  I have problems in start phase..
Most problems are my own errors: Testing Pub without reading/understanding instructions. Sometimes may also be, that Pub is out of order/anfunctional, when I do tests...
So I collect some poits, to deepen my knowledge of Pub and to solve my -dawo problems.
Check original text.. http://pub.dartlang.org/ this all is subject to changes!! 
-------------------------------------------------------------------------------------------------
What do I want to ask? 
1.  Is Publish the only way to push new version to my local package-folders?
2.  Does Pub use my local folders this way:
- Web, to start/rule package & main / entrypoint?
- Lib, to actual create packages content?
- Example, for others to use my package easily?
- Build, to show me, how my package looks out?
This, because global picture of folders, is still little unclear to me...
Question: is my package (which others use) a combination of web & lib folders??
--------------------------------------------------------------------------------------------------
http://pub.dartlang.org/doc/  Getting started:   My comments on red. 
reuse existing Dart code and bundle your Dart apps and libraries 
Import one or more libraries from the package:
If your app wants to use pub packages, it needs to be a package too.
An application package only consumes packages but doesn’t itself get reused. 
To turn your app into an application package so it can use other packages, you just need to give it a pubspec
The simplest possible pubspec just contains the name of the package.
Most packages just define a single entrypoint whose name is the same as the name of the package.      !!!!!!!!!
import '../../lib/parser.dart';
But that’s a pretty nasty relative path. 
When you are ready to upgrade your dependencies to the latest versions, do:  Ugrade. 
YES.   All seems quite clear. ===================================
http://pub.dartlang.org/doc/dependencies.html  Dependencies. 
 For library packages, you specify the range of versions of that package that you allow. 
allows any version, and looks it up using the default source, which is this site itself.   MEANS WHAT?  Ou!! it means pub-html-page... :)
the “live” version of that package on your local file system.
Relative paths are allowed and are considered relative to the directory containing your pubspec.
you cannot upload a package to pub.dartlang.org if it has any path dependencies in its pubspec.
Git & bVersion constrains.. Clear!!  Dev dependencies:  Clear.

http://pub.dartlang.org/doc/pubspec.html  Pubspec Format.. Quite clear.
Each time you publish your package, you will publish it at a specific version. Once that’s been done, consider it hermetically sealed: you can’t touch it anymore.

http://pub.dartlang.org/doc/package-layout.html      Package layout conventions
Many packages are library packages: they define Dart libraries that other packages can import and use. These public Dart library files go inside a directory called lib.
Most packages will define a single library that users can import. In that case, its name should usually be the same as the name of the package,
 Entrypoints—Dart scripts with a main() function—cannot go in lib.    !!!!!!!
much of a package’s code is internal implementation libraries that should only be imported and used by the package itself. Those go inside a subdirectory of lib called src
you should never import from another package’s lib/src directory. 
Web files:    Also, and this is important, any Dart web entrypoints (in other words, Dart scripts that are referred to in a <script> tag) go under web and not lib
Command-line apps:   can be run directly from the command line. These can be shell scripts or any other scripting language,   .... put it in a directory named bin.
Example:  Standalone example programs that use your package, of course!
This is an important place to consider using package: to import files from your own package. That ensures the example code in your package looks exactly like code outside of your package would look.
Tool: Mature packages often have little helper scripts and programs that people run while developing the package itself. Think things like test runners, documentation generators, or other bits of automation.

Assets and Transformers  http://pub.dartlang.org/doc/assets-and-transformers.html  The pub serve and pub build commands use transformers to prepare a package’s assetsto be served locally or to be deployed, respectively.  Ou!!  Seven screens... I leave this in side now.. hope not need this ever... BUT: I can put my empty folder structure here!

Commands:   Build:  generates the assets for the current package and all of its dependencies, putting them into a new directory named build.
Pub also automatically compiles your Dart application to JavaScript using dart2js.
Cache:  lists information about packages currently downloaded into your system cache
Get:  Check later... must be all clear...
Publish;  All files in your package will be included in the published package, with the following exceptions:  If you aren’t using Git, all “hidden” files (that is, files whose names begin with .


To be on the safe side, pub publish will list all files it’s going to publish for you to look over before it actually uploads your package. GREAT!! I CAN "ALMOST" PUBLISH...
Options
--dry-run or -n

With this, pub goes through the validation process but does not actually upload the package. This is useful if you want to see if your package meets all of the publishing requirements before you’re ready to actually go public.  
Upgrade:   gets the latest versions of all the dependencies   TL:DR  lol 
Serve: This command starts up a development server, or dev server, for your Dart web app.
Hope never need this... 
So going now to "try" publish.. to 0.0.02.