Programming and general geekiness.

Posts tagged ‘coding’

UI Animation

I spend a lot of time developing software and it means that I have to put far too much effort into designing the UI. I don’t really like UI design because I prefer the actual backend programming because it is far more interesting. I tend to be incredibly lazy when it comes to design.

Over the last few years we’ve had loads of new design technologies that have made it easier to develop great user interfaces for our applications. Microsoft adopts an XML based markup language whereas Apple still maintains its Interface Builder which hasn’t really changed too much since the last 1990s. Other systems adopt similar technologies.

I’ve recently noticed that animation has become a more prominent thing in UI design. Many smartphone apps tend to animate between screens by sliding or flipping and websites are gradually adopting animation between states. Sometimes this works very effectively but most of the time people will go over the top.

UI animation is only really useful if it adds something to the UI and doesn’t slow down the application. I am concerned that with the introduction of CSS3 and other technologies animation is going to become more commonplace as bad UI designers add it to almost everything – it will be like Flash all over again.

I personally don’t use animation at all, but that probably stems from the fact that I prefer the actual programming to the UI design. When working on projects I generally employ a 10:1 ratio of programming time to design time purely because it means my apps generally run better.

Why having lots of programming languages is useful

I know a lot of programming languages but I probably spend 95% of my time working in about five different programming languages. Some people reckon that it is a good idea to have just a few programming languages so that there is less confusion however I don’t think it is necessarily a good idea. Assume that C++ was selected as the ‘one language’. This would benefit many programmers because it allows for complex development of fast applications. On the other hand it would be very difficult for beginners to pick up.

You could argue that Java would be an appropriate ‘one language’. I certainly spend most of my time working in Java because it is a good language with lots of advanced features however it isn’t suited to the web – I’ve never really liked Java Applets that much.

It is therefore important that we have many programming languages (much as we have many spoken/written languages) because it allows beginners to easily understand programming (my current recommended path is Python > Java > C++ > Whatever you like) and also because different languages suit different purposes. C++ was designed to run programs but it would be pointless using it to create websites because markup languages do a better job.

The main advantage of different programming languages, however, is preference. It is always important to have a good choice of options when doing anything and additional programming languages offer that. I like C syntax because it makes sense in my head but other people prefer Python syntax because it is more human readable (although I reckon that once you know your way around a C-like language and you format your code well it is a lot easier to read).

I do get the feeling that desktop programming languages probably won’t evolve much over the next few decades but Dart is set to do some good for the web. Possibly.

Settling the difference between programming and coding

Programming and coding seem to be interchanged terms but a lot of people seem to think that there is a difference. I personally prefer the term programming and I see myself as a programmer however I am happy to adopt the term coding as well to a certain extent as well. I don’t mind the term scripting as this is technically different because a scripting language is technically an interpreted programming language so I see it as completely reasonable to suggest that I’m doing scripting provided I’m using Python, JavaScript or PHP.

Now I think it is time to gauge dictionary opinion. Here’s the definition of programming according to Google: “The action or process of writing computer programs.” Here’s the definition of coding: “To translate (a program) into language that can be communicated to the computer.” The coding definition does sound a little more like compiling however both are completely reasonable.

Wikipedia suggests that programming and coding are used interchangeably and that coding is just a shortened version of computer programming. On various forums the following opinions were expressed:

  • “Different names for the same thing” – The Troll
  • “Coders are basically amateur programmers” – Destron
  • “I usually think of coding as just mindlessly typing out computer commands, whereas programming is actively thinking about abstract solutions to a problem” – Sr_gaupo
  • “A programmer is an inventor and a coder is an assembly line worker. A programmer creates things, a coder follows instructions and assembles things.” – Tristan Irwin
  • “Programming: The overall act of designing, expressing, debugging, then optimizing a software package. Coding: Expressing (implementing) a program. (You’ll note I’ve yet to say anything about computer languages. This was intentional.)” – Moose

The general consensus, therefore, is that from these people with great screen names that coding and programming are used interchangeably but that programmers are the smart people that can design and create cool stuff whereas coders are the amateurs that generally work for the programmers. I think that makes me a programmer.

Mail Macro – a new mail program coming soon

Mail Macro is a new program that I am writing in C# with .Net 4. The application is designed to allow you to send mass mail quickly from your computer by configuring a mail server and account. The mail can be either plan HTML that is quick and easy to send or Mail Macro format which allows you to write XML markup like the following to send emails:

<mailmacro>
<recipients>
<recipient mail="bob@exmaple.com">
<recipient mail="james@example.com">
</recipients>
<from>me@example.com</from>
<subject>Fun for {SPECIAL:RECIPIENT}</subject>
<content>
Hello,
Here is a random picture from Flickr for you:
<img src="{SPECIAL:FLICKR:CATEGORY:EXAMPLE:RAND}" />
From me
</content>
<settings>
<sendseparate />
<html />
</settings>
</mailmacro>

The syntax and UI aren’t final, but it should work great once finished,

What do developers want/need?

It is now less than a month before Microsoft’s Build Windows conference. In a month we will know the ins and outs of Microsoft’s new operating system and how we will be able to use the developer tools to develop next generation applications. However, despite the fact that we are going to find out then, I would like to take a step back and consider what developers really need and or want in their development tools.

  1. Freedom. Developer tools should really be free. I don’t think that it matters if you have to pay for a developer license to distribute the application through a main stream distribution service such as Mac’s App Store or the rumored Windows App Store. The tools should allow for complete freedom to develop for the platform, taking advantage of all the tools available without having to pay an additional fee.
  2. GUI Design. I am incredibly lazy when it comes to UI design because I find it easier to just drag and drop, always. I really can’t be bothered to think about layout tables and other pointless things. I just want to drag and drop controls or widgets or whatever name they have been given into the UI. There should be guidelines to help me place controls evenly. Its also quite nice if I can double-click on a control in the designer to either write code for its default action, or to edit the default text.
  3. A sensible, easily accessible framework. The frameworks that are used should be up-to-date and the same version that is distributed with the OS so that the application is guaranteed to work. The frameworks should be easy to access and be organised logically with a large amount of functions that allow for integration with other services.
  4. Compiled applications should be lightweight and fast. Once I have finished my application I want to know that my application will run smoothly, and quickly, on all computers. None of my users should be left behind because my application is to complex, and so the frameworks should be able to adapt to users’ needs.
  5. Graphics should be great. Applications should look nice. I think that animations can work for some applications, but there is no need for laggy animation because that is not what users want or need. Not only should the design of components of applications be good, graphics libraries should be great. I should be able to sit down and build a 2D or 3D game using the default set of libraries. The libraries should therefore have maximum support for fast and responsive graphics. All graphics should be carried out on the graphics card by default with as little CPU input as possible, and I should also be able to run code to do other things on the graphics card.
  6. A nice code editor. It surprises me how many IDEs still have appalling editors. The bare minimum should have syntax highlighting, line numbers and code completion. This bare minimum allows for code to be written very quickly and also produces readable code.
  7. The language should be designed for reusable code. It’s always nice to be able to write reusable code, and the language itself must encourage this as much as possible. Users should be able to build up libraries of functions they often use, and perhaps the IDE provider should allow users to easily share these functions with others so that popular functions could be added to future versions of the framework. However, there shouldn’t be a great need for reusable code as code should be written anyway in the framework.
  8. Post compilation should be thought out. After I have compiled a program I always like it if I can quickly build an installer that could be potentially be distributed easily through an App Store. The installer should be fast and not pester my user for default settings. I should also be able to manage updates quickly, fluidly and through a standard method. Users won’t like it if they have to manually update an application; either updates should be automatic in the Operating System, or the IDE allows me to control automatic updates in the application.
  9. Programs can remember state/key variables. When I close an application it is always nice if the application loads again with the same things that I had open before. This should be easy for an application to remember. It could either have some sort of automatic settings, or the option to have external variables (which the user can’t edit) that are saved by the application regardless of whether it crashes.
  10. Files should be easy. When an application saves a file it should follow some defaults. Perhaps it could be that there is some sort of compressed container file (a renamed .zip or .tar.gz file) which can contain images, video, audio and XML text files to store key data. The installer should automatically set it up so my application is launched when the user double clicks it in Windows Explorer, and it also has a simple of getting thumbnails for the file, perhaps these could be saved by the application. Not only should files be well supported, but databases should be too. If I want to to use a database in my application, or communicate with one on a server, I should be able to connect to it safely and securely in such a way that ensures the user cannot edit or see what they shouldn’t.
  11. Applications should be congruent. It annoys me when applications aren’t compatible. It should be easy to make the compatible and make them work with other applications. It should be easy to code plugins for applications. It should be easy to extend them. Regardless, applications should be good at drag and drop. I should be able to drag and drop content from a document to a presentation to an email, to a web page, to tweet. File formats would need to be standardized, so I could, for instance, drag and drop a podcast onto my desktop to instantly get it to show a player that will download the most recent version for me.
  12. Design should be easy. This sort of matches point two, but this is more about how the design of an application should match standards that make it easy to use for every audience. Apple have the Human Interface Guidelines and these ensure that Mac applications work smoothly. Not only should the design of the GUI be simple, icons and images should also be designed carefully. I don’t want to have to pay a few hundred dollars to pay for a drawing application I don’t really understand just to give my application an Icon. The IDE should contain an easy icon designer that developers, and designers, can understand. The framework itself should offer a set of default icons that can be used across applications to represent things; it is important that a New button looks the same everywhere so people understand what it does. Furthermore, these default icons should be up-to-date, relevant and easy to remember. The fact that the default save button in most applications is a floppy disc is proof that we need an update soon.
  13. Defaults. The IDE should offer a good set of default templates that make application design easy. It is nice to have separate templates for a document based application, a navigation based application and a game. Right now, neither Apple or Microsoft gets this entirely – both have things to improve on, but Apple is better. I should really be able to mix and remix these templates so that I can produce, perhaps, a document based application that has 3D design capabilities. The templates should also allow for me to write a really small application and a really big one – they should be sizable.
  14. Toolkit. The default toolkit should be massive, but easy to access. Where is the point in me spending a couple of years designing a game if I have no tools to build the 3D characters with. The toolkit should effectively be one application, but I should be able to add to the toolkit, so if someone has designed something to allow me to edit my characters more easily, I should be able to add this in with no problems.
  15. Speed. Everything should be fast. Creating a project should be fast. Designing the UI should be fast. Selecting the design set should be fast. Coding should be fast (using code completion). Compiling should be fast. Perhaps the UI of the IDE should even optimize itself to my tasks, automatically hiding things I won’t need in the design of my applications. If I want to, I should be able to spend a day on a project before general release, but if I want to spend three years the tools should be just as good.
So, where do we go from here? Microsoft will certainly need to take nearly all of these points on board for Windows 8. Apple are most of the way there with Xcode. In my mind Microsoft will probably need to redesign Visual Studio from the ground up for Windows 8 if it is going to have decent development tools. If Microsoft is genuinely planning on having most Windows 8 applications written in HTML5, CSS3 and JavaScript they will need to find ways to give developers maximum support and to allow them to securely compile and distribute them. Microsoft will need to rethink Windows Installer, definitely using some support of app center that allows for applications to be instantly downloaded and installed.
I think that only time will tell on whether Microsoft succeeds with its new tools, but I hope that perhaps at least 10 of my 15 points are considered at some point in the future, because they need to be to make a nice development environment.

Why GCC is popular

I like coding. I like coding a lot. It’s fun. However, I couldn’t do any of the coding that I do without compilers. Thankfully, a bunch of these exist. When it comes to compiling on most platforms there is only one major leader: GCC. On Windows there are alternatives such as Visual C++ and Borland but neither of them have the user base that GCC has amassed over the past twenty years. GCC works on almost every Operating System and with many programming languages.

Visual C++ and Borland compile for the Intel architecture on Windows for either C or C++. That is it. That is everything they do. However, GCC will compile for around twenty different platforms on twenty different architectures with C, C++, Objective-C, FORTRAN and others. It is simply more capable.

It probably isn’t just support that has made GCC popular. Something else helps: it is used by UNIX. Mac OS has nearly always used GCC as the default compiler because of the Objective-C support. That means that hundreds of thousands of apps on the Mac/iOS App Stores are almost all compiled by GCC. Globally GCC has probably compiled billions, if not trillions, of lines of code. Without GCC whole Operating Systems probably wouldn’t exist.

GCC is pretty much the default on Linux as well. I have no used or come across anything else (probably through ignorance and or laziness) because of the usefulness. It gives me decent error reports and the programs I code work. GCC is also very extensible because it allows for libraries to be written on top of it. Apple adds Cocoa to it with its own controls, however Linux adds GTK+ (GIMP ToolKit+) for interface. The nice thing about GTK+ is it works on Windows, Mac and Linux – that’s why GIMP is popular.

GCC deserves more recognition that what it receives. It has done so much in the last twenty years, and without it we wouldn’t have Linux or Mac in the current form. Thank you, GNU, for making the the GNU Compiler Collection.

ThomasScript will happen

Yesterday I finally got round to deciding that I would code ThomasScript. I had written some code about a month ago that roughly worked out how I could get started – but that was in C#, so today I have been porting it all over to Java. So far I have a relatively simple 150 line Java file that allows for ‘string evaluation’ and the write command. Here are the total commands:

Branching Commands:

  • if
  • else if
  • else
  • for
  • while

General commands:

  • write*
  • get
  • getnum
  • dim*
  • random
  • set

Variables:

  • PI – 3.141592
  • NEWLINE – \n
  • THEANSWERTOTHELIFEUNIVERSEANDEVERYTHING – 42
*Infinite arguments
I’ll probably add some more, but this is the basics of the language for now – it will be improved.

How to build a really simple programming language

This is not a tutorial. It is more a guide of how you could first approach things. It is assumed that you code in some object-orientated language. I think Java would be the best thing to get started with for this. I have based this on some code that I have already written as part of my ThomasScript project, which I intend to release at some point. Maybe.

First of all, I must assume that your programming language (and mine) and simple non-OO languages that have their code written out in text files, or somehow read text into some sort of String object to use as the basis of their ‘code’. Like you have a BASIC interpreter (which you would write) and a .BAS file that someone else would write and run. I’ll let you worry about how you get the content of the .BAS file.

Now that you have roughly figured this out, you need to think about how you are going to structure your language. Here is a rough example of mine:

dim $variable

set $variable = “Hello”

write $avariable

getnum $variable

set $variable + 1

write $variable

if ($variable > 10)

write “Big number”

else

write “Small number”

write “Going to run a function”

run someCode “Hello!”

code someCode $text

write $text

I think it is relatively clear how this program works and indeed how the programming language works – even though it is very simple. The first part of coding the language is to split everything into array, split into individual lines. You then take apart the first line by its spaces: dim and $variable. There is therefore a switch branch in your code that has all of these possible language keywords. The code for dim is found and the argument $variable is given to it. For simplicity purposes all variables start with a dollar symbol for easy lookup. The variable names are stored in a string array with a length of about 10,000 because it is unlikely that you’ll need more, or that you are using a language that allows for arrays of unlimited length. There is then another array with type of object (or equivalent) that stores the variable values. This is relatively simple.

Because it is relatively clear how all the other functions work from this, the next thing to look at is basic (very basic) logic. I have decided that to keep things simple at first I will only use >, <, ==, !=, <= and >=. I will not use any variation on AND or OR. The value in the brackets is now relatively easy to evaluate; you simply get the left hand value and compare using the appropriate operation to the right. After this you get all the code that is indented and run that.

This is a very basic article and doesn’t really discuss the full process, however it certainly offers a simple start. Please note I plan to write a simple version of ThomasScript to the syntax described above before releasing the source code (either C, C++ or Java).

HTML5 Canvas FallDown

FallDown is probably one of the most successful free iPhone games of all time, and I quite like playing it even though I am really, really bad at most iPhone games. Just for the fun of it I decided to see if I could code my own version of the game in HTML5 Canvas because all the other versions on the web are flashed based, so I thought it would be nice for there to be a Canvas version.

You can play the game at programmingthomas.tk. I have tested it to work in the latest versions of Firefox and Chrome and I can’t think why it wouldn’t work in any other major browsers that support Canvas – maybe excluding IE9, but I’m not going to go there. The game itself was really easy to code, though my high-score is only 106 (the scoring works on the number of bars you get through)!

Comics of Chuck Norris, winning and programming

This slideshow requires JavaScript.

Follow

Get every new post delivered to your Inbox.