Skip to main content

Byzantine Programming Languages: Dart

 Dart,  Byzantine Languages pt. 1

Darts



Why is Dart a Byzantine Language?


Dart wasn't born with types. It was born to replace JavaScript (JS) but wasn't any better than JS when it was born, because very quickly ES6 made the improvements Dart had over JS disappear. Then TypeScript gained ascendance as types help get a handle on large JS databases. So types were added to Dart... and Dart seemed to be ready for the graveyard of fringe languages like Pony, Prolog, and Idris.

But Google didn't give up on it. Dart kept evolving but like a Bazar, it evolved by adding things like it added types. So when you look at Dart you see many design decisions in the language are in conflict. It's a packed language, with lots of things. Its syntax was extended to use types and it's lightly based on C, quite possibly the most popular language historically but also one that largely succeeded in-spite of its syntax not because of it.


What's good about Dart?


The VM. The virtual machine that runs the language is fast and great. And it was chosen as the basis for Flutter a toolkit that allows rapid development of mobile apps both for Android and iOS while sharing the same code base (mostly). Notice that its main strengths are not the language per-se but its virtual machine.


Byzantine features

The Byzantine nature of the language can be seen in the names of its types. It's got String, RegExp but then num, int, and double. It's got List, Set, and Error but bool. There is no uniformity of types. Additionally, a type like Map which is a hash-map contains elements of the MapEntry type, clearly showing this was added on, not part of the design of the types.

Some features come from C but seem out of place in a modern language. It uses the semicolon as a terminal thing, but only sometimes. This inheritance from C is one of my most hated features. Then it also has the abysmal C-style-for-loops which JS is moving away from. They're terrible because a small typo will make it not work as intended. In a C-style-for-loop you have to declare a variable to count the number of times the loop is going to go, then set a condition for termination, then the increment. It's boilerplate the language itself should take care of for the programmer but in Dart, you have to watch your for-loops like a hawk. Thankfully there are comprehensions for collections but they don't have the same flexibility as the for-loop.

My favorite byzantine feature is the double dot operator (..). Some functions like sort for example change the object in place and return void (nothing basically) so you can't chain a method because void isn't the object you want to call the next method on. Well, Dart's got a solution for that, it has a double dot operator that passes the original object rather than the resulting object. However, this is operator is put in front of the call, so you put "..sort()" in order to get the original object sorted rather than void returned. If you want to chain something after that though, you'll need to wrap the first part in parenthesis, so the double dot operator returns the original object before continuing. This is an interesting solution in that it works but it looks horrendous on the code base making it hard to read at first and definitely doesn't look like anything in other languages.

Weird features that are cool.


Not everything unusual in Dart is bad, but it's good to know what they are because previous experience in other languages can trip you up.

I like that Dart allows trailing commas in Lists, in fact, it's the preferred way to write them. How many times have I deleted the last element in an Array and then caused a crash because the last element had a comma and that language didn't know how to handle that. Dart's got you covered.

Instantiating an object doesn't require the 'new' keyword. Simply call the class name (which is also the name of the constructor) feed it the parameters and boom. Its simplicity makes you want it in other languages.


The absolutely worse thing about Dart, though:


Dart lacks a REPL, or an interactive command-line utility. This means it's hard to figure out all the nooks and crannies of this language.

Photo by Marc A on Unsplash



Comments

Popular posts from this blog

Building my own home.

I've decided. I want to build my own home. There is something special about building your own things. I built a desk for my tiny room when I first moved to L.A. My room was so small that I had to sit on the bed to use the computer so I build a high desk so I could sit on the bed and work on the computer. My roommate Trentity helped me cut the ply-wood to the right side. I still have that desk. It now sits on the living room covered by a cloth hiding the surplus of costume parts my current roommate Sean uses in his creations. Learning to build and fix things continue. And the feeling of satisfaction from fixing even small things is great. So a few years ago I heard on the NPR program the Story about a couple of educators that moved to a tent in their back-yard so they could rent their house and afford to send their kids to college. They had a special type of tent called a yurt and cooked and showered in an RV they had parked next to it. I thought I could do that. Housing in Lo

Contrasting Styles of Writing: English vs. Spanish

There is interestingly enough a big difference between what's considered good writing in Spanish and English . V.S. Naipul winner of the 2001 Nobel prize for literature publish an article on writing . In it he emphasizes the use of short clear sentences and encourages the lack of adjectives and adverbs. Essentially he pushes the writer to abandon florid language and master spartan communication . This is a desired feature of English prose , where short clipped sentences are the norm and seamlessly flow into a paragraph. In English prose the paragraph is the unit the writer cares about the most. This is not the case in Spanish where whole short stories (I'm thinking this was Gabriel Garcia Marquez but maybe it was Cortázar) are written in one sentence. Something so difficult to do in English that the expert translator could best manage to encapsulate the tale in two sentences. The florid language is what is considered good writing in Spanish but unfortunately this has lead t

My Fake Resume

Inspired by the over aggrandized bio of Joseph Rakofsky I want to write my own. If you don't know who he is; Joseph Rakofsky is a lawyer who earned a mistrial for a criminal client due to his (alleged) incompetence as reported on the Washington Post . There has been quite a few commentaries on his "Streisand-house" approach of suing all the bloggers and even the Washington Post and American Bar Association for reporting his (alleged) ineptitude. ("Streisand-house" is what happened to Barbara Streisand who wanted to have a picture of her mansion removed from the internet and she sued to have it removed. Unfortunately suing requires the filing of public documents with a picture of her house. The lawsuit had the direct opposite effect it intended. Everybody now could see legally, since it was a public document, a picture of her house.) But all that internet gossip aside I'm most impressed by his resume. Here is a quote from the website: Prior to stud