create account

A Beginners Guide to Dart - Control Flow and Low Level Compilation - Part Two by tensor

View this thread on: hive.blogpeakd.comecency.com
· @tensor ·
$33.38
A Beginners Guide to Dart - Control Flow and Low Level Compilation - Part Two
![dart-bird.jpg](https://cdn.steemitimages.com/DQmVf52JbNULs9kr7M9BTaZfgoEtAUdHc9VpVvGpuu4mg24/dart-bird.jpg)

#### Repository
https://github.com/dart-lang/sdk

#### What Will I Learn?

- You will learn the difference between JIT and AOT compilation
- You will learn about Control Flow Structures
- You will learn why Types are important
- You will learn how to make Loops
- You will learn about Boolean Types and Boolean Algebra
- You will learn about Conditions in Dart

#### Requirements
##### System Requirements: 
- [IDEA intellij](https://www.jetbrains.com/idea/) or [Visual Studio Code](https://code.visualstudio.com/) with the Dart [Plugins](https://dartcode.org/)
- The [Dart SDK](https://www.dartlang.org/) 
##### OS Support for Dart:
- Windows
- macOS
- Linux 
#### Required Knowledge
- The Dart SDK
- A dart supported text editor 
- A little time to sit and watch a video and some patience to learn the language

#### Resources for Dart:
- Dart Website: https://www.dartlang.org/
- Dart Official Documentation: https://www.dartlang.org/guides/language/language-tour
- Dart GitHub repository: https://github.com/dart-lang/sdk
- Awesome Dart GitHub Repository: https://github.com/yissachar/awesome-dart
- Pub website: https://pub.dartlang.org

#### Sources:
Dart Logo (Google): https://www.dartlang.org/

#### Difficulty

- Beginner


#### Description

In this Dart video tutorial, we take a much lower level look at some of the topics that were covered in the last tutorial.  We also go ahead and take a look at control flow structures like `if`, `if/else`, `for` and `while`.  We look at conditionals and Boolean types and how they relate to the other control flow structures.  We also talk about why Types are important and the implications of Dart being a static language.  This includes talking about the `dynamic` and `Object` types.   



#### Dart as a Statically Typed Language and its Relation to the Compiler

Up until the release of Dart 2.0, Dart was a dynamically typed programming language.  This meant that when you compiled a Dart program, the types were checked at run-time rather then at compile type.  This also meant that you didn't need to supply a type for a variable, function or object and the compiler would infer these things for you.  When Dart used this method of type checking, it also relied heavily on its Just In Time (JIT) compiler.  As Dart moved into Dart 2.0, the type system was shifted from Dynamic to Static.  With static typing, the types are known at compile type rather then during run time.  This not only boosts the performance of the language significantly, but it also makes the Ahead of Time (AOT) compiler work much better.  Now when you compile a Dart program, the compiler can suggest fixes and give clearer errors to the user. 

    
![compiler-cycle.png](https://cdn.steemitimages.com/DQmVMciptGFyfXdRajYpS7R5LShzuVo64vqxEinnAnWSYjy/compiler-cycle.png)

The image above shows the process by which you can interact with your computer through the Dart programming language.  You write your Dart code and submit it to the compiler and virtual machine.  The Virtual Machine produces machine readable byte-code so that the computer can follow the instructions from the code.  This then produces an output based on what the program is.  Then the user can take this output and change their program accordingly.  Because Dart used to be dynamic, it contains both a JIT and AOT compiler and it also has types that act like dynamic types.  These types are the Object type and the dynamic type.  The dynamic type is a bit of a catch all type, if the compiler can't infer the type and the user doesn't supply one, then it is assumed to be dynamic.  The Object type on the other hand is the type that all other types are derived from. 

### Using Control Flow Structures in Dart

In Dart, because the language is imperative we have access to many of the C-style control flow structures.  This of course, includes structures like `if`, `if/else`, `while`, `do/while`, `switch`, and `for`.  Each of these structures uses a set of logic to allow the program flow to change.  Some allow for code re-use; such is the case for the looping structures and others allow the program to branch from one path to another.  This not only makes it easy for the developer to control the flow of the program but it also helps keep the code easy to reason about.  

![conditionals.png](https://cdn.steemitimages.com/DQmTcGxzWFVezLBJssyJy1yy8HGULA3m2Eek66tR1oMk4br/conditionals.png)

In the image above, we have some examples of `if/else` statements.  Also at the bottom, there is a list of the conditionals that are included in the Dart programming language.  The `if/else` structure allows the user to control the flow of the program based on a conditional statement which appears in the parenthesis.  If the initial conditional evaluates to true, then the first block of code is executed.  If the conditional evaluates to false, then the program skips over the first block of code and moves on to the next block.  If another `if` statement follows the `else` keyword, the compiler checks the conditional statement and follows the same pattern as before. 



The Source Code for this video may be found here: https://github.com/tensor-programming/dart_for_beginners/tree/tensor-programming-patch-1


#### Video Tutorial
<iframe width="560" height="315" src="https://www.youtube.com/embed/vM1gHeQRqjI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

### Curriculum 

- [A Beginners Guide to Dart - Types, Functions, Variables and Objects - Part One](https://steemit.com/utopian-io/@tensor/a-beginners-guide-to-dart---types-functions-variables-and-objects---part-one)

#### Proof of Work Done
https://github.com/tensor-programming
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 49 others
properties (23)
authortensor
permlinka-beginners-guide-to-dart---control-flow-and-low-level-compilation---part-two
categoryutopian-io
json_metadata{"tags":["utopian-io","video-tutorials","steemstem","programming","technology"],"app":"steem-plus-app"}
created2019-02-07 02:29:36
last_update2019-02-07 02:29:36
depth0
children6
last_payout2019-02-14 02:29:36
cashout_time1969-12-31 23:59:59
total_payout_value25.018 HBD
curator_payout_value8.365 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,836
author_reputation87,856,203,149,624
root_title"A Beginners Guide to Dart - Control Flow and Low Level Compilation - Part Two"
beneficiaries
0.
accountsteemplus-pay
weight100
1.
accountutopian.pay
weight500
max_accepted_payout100,000.000 HBD
percent_hbd10,000
post_id79,507,265
net_rshares74,248,876,623,132
author_curate_reward""
vote details (113)
@rosatravels ·
$10.45
Hi @tensor

Thank you again for another great video tutorial.

I like the way you write your post which truly supplement to the video tutorial.

Your thoughts are well organized and flows very well in the tutorial.

Thanks for doing such good work and I have used you as an example for others to follow as they create their video tutorials.  


Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/9/1-1-1-2-1-1-1-1-3-).

---- 
Need help? Chat with us on [Discord](https://discord.gg/uTyJkNm).

[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , ,
properties (23)
authorrosatravels
permlinkre-tensor-a-beginners-guide-to-dart---control-flow-and-low-level-compilation---part-two-20190207t145625881z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["tensor"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/9/1-1-1-2-1-1-1-1-3-","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2019-02-07 14:56:27
last_update2019-02-07 14:56:27
depth1
children2
last_payout2019-02-14 14:56:27
cashout_time1969-12-31 23:59:59
total_payout_value7.915 HBD
curator_payout_value2.534 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length797
author_reputation422,827,447,688,168
root_title"A Beginners Guide to Dart - Control Flow and Low Level Compilation - Part Two"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id79,529,887
net_rshares21,965,240,601,520
author_curate_reward""
vote details (11)
@tensor ·
Thank you @rosatravels.  Yes, I noticed that you had used this tutorial specifically as a reference.  Feel free to reference any of my material in the future.
properties (22)
authortensor
permlinkre-rosatravels-re-tensor-a-beginners-guide-to-dart---control-flow-and-low-level-compilation---part-two-20190207t180541172z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["rosatravels"],"app":"steemit/0.1"}
created2019-02-07 18:05:39
last_update2019-02-07 18:05:39
depth2
children0
last_payout2019-02-14 18:05:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length158
author_reputation87,856,203,149,624
root_title"A Beginners Guide to Dart - Control Flow and Low Level Compilation - Part Two"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id79,537,659
net_rshares0
@utopian-io ·
Thank you for your review, @rosatravels! Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-tensor-a-beginners-guide-to-dart---control-flow-and-low-level-compilation---part-two-20190207t145625881z-20190210t120510z
categoryutopian-io
json_metadata"{"app": "beem/0.20.17"}"
created2019-02-10 12:05:12
last_update2019-02-10 12:05:12
depth2
children0
last_payout2019-02-17 12:05:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length63
author_reputation152,955,367,999,756
root_title"A Beginners Guide to Dart - Control Flow and Low Level Compilation - Part Two"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id79,660,163
net_rshares0
@steem-plus ·
SteemPlus upvote
Hi, @tensor!

You just got a **5.29%** upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in [here](https://steemit.com/@steem-plus) to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.
properties (22)
authorsteem-plus
permlinka-beginners-guide-to-dart---control-flow-and-low-level-compilation---part-two---vote-steemplus
categoryutopian-io
json_metadata{}
created2019-02-07 17:28:24
last_update2019-02-07 17:28:24
depth1
children0
last_payout2019-02-14 17:28:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length433
author_reputation247,952,188,232,400
root_title"A Beginners Guide to Dart - Control Flow and Low Level Compilation - Part Two"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id79,536,237
net_rshares0
@steem-ua ·
#### Hi @tensor!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-a-beginners-guide-to-dart---control-flow-and-low-level-compilation---part-two-20190207t153022z
categoryutopian-io
json_metadata"{"app": "beem/0.20.18"}"
created2019-02-07 15:30:24
last_update2019-02-07 15:30:24
depth1
children0
last_payout2019-02-14 15:30:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length285
author_reputation23,214,230,978,060
root_title"A Beginners Guide to Dart - Control Flow and Low Level Compilation - Part Two"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id79,531,565
net_rshares0
@utopian-io ·
Hey, @tensor!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-a-beginners-guide-to-dart---control-flow-and-low-level-compilation---part-two-20190207t154937z
categoryutopian-io
json_metadata"{"app": "beem/0.20.17"}"
created2019-02-07 15:49:39
last_update2019-02-07 15:49:39
depth1
children0
last_payout2019-02-14 15:49:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length588
author_reputation152,955,367,999,756
root_title"A Beginners Guide to Dart - Control Flow and Low Level Compilation - Part Two"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id79,532,392
net_rshares0