RSS Feed

Multilingual programming


Recently I involve in various projects. And they are using different technologies. I am fervent in programming because it conforms to my theological and philosophical perspective.

The languages and technology I am currently using: AngularJS and NodeJS, .NET MVC with C# Mono, and Ruby on Rails. Other related technologies: Nginx, AWS, migrations, Bootstrap CSS, etc. Besides that, my background is strong fundamental C, C++, and PHP skills; have good experience on Python; some experiences on Java, Android, Perl, and VB Script.

Since the advancement of cloud computing, everything is about server and client. HTML, JavaScript, and CSS are the basic of the basics. Furthermore, I am a Linux user, working on sysadmin tasks becomes much easier.

Naming convention and syntax

Involving in various languages and different development frameworks, there is something very important, that is, naming convention. Unlike syntax, where syntax is the language level rules, naming convention is the framework level rules. That means, when using a certain framework, you should follow the naming convention, especially MVC framework. Because by following naming convention (and file structure as well), the framework will use the corresponding database, view page, and controller as well. That is why, you follow it, your development will work faster, need not to care about the internal algorithms.

And some of the naming conventions, is just the style, not really related to the framework. They are “recommended”, instead of “required”. You must know how to differentiate these two.

Let me explain why the naming convention matters. Web technology is a very interesting area. If you open an HTML file, you will see three kinds of syntaxes: HTML, JavaScript, and CSS. Yes, these kinds of syntaxes exist in one file. JavaScript usually use the camel case, so do HTML DOM methods. CSS selector has no requirement, you can use camel case as well, but it is usually hyphenated identifiers, eg foo-bar instead of fooBar. HTML has no restriction. But the attributes are usually hyphenated, yet the value can be camel case or hyphenated. If it is JavaScript related, then camelCase; if CSS, hyphenated. This is how HTML works.

The above is purely client side HTML. For the server side, we usually use a template engine or template system. MVC uses Razor: Rails uses ERB; ExpressJS uses Jade; etc. So, when using these engines, new syntax comes in. Some template engines allow logical statements written in the view, such as Razor and ERB. As a result, you will see pascal case in Razor, snake case in ERB. So, by looking at these naming conventions and syntaxes, you will know what languages being used and what you should do. On the other hand, AngularJS has a very neat template design. No logical statements allowed in the template. Consequently, the template is very neat!

Pascal case and camel case

I don’t like Microsoft, but I admit that Microsoft has its own strength in some technologies. (Else you will not see Mono in Linux.)

Microsoft uses Hungarian notations in C/C++ documentation, for instance, “szName” means identifier “Name” with zero-terminated string data type. It is less human readable. Currently there are a lot of high level languages, thus human readable is required so EVERYONE can code. That is why the methods/functions are verbs like getSomething, setSomething, countSomething, addSomething, removeSomething, clearSomething, etc.

Microsoft uses PascalCase; JavaScript uses camelCase. Because I am used to work on JavaScript and HTML DOM more, that is why I prefer camelCase. Microsoft doesn’t disallow camelCase, but the PascalCase is a suggested naming convention. The reason I prefer camelCase rather than PascalCase is because, uppercase of the first later like

MyType

means data type. And

myData

means variable.

So, using the uppercase of the first letter allows me to differentiate my source code easily. However, Microsoft .NET C# uses PascalCase.

So, the question is, should I follow PascalCase or camelCase when using C#? After working with so many projects, I decided to follow the naming convention as recommended. Just use PascalCase as it is recommended. So that, I can feel the conformity instead of alienation. So, how to differentiate the data type and the variable? That is an easy solution. Just recognise them semantically! Because the programming languages, at the end, are still human readable language.

Editor

Lastly, I have to talk about the text editor. Instead of IDE, I prefer my favourite text editor, which can split the view into multiple unlimited windows, or clone multiple unlimited windows. Not only that, the text editor has syntax highlighting in multiple languages in one file like HTML. At the same time, open different file types like Ruby, C#, JavaScript, CoffeeScript, CSS, SASS, SCSS, it can still differentiate them. None of the editor can beat it! Yah! That is Emacs. Emacs is the best programmer editor!

I like Vim too. There is always Emacs and Vim war. I like Vim, as it is a general text editor. Edit any text with keyboard only. Edit configuration files through SSH, Vim is the best. Yet, Emacs is the programmer editor. It takes care the programming language indentation smartly. This is what I need! Highlight all and TAB, everything is formatted!

About Allen Choong

A cognitive science student, a programmer, a philosopher, a Catholic.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: