Category Archives: Programming

What the heck is Xamarin?

Xamarin on the Rise

By mid-2014 Xamarin is starting to pick up some traction in the market. There are more Xamarin jobs (paying very well) then there are programmers to do the work. So I get a lot of questions from recruiters and students about “What the Heck is Xamarin”?

xam-x-plat

So What the Heck Is Xamarin?

If you are a Microsoft shop C# is likely your language of choice. And Visual Studio your choice of IDE. Xamarin is two things:

  • a Visual Studio add-on so you can program Windows, Mac, Android or iOS apps* in C#.
  • a IDE for the Macintosh and Linux so you can Windows, Mac, Android or iOS apps in C#. (Visual Studio does not run on Mac or Linux)
  • an alternative to learning Objective-C and XCode on Mac or Eclipse and Java on Mac or Linux or Windows to program Android apps.

* even if you only use Visual Studio on Windows to build iOS Apps, you will need a Mac that will be used to compile your iOS code.

so-why-choose-us

So Why Choose Xamarin?

There are several compelling reasons

  • You are a Microsoft shop and a C# Zealot you have to build Android and/or Mac and/or iOS apps.
  • Learning Eclipse, Objective-C, Swift, XCode scares you to death. A Mac or Linux machine is not your cup of tea.
  • You did not like the price tag of my favorite tool  Rad Studio from Embarcadero Technologies  to do this although it’s C++ orientation (Delphi is available too, a language invented by the C# creator Anders Hejlsberg).
  • Because Microsoft told you too! (don’t laugh that has worked for them for decades with developers).

So these are all legit reasons, and they are why Xamarin’s star is rising.

why-not-hey-archiekeep-calm-and-choose-wisely-33

So Why Not Xamarin?

There are good reasons to not use Xamarin as well.

Rad Studio from Embarcadero Technologies may be more expensive (almost 5 x the cost fully loaded) but ITS MORE EXPENSIVE FOR A REASON.

  • XCode and SWIFT rock for iOS programming.
    • If you are a C# programmer get out of your comfort zone and try an Angel you don’t know, and don’t waste too much time griping its not the devil you know.
    • Even Objective C is nice compared to C++. So while it is a bit dated it is a nice superset of C and C++.
    • More frameworks and 3rd party libraries and open source libraries available than with Xamarin.
  • Eclipse and Java is multi-platform (and while it is worse than VStudio with the right add-ins it can be quite nice) and learning new stuff is always fun unless you are stubborn.
    • Its not THAT hard its just difference. Hard is macro-assembler or VI. Eclipse is easy.
    • More frameworks and 3rd party libraries and open source libraries available than with Xamarin.
  • You have Simpler Cloud and iOS and Android needs that can be met with
    • PhoneGap
    • Icenium

The above frameworks and code-generation tools do a LOT of the work for you and are built on HTML 5 and JavaScript instead of low-level code with all that implies good and bad.

 

xamarincodesharing-500x297

How do I learn it? What does it cost?

Well the good news is there are not many books, so you won’t go broke buying every Xamarin book. The bad news is since there are not many books you better be great at Googling and teaching yourself. As for the cost at the time of this writing the Xamarin IDE for Linux or Mac costs about $83/month (about $1,000 a year).

  • Renowned author Charles Petzold wrote a book that you can get a free preview edition of here @
    Petzold-Book-232x300
  • The Xamarin cookbook by Dimitris Tavlikos focusing on iOS is good @
    ios-Cookbook

If you have any favorite Xamarin books or learning resources, please share it in a comment so we can add it here.

My Xamarin predictions

crystal-ball-future-quote

Xamarin is young and with 30+ years in the computer field and business/marketing prediction field I can safely give you a roadmap of Xamarin’s future:

  • Microsoft will buy it or clone/steal it.
  • If MS clones it, it will take the form of a Mac and Linux VStudio first with a FREE Xamarin add-in before they ditch it for a “built in house” replacement.
  • The cross platform Framework may catch up to Rad Studio from Embarcadero Technologies in a few years.
  • Basically the need for a MAC will go away because they will invent a Virtual Cloud Mac that transparently compiles it for you via WebService.

These predictions were made on November 2014 and will be updated as they occur, or something happens that proves they will never occur.

Embarcadero Rad Studio: What the Heck Is It?

 

rad-studio-xe7-collage

What the Heck is Rad Studio?

Embarcadero Rad Studio which is a IDE and several Framework that allows you to write one set of code that compiles and runs on

  • Windows Desktop app
  • Mac Desktop app
  • iPhone app
  • iPad app
  • Android phones and Tablet
  • Blackberry
  • Windows Store 8
  • Cloud website

One Code Base for many Platforms and Devices

Yes really one code base for all those platform, yet generating native code on each. It also

  • handles WebServices and Json and connecting server databases to Tablets and Phones better than any MS tool I know
  • Integrates with Interbase an obscure but very powerful light database (very old and respected has been around over 30 years) that competes with mySQL, SQL server Compact, SQLlite in the embedded front.
  • Offers a C++ or Delphi edition (Delphi was invented by Anders Hejlsberg inventor of Turbo Pascal, Turbo Modula and C#)
    Anders_Hejlsberg
    Anders Hejlsberg

I went to a 6 hour demo one Saturday in mid November 2013 and it was amazing to watch. It truly offers a really lightweight set of tools and Frameworks to build core code that runs on many platforms, then write any platform specific code or APIs as needed when the Framework does not offer something.

keep-calm-and-choose-wisely-33 so-why-choose-us

Why Use Rad Studio?

  • You want quick results and you need to support more devices and platforms than Xamarin or other cross platform Frameworks support.
  • Efficiency of code size, database size, compiled code size matters, i.e. you are very old school and want your redistributables as small as possible in Disk and RAM consumption.

index

Why Not Use Rad Studio?

  • You are a language bigot so you think C# or Java is the ONLY language you will code in so C++ 11 or Delphi are something you just are not comfortable doing. There are cross platform frameworks for Java and C# so you are welcome to go that way. I plan a round up of them soon in a future blog entry.
  • Some people despite the power and elegance of Interbase may feel SQL Lite or other Databases are a better choice. In that case use them, heck use SQL Server or Oracle it has superb support for client devices talking to server databases via Web Services in a very easy way. Even can generate the Web Services if you are too lazy or just don’t have time to write them.
  • You think $5,000 is too much for a multi-device programming tool and would rather use open source frameworks or “roll your own”. Well if so go for it, but remember your programming time translates to a chunk of your life and high billing rates for client, so as the Japanese say “sometimes the FREE thing is the most expensive” or “some times the short cut is the long way”.

Happy Coding on all your Platforms – Charles Carroll

me-whiteshirtandtie

DRAFT – JavaScript + Frameworks – get with the program

Brief History of Javascript

Javascript was invented for an ancient browser called Netscape. It was cloned by every major browser after it – Internet Explorer, FireFox, Opera, Chrome, etc. It was looked down as not a real language since it was:(

  • (then) Not fully compiled. Thus must be slow*. (now) Very very fast. Compilers exist (CoffeeScript, TypeScript)*
  • (then) It was loosely typed. (now) Compilers provide strong typing.*
  • (then) It ONLY ran in a browser. (now) Browsers took over the world. App Frameworks support Javascript too.*
  • (then) It was partially OO and fully prototyping based. OO purists were aghast. (now) Compilers provide full OO.*
  • (then) It lacked some real tools languages had: IDEs, unit testing. (now) Several IDEs. Several Unit Test frameworks.*
  • (then) It was attached to awful HTML which was going to die anyway, that had NO PROGRAMMING and NO separation of presentation from content like it’s father SGMIL. (now) CSS and HTML 5 fix all that. And PS HTML is alive and thriving despite many attempts to replace it which all died.
  • (then) It had no way to store or serialize data or transfer server and cloud data. (now) XML and JSON (preferred)  for serialization.
  • (then) HTTP was chunky and all page changes required the whole page round trip to the server (now) Ajax and several other partial page refresh technologies are easy.
  • (then) Visual Basic syntax was the rage and Javascript was not. (now) C# and Java brought C++ syntax back and devastated VB so Javascript required less learning for C#/C++/Java programmers.

Then the Internet did not go away. And browsers did not go away (although Apps arrived as an extra channel besides browser to get to the cloud data) in fact people preferred them to Desktop apps. And a rich cloud started growing up.

 

BTW ironically developers rarely EVER use the (now) bullet points in their apps. They were just a convenient excuse to not learn Javascript.

And suddenly not doing Javascript was fatal to a developer’s career.

Some Javascript Humor

Javascript is serious business. So here is some more lighthearted Javascript links

The rise of Javascript Frameworks vs. Libraries

Javascript was adopted quickly by hardcore C++ and C# and Java programmers. Plus open source hippies and capitalists. Those types lost passion for libraries a decade ago, so focused on a few frameworks that duked it out to become THE framework: JQuery, Dojo, Angular, etc.  because they were super familiar with Separation of Concerns, and time was limited because they snobbishly ignored it for over a decade and a half, the frameworks did not attempt to be the one true framework.

  • So a lazy smart Javascript developer can use 1 or more frameworks without causing any clashes.
  • The frameworks are so tiny every framework  added up together took a tiny fraction of what the Java and C# frameworks took up, so combining was an easy decision.
  • They invented minification and bundling which really helped the browsers compress code, and allow browsers and servers to be able to more readily cache multiple frameworks and components. Vstudio ASP.net MVC did this all automagically.

People needed to write very little Javascript code and get BIG results and libraries would not get them there. Frameworks got them there in style.

What are some Frameworks good developers use, and why?

Do you have to use them all? Absolutely not. Should you consider them and know when to use them, and when not. And promise not to be a “Devil I know is better than Angel I don’t know” JS Framework bigot. One of those people that once they choose one framework use confirmation bias to dismiss the value of every other framework.

  • Angular.js – making MVC (Model-View-Controller) style framework coding with Javascript on client and server much easier if you code the right patterns. It is much much more extensive than every other free framework here, and has a lot of power and a steeper learning curve because of the scope of features. Read more @ https://angularjs.org/.
  • Backbone (depends on underscore.js and JQuery) brings models/views/events to JS programming in a minimalist way to reduce learning curve and “lock in” and interop well with other frameworks, Get it/read about it @ http://backbonejs.org/
  • Bootstrap is not really a Javascript technology, it is all about simplifying CSS, but since so many JScripters use it at least learn about Bootstrap and consider it.
  • D3 – Data Driven Documents and Transformation focused on CSS, SVG and HTML 5. Get it @ http://d3js.org/ and there are a ton of plug-ins @ https://github.com/d3/d3-plugins.
  • Dojo is the favored big framework before Jquery. IBM and others blessed it for clients impressed by name dropping. A ton of Javascript components are built on top of it including Graphing and Charting and custom tags and much more. Get it @ http://dojotoolkit.org/download/.
  • Ember – focused on creating new markup tags and templates that look simple on client, but interact with server transparently. Easy transfer of data to/from server.  Routing to easily control where data is fetched to and from the server. Get it @ http://emberjs.com/.
  • ExtJS/Sencha (depends on YUI) – It is focused on providing a bunch of ready made widgets/controls/custom tags and easy commands to interact and manipulate them. It started out as free under the name ExtJS but evolved into 2 commercial products, and combined with several other open source and commercial products (all towards providing high end HTML 5 and Touch Support and Responsive and multiple device support) to improve it’s versatility. Get at http://www.sencha.com/products/complete/. It costs money but is well worth it on the projects I used it.
  • Handlebars is focused on templates that focus on strong separation of client and server code and ability to switch out the back end languages without breaking the front end templates. It is compatible with mustache. Download/read about it @ http://handlebarsjs.com/.
  • JQuery (see next section) emerged as the #1 framework when Microsoft and Open Source types both promoted the heck out of it.
  • Json is not a framework per se but a data transfer structure almost all frameworks have come to depend on. It’s goal is to be a lighter version “easier for human to read” replacement for XML. Microsoft emraced it quickly and the latest ASP.net MVC releases replace many ASP.net MVC XML contructs with JSON. Read more @ http://www.json.org/.
  • Kendo UI By telerik –  A commercial product focused on providing a bunch of ready made widgets/controls/custom tags that provide responsive/adaptive design and multiple devices. And graphing as well. Read more @ http://www.telerik.com/kendo-ui.
  • Knockout is all about data binding 1-way, 2-way, automatic update and dirty control sensing, dependency tracking, and templating, and the like. – Read more @ http://knockoutjs.com/.
  • Meteor – a framework all about building mobile applications. Read more @ https://www.meteor.com/.
  • Node.js – if you want to do portable cross platform SAS (Software as a service) in Javascript instead of a vendor specific stack (Java, .NET) than Node. js is for you.
  • Modrnizr making conditional browser version code easier – @ http://modernizr.com/
  • Reactive.js (not to be confused with RActiveJS) is a “Microsoft Blessed” library all about Observables + LINQ + Schedulers and something they call “Promises” (basically an easy way to have chatty reliable HTTP conversations) – Read more @ http://reactive-extensions.github.io/RxJS/.
  • Underscore.js – Provides a ton of extremely useful functions missing from JavaScript without in any way extending or altering Javascript syntax. See a nice complete function list @Test Suite of the supported functions that can save you a ton of time. Read More/Download @ http://underscorejs.org/.
  • YUI (Yahoo UI library now abandoning new development as of August 29, 2014) – is an oldie but goodie – a way to build UI components (custom tags, widgets, components). Not very active anymore but many sites were built with it, and many components built on top of it. The principles that created it have left, Yahoo is not subsidizing it anymore and it’s future is dead, unless some important group or person rescues it.
  • Browser sniffing on steroids, a Commercial product ($$$)  @ http://51degrees.com/Products

jquery_logo

JQuery – father and grandfather to many

JQuery is a framework that many other libraries are built on top of. So you probably will download JQuery plus a bunch of goodies.

  • xxxxx
  • xxxxx

xxxxx

JS Pre-Processor and Sister Languages

Compilers have been created as proof of concepts for upcoming compiled JavaScript standards. Technically Emmet and Less are listed here not because Javascript is their central focus, but because Javascript and other programmers get frustrated quickly by lack of programming commands in CSS and HTML and these really help.

  • Emmet (used to be Zen) -a pre-processor that is used to make HTML and CSS much easier with snippets, dynamic snippets and editor helpers/expansion. Read more @ http://emmet.io/.
  • Less – a pre-processor that is used to make CSS much easier and add simple programming syntax/constructs and extensions and mix-ins. Read more/get it @ http://lesscss.org/.
  • Zen  – OBSOLETE, replaced by Emmet.
  • Typescript Javascript compiler – Read more/get it @ http://www.typescriptlang.org/*
  • CoffeeScript is a smaller, lighter version of the kind of beast Typescript is. Read more/get it @ http://coffeescript.org/*

These are being used heavily by the more serious developers.

CoffeeScript vs. Typescript is a raging debate that shortly ended with Typescript beating CoffeeScript for now (and probably CoffeeScript’s death). The 800 pound gorilla in the room was Microsoft producing a 1st class version of Typescript integrated with Visual Studio (including interactive debugging) and getting heavily involved in filling out the Javascript standards teams with people and financial donations. Here is a great history of the many Javascript compilers and languages that predate the victory, for now, of TypeScript.

JS IDEs and Debuggers

Then IDEs and Debuggers and Tools appeared. Oh my.

Visual Studio began to every release address Javascript more as a 1st class citizen.

IDEs appeared for Javascript like:

so-why-choose-us

Why use Javascript Frameworks instead of raw Javascript?

Well many reasons…

  • It is more OO. Which if you disregard the King and the Toaster story is a bad thing.
  • The learning curve is less.
  • Event-driven and Event Bubbling.

xxxx

keep-calm-and-choose-wisely-33 index

Why not use Javascript Frameworks?

xxxx

Tight coupling with all the associated issues that raises: version upgrade breakage,

Size – hmm every library needs a Library + the framework. But JS frameworks are tiny.

xxxxx

can-stock-photo_csp8210545

Online Tutorials I love

xxxx

  • xxxx
  • xxxx

xxxx

tutorial-video-purple

Video Tutorials

xxxx

  • xxxx
  • xxxx

xxxx

bookshelf bookshelf-python-for-dummies

Books on Javascript and Frameworks I Love

xxxx

  • xxxx
  • xxxx

xxxx

How to get Javascript Help!

My favorite places to solve any javascript problems I encounter:

Enjoy your Javascripting – Chaz

Sunglasses-Me

Draft – .NET Code Generation

What the heck is code generation?

Code generation is an old idea, that people hobbled together solutions to make it happen. Lets start by showing a few examples of it:

  • Lets say you are writing a class in .NET but many of its properties are based on fields in a database table. For example if the database has 25 fields the class will have 25 properties that map to the database fields. Sure you could type out the property names and types once and have the 25 properties in your class and be done. That is until they add or remove table fields or rename them, and you must go back to your editor and add/delete/rename ad nauseum.  If you have 30 tables that you are wrapping into corresponding objects DBMS changes mean a lot of tedious work to keep them in sync. A code generator could just loop through field names and types dynamically and generate corresponding properties. Update the database tables, then regenerate the code and dozens or hundreds of classes are updated.
  • Now for a simpler example. Let us say you know that the query SELECT * from Location is slower than the query SELECT id,city,state,zip from location.  This could be streamlined by creating a code generating function inline i.e. SELECT <%FieldNames(“Location”)%> from location which expands before compilation to the latter SELECT with an explicit field list.

CodeSmith and FREE T4 – The Coke and Pepsi of Code Generation

In all marketing wars there ends up being 2 leader once the market becomes mature. A strong #1 can “suck the oxygen out of the room” and delay 1 #2 rising, at the risk of the category dying entirely.

Code Generation for .NET there are 2 players

CodeSmith is fairly neutral and can generate any code for any language or platform. T4 is coupled to .NET and visual Studio. Most ORMs for .NET use one of  these two to generate their classes.

Another Approach or 2 or 3

These are just one approach to Code Generation, a simple and easy one.

  • the Roslyn project is yet another focused on the more compiler writer type of person. Read more about the Roslyn project @
    http://msdn.microsoft.com/en-us/vstudio/roslyn.aspx
  • CodeDom allows one to write .NET code dynamically, and combined with Reflection to read the code entities at runtime it is an approach that many used who do not know these tools or just prefer this approach and the runtime checking it provides.
  • All this often dovetails with use of attributes.

What about code generation on other platforms?

  • Linux
  • Mac
  • iOS
  • Android