« .... and Winners for Challenge 3 | Main | HINT FOR CHALLENGE 4B »
October 22, 2005
Programming languages
In case you've missed it there is a good discussion of programming languages going on in the comments on the site. Take a look around.
Posted by Harry at October 22, 2005 07:04 PM
Comments
If you wish to leave a comment please act responsibly. No personal or innapropriate comments should be made. Concerns about a comment should be emailed directly to us here. Hints about the challenges may be blocked or held back at our discretion. We reserve the right to refuse to publish comments without entering into a discussion about why, and to censor comments as we see fit. Please be patient if it takes a while for your comments to be approved.
I'm too old to take part in this as a competition but I really enjoy doing the deciphering. I work with mainframe computers and sometimes the processing takes a while and this helps to pass the time. I wanted to encourage all those who don't or can't use any programming skills because you don't need them. I just use MS Excel - not even any VBA in Excel, just the formulae that are there. I've done all of the exercises in the past two years this way - so it can be done. The downside is that it can be rather slow to tinker; but the upside is that your Excel skills increase!
Posted by: Jonathan at November 8, 2005 10:24 AM
Javascript is great! It's the easiest programming language ever, and takes only about half an hour to learn it to a level where you can write a basic frequency analysis program. The disadvantage of stuff like C# is that you have to compile it; the disadvantage of CGI scripts like Perl is that you have to download the server; whereas with javascript you can just write it, save it, view it without even having an internet connection.
Also, you need absolutely no extra software to run javscript! All you need is a simple text-editor, like Notepad with Windows, and a browser, like IE or Firefox.
Writing your own programs means that they do exactly what you need for your specific situation, and you can adapt them if something new happens and they need more functionality. I guess that at least 80% of cipher breakers this year are using a computer in some way to help them crack it, and that at least 40% are writing their own programs. It would be interesting to find out.
Posted by: harry deVoil at October 27, 2005 08:54 PM
May i remind people that visual basic is not true basic, it has been changed a lot. I am talking about Xbasic and chipmunk for example. VB has been changed to be Object oriented and have a clearer structure. I still stay behind pascal as a better choice especially if you wish to jump to java or c/c++. I admit it can get pedantic (you have to remember the . after end or the whole thing falls) but it is great.
Programming may be fun but if you are starting out you should not try anything like c/c++/java. They are cryptic and unreadable unless you have used them for some time. Don't get me wrong, I like C/C++. I use Linux and so if i contribute to a project more likely then not they will be used (and now c sharp).
Posted by: Alexander at October 27, 2005 08:08 PM
Are we supposed to infer from "but if you're doing the Cipher Challenge..." that you're a bit geeky if you are doing it, so would probably enjoy programming?
Posted by: Ruth at October 26, 2005 08:10 PM
Ruth,
Try gcc from http://www.bloodshed.net/devcpp
dev-c++ is a nice IDE for it.
Posted by: Mike at October 26, 2005 07:11 PM
@ Ruth.
I use g++ for C++ when I'm compiling apps from source in linux, it's free, and there should be a windows port of it.
If not, DEV-C++ or something is free and for windows, I remember a friend using it.
Posted by: jack at October 26, 2005 06:46 PM
I've had this debate many times before, but i feel that c++ is the best language to learn first, it skips the bad habits. Assembly, if that is your cup of tea would be better off being learnt at the same time as learning how to make silicon chips, as you basically have to tell the electrons where to go!!!
Anyone looking for a book on c++, "C++ without Fear" is particuarly good for someone new to programming.
Posted by: Josh at October 26, 2005 06:24 PM
Where can I download a free C++ compiler?
Posted by: Ruth at October 26, 2005 01:29 PM
"Programming is FUN!" - Not for everyone, but if you're doing the Cipher Challenge...
BASIC - "It is not structured and is not logical" - This statement is totally unjustified. Visual Basic happens to be an event-driven object-oriented programming language. The code is broken into different events and from there it is as structured as the programmer makes it.
Posted by: Jason at October 26, 2005 12:41 PM
Someone said this before, but the "in easy steps" books are the best I've found so far.
They only really touch on the surface of a language, but that's all you want from a beginner book.
The way I've learned most of the languages I know, including c++ and perl, is by reading the "in easy steps" book, which gave me an understanding of the syntax and basic functions of a language, and once you know that you can learn from looking at other people's code and reading stuff on the internet.
Once or twice I've spent money on £20-£30 programming books, and I've always regretted it, I wouldn't recommend spending more than £15 max on a programming book, the expensive books are usually too wordy, the best way to learn is by looking at examples, rather than reading waffle.
Also, the best way to learn a language is to do something useful in it, rather than just "hello world" programmes, so now, while doing the cipher challenge, is the ideal time to learn.
Posted by: tom at October 26, 2005 11:28 AM
Ruth,
The two books that are recommended most often are "The C Programming Language" by Brian Kernighan and Dennis Ritchie, co-creators of the language (http://cm.bell-labs.com/cm/cs/cbook/) and "C Programming: A Modern Approach" by KN King (http://knking.com/books/c/). The first is short, clear, and definitive. The second is said to be a lot easier to work with. Unfortunately, they're both expensive, so maybe you could borrow one from a library to see if you like it.
Posted by: Sums at October 26, 2005 01:05 AM
Who cares if it's 'overkill'? Programming is FUN! That's why I do it it (and it's quicker than by hand, but it's easy enough to find programs on the web, which is easier, but a lot less fun)
Posted by: Ruth at October 25, 2005 10:07 PM
My dad knows both pascal and VB but he made me start with pascal for the reasons mentioned below. He also wants me to learn C or a variant to teach him. Can anyone reccomend a good book to start learning C from?
Posted by: Ruth at October 25, 2005 10:05 PM
Many people say to write an automated program is overkill, it still is a useful way to break the codes. Firstly I just want to add Mono (C#) works on Windows 2000 and XP boxes, not just linux. If you are just starting it is overkill to use any language with its syntax based on C (c++, C#, java etc) except pascal and definate overkill to use assembler or binary code (it took me a month to make it display the date). People only use the latter for speed and you're program is so small that whats the point?
Whatever you do I do not advise the use of Basic. It is not structured and is not logical. VB.net is expensive bt if you want visual basic try Gambas which definately works on Linux and should work on windows. I would use pascal
(www.freeepascal.org) for this sort of thing. Ruby is great but very few use it, the same goes to small talk. I agree with Harry de Voil, javascript is great because as long as you have a relatively modern internet browser and a cheap referance book it is easy to learn. PHP is hell to install and harder to learn but is more powerful. You must install apache to get php to work, so i do not advise it. Python is anoying because it is interpretor not a compiler. In conclusion if i were a novice (i have programmed for 5 years) i would use pascal of javascript
Good luck
Alexander Alecio
Posted by: Alexander Alecio at October 25, 2005 02:57 PM
Im using a language called ruby for all my programming. It is completely free, and very easy to use.
http://www.ruby-lang.org/en/
However, as it can be quite difficult to set up, some people may wish to use python, which has already been commented on.
What I like about ruby is that you can just type something like:
3.times{
code
}
This will make the loop execute 3 times - very simple :)
Have fun,
chidders
Posted by: chidders at October 25, 2005 12:32 PM
I found a website with some e-books that introduce computer programming very nicely. The books are called 'How to think like a computer scientist' and come in different versions for different languages.
There's a Python version here:
http://www.ibiblio.org/obp/thinkCS/python/english/
and a C++ version here:
http://www.ibiblio.org/obp/thinkCS/cpp/english/
Posted by: Sums at October 25, 2005 03:28 AM
Richard and Ruth,
It's true of course that assembly languages are not impossible to understand. Somebody has got to understand them so that they can create compilers for other languages. In fact today I wrote a programme in an assembly language which can do Caesar shifts. It was rather fun. It taught me about how my computer's CPU actually works.
But I'm sticking to my story that people should forget about assembly languages. Firstly, assembly languages are horribly cryptic. For example, in C I can write
if (letter > 'z') { … }
which seems clear enough, but in assembly code I have to write something like this
cmp r10, 'z
bf 1, 0f
…
0:
which is horrid. Secondly, it would take much longer to write a programme in assembly code. You have to type more, it's harder to keep track of what's going on, and it's more difficult to find mistakes.
I doubt that programmes in assembly language will be faster than compiled C programmes. Here's someone from IBM, writing about the assembly language for their PowerPC chips:
"One of the most common reasons people want to use assembly language is to make a slow program run faster. But in these cases, assembly should be the absolute last place you turn. […] Your compiler can almost always do a much better job than you can at writing assembly!" (http://www-128.ibm.com/developerworks/linux/library/l-ppc/)
The bottom line here is that it would be a very bad idea for anyone new to programming to start with an assembly language.
Posted by: Sums at October 25, 2005 03:20 AM
I dont think Sums meant it as Assembly was impossible to use, I think he just meant it as "noone in this challenge would use assembly". Assembly is good for streamlining applications, or making them smaller(the Slammer worm a few years back was wrote in assembly for this reason). However it is very difficult to use as none of the commands are reconisable unless you understand assembly.
However, I still think that for this challenge, learning C++ is not nessesary(compared to learning higher level interpreted language for example) as these challenges were designed to be cracked without programs, so a BF attack shouldn't be an option, more a last resort.
I would say learn Python, but i am bias towards Python in a way as it's the only language I have any real knowledge in.
My main suggestion to any new programmers is: Go with what your friends use, so they can help you until your profiecient, then look at other languages.
Posted by: Jack at October 25, 2005 12:02 AM
The instructions your computer actually carries out are in a language call Assembley code. This is not impossible to work out at all - this language is still taught to this day, even though more usable languages have been developed, solely as a lesson as to how to improve and streamline your code. If you know how the computer does what you tell it to, you can create shortcuts within your code that make it run quicker or more efficiently. On a slighty ulterior note, this is the way programs are 'cracked' by reverse engineers - so someone understands it still.
.NET coding is powerful but fairly over the top for these simple sorts of ciphers. There are free versions of Visual Studio or programs with similar functions (on Linux boxes there's Mono) designed for specific languages, eg J# (basically Java.NET) and C# (C or C++ .NET). I would disagree that compiled languages are "fiddly" - they make a lot more sense once you have grasped the real elementary stuff. Sure, some things you may have to take for granted (the initial line 'public static int Main(string[] args)' in C# I'm still not sure about) but once you know basic things like variables, strings, arrays and functions you're on your way. The only problem becomes can you think laterally enough to solve the problem at hand?
For those of you wanting a book, I've always found Sams "... In 24 hours" or "... In 10 Minutes" to be handy. They don't require much (any, really) knowledge of the subject before reading them, and they are very concise - you have to learn all this stuff and then use it in the next 2 months or so! I'm working through the C++ book at the moment and I've managed to understand most of it - if you really don't get some bits (pointers and references do my head in) then search the internet and look on forums, you won't be on your own with the problem.
Posted by: Richard at October 24, 2005 10:55 PM
Sums said 'First there is the native instruction set of your computer's CPU. This is a machine language that is almost impossible for humans to understand. (Not completely impossible, of course, but forget about it.)' My dad said that is a lot quicker but it takes so much longer to program, particularly with RISC (reduced instruction set computers), that it really isn't worth it.
Posted by: Ruth at October 24, 2005 10:17 PM
I didn't mean to imply that you have to spend money to program... just that VB is quite a nice language to just plug algorithms in, and most schools (and probably homes) will have some office application.
Notepad is quite nice if you're familiar with the language, but having an editor such as with VB is helpful, especially with object-oriented stuff.
Posted by: Ian at October 24, 2005 12:21 PM
Since you're all talking anout programming i just wont to know how complex a programs you're actually? and what do they do?
Posted by: alex at October 24, 2005 11:42 AM
For anyone looking to buy a book for a programming language, the 'in easy steps' range are very good value and very easy to learn from. They're about £8 on Amazon, and are available for a variety of languages.
Posted by: Jonathan at October 24, 2005 11:03 AM
Nicely put Sums, Python is slow, which is why I wouldn't use it for BF.
My teammate is good with C++, so any BF we would code in C++.
Just an addition, you say that gcc comes with OSX, it also comes with almost every flavour of linux too, as you do tend to compile software from source.
If I was to suggest a language, I would say Python to start as it has simple syntax and it's fast (as in writing/debugging). I would then suggest going to C++, as there both OOP (Object Orientated Programming) so the structure would be similar, just differnt commands and syntax, and C++ being more powerful and faster.
Posted by: Jack at October 23, 2005 10:44 PM
People should know that there are different kinds of programming language. First there is the native instruction set of your computer's CPU. This is a machine language that is almost impossible for humans to understand. (Not completely impossible, of course, but forget about it.) Second there are so-called compiled languages like c, c++, and pascal. These are human languages that can be translated into machine language by a special programme called a compiler. You write a programme. The compiler translates it. Then you run it. Thirdly, there are so-called interpreted languages like python, php, and javascript. In these languages you don't really write instructions for your computer's CPU but for another programme, called an interpreter. All the time you want to run your programme you have to have the interpreter running. The big difference between compiled languages and interpreted ones is that compilation is a one-off event, whereas interpretation is never-ending.
People should think carefully about what kind of language they want to learn.
On the whole, interpreted languages are much easier to learn. I agree with Jack that Python is particularly nice. You can get to the point where you are using Python to get something done quite quickly. The problem with interpreted languages is that they are slow. It doesn't matter for some things, but if you want to try some kind of brute force attack on a cipher (like you will probably have to in the final stage of this competition) then you are in trouble. For this kind of thing, a Python programme will run somewhere between 10 and 100 times slower than a similar C programme. That means that if the C programme takes an hour (which it might well do) the Python programme will take a couple of days. (Two days! And in that time you've no idea whether the programme is going to work.)
The reason is that in codebreaking you want to do fairly simple things an extraordinarily large number of times. With a compiled C programme your computer can get on with this. With an interpreted programme, however, the time taken to execute each of these simple steps is dwarfed by the time it takes to do the complex things needed to keep the interpreter working. So it's really inefficient.
The trouble with compiled languages is that they are fiddly. You have to master a lot of detail before you can get anything done, and this can be frustrating. It's worth it in the end, but the learning curve is steep.
(Java, by the way, is a hybrid. It's an interpreted language, but the interpreter is clever and compiles bits of the programme as it goes along. Unfortunately, Java is not particularly easy to learn.)
I disagree with the person who implied that you have to spend money on software if you want to programme. Not so! All you need is a decent text editor (There are many excellent free ones) and a compiler/interpreter. There are free compilers/interpreters for practically all languages. Eg, you can easily get the free interpreter for Python that Jack mentions, and for C you can get gcc. (If you are lucky enough to have a Mac with OS X, then these things will already be installed.) Maybe you have to spend money if you want a so-called Integrated Develoment Environment (IDE). But you don't need one of these. IDEs are useful for writing massive programmes with dozens or even hunrededs of inter-related files, but you're not going to be writing one of those. In any case, there are free IDEs. (Eg, on the Mac, there's XCode.)
I think you ought to save your money so that you can buy a decent book. You really need a book on your chosen programming language, because looking stuff up on the Internet doesn't give you the kind of overview that you need.
Sorry for the long post.
Posted by: Sums at October 23, 2005 08:46 PM
@Ian,
All you need to code in almost any language is notepad, a compiler and a guide to get you started. For example, if you wanted to learn python(a very good starting language) you could start for free with this:
http://notepad-plus.sourceforge.net/uk/site.htm
- A great text editor, that supports syntax colouring for a range of languages, and best of all it's free :D
http://www.python.org
- And download the free interpreter here, you can also find alot of tutorials/infomation regarding python. If you run linux it's very likely you have the interpreter already installed.
Python is a great language: powerful, elegant, portable and easy to learn. So none of you have an excuse about not being able to program :P.
Posted by: Jack at October 23, 2005 06:28 PM
4B happen to be written in English...
I do know what you mean though. I got majorly confused and was determined to prove there was a mistake in the cipher text.
I wish to itterate the hint may have given; don't translate using an online morse translator, as it gets rid of the 0000 which IS a morse character. You just need a more comprehensive list.
Then you do the decryption again, and you will see that it makes all sense rather than half sense :)
Posted by: Andy at October 23, 2005 05:54 PM
i get how to do 4b, but what language is it in?
Posted by: F at October 23, 2005 05:24 PM
Regarding programming languages, anyone who feels "I'll never be able to program because I don't have hundreds of pounds to spend on software", I came 28th last year programming entirely in MS Office's Visual Basic Macro editor. Which did suck quite a lot, but it did the job.
(Tools > Macros > Visual Basic Editor)
Posted by: Ian at October 23, 2005 05:06 PM
Harry, I know it's only Sunday but I feel I have to ask now- seeing as Challenge 5 goes on for two weeks, what will the time intervals be? Will they be particularly long, or will there just be a lot of points available for timing?
Posted by: Jess at October 23, 2005 11:56 AM








