Languages vs Algorithms

Programming

I was recently discussing a project with a potential client. His project was using a language I haven’t used heavily in quite some time. He was disappointed because he was struggling to find developers to work on his project. I indicated that I would not have trouble getting back up to speed on the language and being able to move his project forward.

This really highlighted in my mind what really matters in development – it’s not languages, it’s algorithms and software design. All programming languages are, at their core, pretty similar. For example, all languages include:

  1. Syntax for creating variables,
  2. Selectively executing a block of code based on one or more conditions
  3. Repeating a portion of code multiple times
  4. Encapsulating code into functions

These basic structures are responsible for all the software you will ever use. Whether it’s a complex operating system like Windows or MacOS, a cell phone application on iOS or Android, or an application on the cloud, they all rely on the basic elements above.

Once you understand the basic syntax of a language, you move into the more important stuff – algorithms. Algorithms are a set of instructions to perform a given task. Regardless of the language, the algorithm will be largely the same. Next up on the hierarchy is software design. Knowing syntax and algorithms is great, but to really develop quality software you need to be able to design the interactions between components. None of these things vary substantially between languages. Languages are merely the syntactic rules you must follow to define your algorithms and implement your design.

I think people need to worry less about what language a developer uses and look for higher-order skills including algorithms and design. That’s what really defines the skill of a programmer!

Coding Style

Writing

One of the most important skills for any team of engineers is to develop a consistent coding style. Without it, development and debugging times increase and productivity decreases. Coding style is much like the rules of writing a story. Sentences start with a capital letter and end in a period. New ideas are started in new paragraphs. Spaces exist between letters of words. If someone were to write a book without following those conventions, it would be substantially more difficult to read. Coding style works the same way.

One of the projects I worked for years was a complicated telephony system. It included low-level code for interfacing with the phone boards as well as high-level code for displaying data to the user. This was a lengthy project that took substantial time to develop. During development, John and I worked to develop a consistent coding style. A mentor on the team, Mark, would review our code, provide feedback, and fanatically insist on standard coding conventions and style.

At first, this seemed silly to me. I’m a developer, let me do what I do! But, as time went on, it became increasingly apparent how valuable it was. After a while, I was unable to tell the code I wrote from what John wrote. While this may seem silly, this meant that when bugs were found, either of us could feel equally comfortable understanding and changing the code.

Today, when I learn a new language, one of the first things I try to do is learn standard coding conventions for that language. Some languages, like Java, have well established and followed conventions. Unfortunately, many other languages do not. When that happens, the team needs to determine what conventions they will follow for their team. If not, expect bugs to take longer and development to be slower.

Development Environments

Workbench

As a developer, it’s a great time to be alive. We have countless options for development languages and frameworks. But, sadly, many of them leave much to be desired in terms of tools and environments.

The Model Environment

As a veteran Java developer, I’ve been spoiled with excellent tools. We have numerous IDEs including Eclipse, NetBeans, and IntelliJ. Everyone has their preference, but all three are excellent. Likewise, we have numerous build and dependency management packages such as Maven and Gradle. We have test frameworks, automation frameworks, debuggers, profilers, and anything else you could want to engineer even the most complex of application. In short, Java provides the best development environment there is. Seriously. Few languages have IDEs as good as what Java has. Even fewer have tools that can complete with Maven or Gradle.

When Will Other Languages Catch Up?

I continue to see how Python is displacing other languages. But when will it catch up to Java in terms of development environment? Are there any IDEs that complete with Eclipse for Python? (NOTE: Eclipse can actually be used for Python, but it always seemed to me more of a hack than a real Python IDE) How about debuggers? Go ahead and try debugging Python or JavaScript code and you’ll quickly see how far behind Java they are. Not to mention dealing with libraries and environments!

A Call to Action

As we continue to shift to newer languages, I’m concerned that the next generation of developers will actually have a more difficult time than we do today. Why, as a development community, are we only focused on creating new languages but not on creating solid environments? How are Go, Python, Rust, and the myriad of other languages ever supposed to achieve the same widespread adoption of Java if we never had the rest of the tools we need to get the job done? I want to enjoy the benefits of some of the newer languages to come along. But, until they can complete with Java, I’m unable to stake the success of my customers on them.

Multilingual Programmers

One of the biggest difficulties in the computer programming world today is the sheer number of languages out there to use for application development. Which language should you learn? The reality is, that’s the wrong question. I recently spoke with a developer who indicated that he only knew C# – he was not comfortable with Python or any other language. For the professional developer, this it not an acceptable answer. In today’s world of programming, you can no longer get by knowing only a single language. For example, while the bulk of the code in a Java web application will be in Java, the front-end will require JavaScript and HTML. Build scripts may be written in Groovy or XML, and Shell scripts may be required for build automation. This is not unique to Java applications – just about any application will require some knowledge of other languages.

How do you pick which languages to learn? At a minimum, every professional engineer should know at least one compiled language such as Java, C, C++, or C# in addition to JavaScript, Python, and SQL. Additionally, he or she should be comfortable with another language such as Ruby, PHP, Go or Rust.

If you’re an application developer, do you only know one language? If so, I would strongly urge you to learn additional languages. Mastery of every language isn’t necessary, but any decent developer should feel capable of writing code in several languages.

Language Popularity

A subject that repeatedly comes up on websites, blogs, and conversations is which language is the most popular and which ones are the best to learn for future job opportunities. I keep an eye on this list myself as it’s important to understand trends within the software industry. However, people seem to ignore the most important aspect of language popularity – the context.

What do I mean by context? I mean we have to look deeper to understand why a language is as popular as it is. We also need to understand the market for a language and how that impacts popularity. For example, JavaScript is always near the top on any language popularity chart. Is it any coincidence that JavaScript is also the only front-end scripting language in use today? Whether or not you like JavaScript is utterly inconsequential. If you want a website with any manner of front-end scripting, you will use JavaScript. Likewise, if you want to interact with a database you use SQL and if you want a web page, it will be HTML. As such, these technologies will always rank more highly than those with a smaller market.

So what about Python? Everywhere you look, you see that Python is at the top of the list. Should we all switch to Python? Not really. What all those rankings fail to point out is the user base for Python. Certainly there are all kinds of production projects out there running Python. But if you look around, you see that Python’s popularity is largely caused by people outside the traditional developer community. AI researchers, academics, data scientists, system administrators, makers, etc. For non-programmers, Python is easy and incredibly powerful. But that hardly makes Python superior to other languages nor does it suggest that professional programmers should start porting their eCommerce sites.

Remember, while rankings of popularity may help you see trends, look to the underlying reasons. Why is it popular? Who is it popular with? Does this language look poised to overtake in other realms? When picking a language for a problem, the most important question is which language solves the problem best – not which language is the most popular.

Angular & MaterializeCSS

During the last year, I’ve developed numerous websites and mobile applications using the Angular framework. I’ve used numerous CSS frameworks as well such as Bootstrap, Ratchet, and Topcoat. But recently, a customer asked me to use MaterializeCSS. MaterializeCSS is a library of CSS and JavaScript code to easily create a material design experience for web applications. It’s quick, easy, and visually appealing. Unfortunately, getting some of the components to work with Angular proved difficult as the online documentation does not show how to setup Materialize for Angular. While most of the components do not require any JavaScript interaction by the developer, some components (such as select option lists or tabs) require initialization. The documentation says that tabs can be initialized by using:

var instance = M.Tabs.init(el, options);

Unfortunately, this won’t work in Angular as you’ll get numerous errors regarding undeclared variables. How can you hook this up properly?

First, declare the ‘M’ variable inside the page component below the imports. This will allow you to use the ‘M’ interface to MaterializeCSS from within your Angular code.

declare var M: any;

Next, get a reference to the object you are trying to interact with. This can be obtained by using a querySelector for the class of object you’re trying to initialize. For instance, tabs will be declared in HTML by assigning a class=”tabs” attribute to object. Once you have the object, you can initialize it by calling the appropriate method. This should all happen on the init method of your page object.

ngOnInit() {
  const elem = document.querySelector('.tabs');
  const options= {};
  M.Tabs.init(elem, options);
}

This is identical for any other object that requires MaterializeCSS initialization and can also be used to call any other functions in the MaterializeCSS framework.

With this information, you should be able to enjoy the benefits of Angular as well as the awesome UI elements of MaterializeCSS to their fullest!

Killer Robots

During the last year, countless tech leaders have talked about the danger that artificial intelligence could pose in the future. Like most people, I laughed at them. After all, do I really think that The Terminator or The Matrix were prophetic? Hardly. But the more I read and the more I pondered it myself, the more concerned I became. Now, I wonder if there’s any way to prevent it from happening at all.

Is it really reasonable to think AI could take over the world? Do we really think code will be so poorly written and that software testers will be so incompetent as to let AI robots kill humanity? Unfortunately, I do. Not intentionally, of course, but bad code that wasn’t properly tested will make it into the wild on robots. Consider all the system updates that have been performed on your computer or your cell phone. Think about all the app updates that happen every single day. Consider all the one star reviews for apps on the mobile stores. AI will be no different.

Consider all the potential causes of AI issues. Developer errors, inadequate testing, corporate release requirements, poorly defined ethics, unforeseen events, etc. Each one of these issues could cause AI to perform in ways it was not intended with potentially catastrophic consequences. Consider government AI being developed by the lowest bidder – wow, that’s scary.

The more I think about that, the more certain I become that AI will eventually cause huge problems to the world. As such, it’s imperative that we – the tech community – consider the limits of AI – not in regards to technology, but rather in regards to safety and security. Do we want AI police officers or soldiers? That sounds dangerous. Could Russian hackers embed “Order 66” into our own robot army? Do we trust robots with firearms to make the appropriate decision in a life-or-death situation?

My intent is not to sound like an alarmist, but rather to begin thinking about the issues now. If not, we may find it’s too late to do so later.

Picking a Server Platform

Many small businesses want websites or mobile applications that require server-side functionality. Often, this functionality includes a database to store user information. What options exist for a user? What are the pros and cons for each one? I will examine three different frameworks – Node and SQLite3, PHP and MySQL, and Tomcat. These represent just a small number of options available to a business – from small scale applications to enterprise solutions.

For small applications, I like Node and SQLite. Node is a simple platform to run server-side programming. Since it requires virtually no infrastructure, Node services can be installed and deployed in minutes.  Likewise, SQLite requires no installation. SQLite databases are a simple file that can be easily backed up or restored by copying the database file. While this framework is great for small applications, enterprise applications would benefit from more robust environments. Node and SQLite can work really well for small internal applications or to implement a small number of services using a small database.

Next up, PHP and MySQL. This combo is widely deployed on a variety of platforms. In fact, that’s one of the reasons I like it. Typically, service providers like GoDaddy have support for PHP and MySQL out of the box, so applications and services can be deployed without much effort.  PHP/MySQL is also more robust than Node/SQLite. On the negative side, PHP has a variety of versions that are substantially different and PHP code can easily become unmanageable if developers aren’t careful.  I like this solution for smaller customers needing a small number of services on an existing PHP server.

Finally, there’s Tomcat. This option is an excellent Java-based server bringing all the advantages of the Java programming language into a robust server environment. Tomcat can integrate with any database, but MySQL is a common solution. Tomcat is an excellent option for Java web applications or services, but suffers from one big problem – it’s the most complicated option to setup.  This option is best when a large number of users or a large database must be supported. This is the option I like to recommend for enterprise customers.

Numerous other databases and server platforms exist. Microsoft’s .NET platform can work great for customers who prefer Microsoft products and Ruby may be a desirable option for some customers too. As with all technology choices, server platforms must be selected based on customer requirements. Small customers appreciate rapid, low cost development while larger customers will want more robust solutions while being less price sensitive.

Language Overload

As a technology enthusiast, I live in a great time. Computing devices are everywhere, artificial intelligence is advancing by leaps and bounds, and hardware platforms such as Arduino and Raspberry Pi have made it easier for people to tinker with new technologies without spending a lot of money. But with all the great advances in technology, there is one advance I do not enjoy – the endless list of new programming languages released every single year. I’m not opposed to new languages, they are a necessary part of the march of progress. But don’t we have enough already? One example is the proliferation of languages that operate on the Java Virtual Machine. Originally just Java, now we have Scala, Groovy, and Kotlin too. And, each one has their own group of advocates saying their language is the best.

When Apple announced a few years back that they were replacing Objective-C, I was originally optimistic. Objective-C is pretty much unused outside the Mac world. If you wanted to write iOS applications, you had to learn an otherwise useless language. Was Mac going to lower the bar for new developers and allow them to use a language that was already widely used? Nope – they invented another language – Swift. I’ve heard lots of great things about Swift, but I’m not really interested in learning another niche language to develop for a single platform. (Instead, I’ve chosen to use hybrid tools such as Cordova and Ionic).

What’s the harm in all these languages? While different languages do bring different things to the table, there has to come a point where the market is over saturated. With all the languages out there, developers have to pick which ones to learn and which to skip. While every developer should be competent in more than one language, it’s certainly not realistic to expect a developer to be an expert in a dozen different languages. And since every language needs their own libraries of code, scores of developers are wasting their time writing standard functions for another language. Solving a problem that has already been solved a dozen times in the past – with a new language – is not particularly useful.

Where do we go from here? I suspect that we will continue to see the proliferation of languages. Long term, we will see languages transition to legacy code far sooner than previously. This will make it increasingly difficult for companies to maintain their codebase and will mean more frequent rewrites of software applications just to stay current. For companies, I would suggest ensuring that the languages you choose are solid, stable, mature, and likely to be around long term. You can go for the newest language out there, but you’ll struggle to find developers now and you’ll likely end up having an ever more difficult time maintaining the application long-term.

Getting Started with Artificial Intelligence

It seems that artificial intelligence is in the news more and more. Most larger companies use AI for something within their business, and more and more businesses are finding ways to improve their organization with AI. Purchase recommendation systems, self driving cars, video games, language translation apps, and route mapping software are just a few examples of artificial intelligence we see every day.

But where does someone interested in AI get started?  AI can be very complicated, but that doesn’t mean you can’t get involved too! One of my favorite resources for learning AI is the series Artificial Intelligence for Humans by Jeff Heaton. In his books, he covers a variety of topics including genetic algorithms, machine learning, clustering, linear regression, swarm algorithms, and so much more. While these topics can be complicated, Jeff presents them without all the math in a way that is far more readable than most texts on the topic.

If you are interested in AI, one of the first questions to answer is what programming language you want to use. While any language can be used for AI, the bulk of the tools and frameworks available exist for Java, C++, Python, and R. If you’re big into number crunching and Big Data, R may be the obvious choice. If you’re not a programmer, Python may be easier. For existing developers, Java or C++ may be best.

What type of AI do you start with? Try genetic algorithms or swarming algorithms. Genetic AI assumes the answer to be like a genetic genome and, through a series of mutations and genetic splicing, attempts to find an answer.  Swarming algorithms look at groups of objects and attempts to have them behave like a cohesive team. Swarming algorithms are great for games with AI controlled enemy armies and are commonly used by game developers. Other common, and simple, AI algorithms include K-Means clustering (used to group objects by similarity),  linear regression (used to predict unknown values using relatively simple algebra), or path finding algorithms such as Dijkstra’s Algorithm.

Once you understand the basics of AI, you can move onto frameworks like DeepLearning4J or TensorFlow to help create Neural Networks (a far more advanced type of AI) or look into libraries like OpenCV for tinkering with Computer Vision.

Whether it’s creating an emulation of a fish tank using swarming algorithms, solving the Traveling Salesman Problem using genetic algorithms, or calculating a path through a maze using Dijkstra’s Algorithm, artificial intelligence is loads of fun.