This week google introduced "go" their new programming language. From the Go website:
No major systems language has emerged in over a decade, but over that time the computing landscape has changed tremendously. There are several trends:
- Computers are enormously quicker but software development is not faster.
- Dependency management is a big part of software development today but the “header files” of languages in the C tradition are antithetical to clean dependency analysis—and fast compilation.
- There is a growing rebellion against cumbersome type systems like those of Java and C++, pushing people towards dynamically typed languages such as Python and JavaScript.
- Some fundamental concepts such as garbage collection and parallel computation are not well supported by popular systems languages.
- The emergence of multicore computers has generated worry and confusion.
We believe it's worth trying again with a new language, a concurrent, garbage-collected language with fast compilation.
So I decided to install the GO compiler, so I could play around with it. I found it to be a little different than the instructions.
Step 1: edit your .bashrc and add these lines:
export GOROOT=$HOME/go
export GOARCH=386
export GOOS=linux
export GOBIN=$HOME/bin
export PATH=$GOBIN:$PATH
The last two are not listed on the GO site, but I needed them to compile.
Step 2. Create a bin folder
mkdir ~/bin
chmod 755 ~/bin
This was also not included in the instructions, this is so quietgcc has a place to sit, and be run by the installer.
Step 3. Run the following commands:
sudo apt-get install python-setuptools python-dev
sudo apt-get install mercurial
hg clone -r release https://go.googlecode.com/hg/ $GOROOT
This will pull down the latest copy of go. Next, you'll need the libraries to build go:
sudo apt-get install bison gcc libc6-dev ed make
Step 4: Build and install
cd $GOROOT/src
./all.bash
If all goes well, you'll see this screen:

Go has been successfully installed
I am using Ubuntu Linux, Karmic Koala with GCC 4.4.1
If you have any questions, feel free to contact me!
Tags: compiler, go, Linux, Programming, software, ubuntu
If you're reading this tutorial, it's likely because you googled how to read and write text files with C++. And it's probably a pretty lucky guess you're a beginner, so I'll try to explain as much as I can here to make it clear.
If you're thinking of getting into C++, hopefully this example will show you that it's not as complicated as commonly thought. C++ can be very difficult, but the performance advantages are worth the effort sometimes. Java and C# are definitely stealing marketshare from C++, but it still has it's place in the software development world, mainly in applications that require high performance. But that's for another article. Let's get started.
For this example, I'm using Bloodshed Dev C++, because it's simple, fast and free. You could just as easily use Visual C++ express, also free, but I feel that Dev C++ is far simpler, and better for learning the code.
Go to file->new and create a new project. Your options should look like this:
Start a new C++ project, and call it whatever you want. You can save the dev file wherever you feel neccessary. Go into options and choose a folder to put your executable:
Select Project->Project Options->(Build Options)
This will put your final executable in a folder you can easily get to when you decide to run it.
When you first create your project, you'll find the following code:
#include <cstdlib>
#include <iostream>
using namespace std; int main(int argc, char *argv[]) { system("PAUSE"); return EXIT_SUCCESS; }
This code is pretty self explanatory, and I won't go into it here, because we're going to erase it anyway. Select all the code in the window and delete it. Replace it with this:
<------ start code ------->
#include <iostream>
#include <fstream>
using namespace std; int main () { ofstream myfile; myfile.open ("test.txt"); myfile << "Hey this is my first written text file.\n"; myfile.close(); return 0; }
<------ end code -------->
After you have entered this code, save the file, then press Ctrl+F9. This will compile your executable. Run it from the command prompt, wherever you set it to build to. In my case, it looks like this:
When you run the executable it generates test.txt. Everything you specified in your cout gets written to a file. But lets examine how that happened.
The following code is the start of your program:
int main () {
This is the starting point of your program. Wherever you see main() that is the method you use to start your program. By putting this in you are telling the compiler where to begin. "Int" is the return type, which I will talk about in future tutorials. "int" stands for integer, which is what your main function must return. For this example, you don't need to be concerned with that part, but in the future, you will create funtions which return a datatype, and it will become more important.
The following opens up an output file stream:
ofstream myfile;
What this does is open up a stream for file output. You can get more info about ofstream here. By opening up this stream, you are preparing the compiler to output data to a file. You create an object called "myfile" that you can use to perform the necessary file output functions.
myfile.open ("test.txt");
As you've probably guessed, this is how you open your file. You are using that same ofstream object to open a file you specify within the parentheses. In our case, we are instructing the myfile object to open test.txt.
myfile << "Hey this is my first written text file.\n";
This portion of the code does the actual writing. You are essentially "pushing" the data to the file object using the << operator. You can see above the line of text, and then followed by \n. At the end of the string we put \n to indicate a new line. This is what's known as a "escape character" and is used to create a new line. Play around with this line and see what you can do with it. You can use \n as many times as needed to format your output with the proper line breaks.
Finally, we need to close the file:
l
myfile.close(); return 0;
By calling the close method of myfile, we are closing the file we wrote to. While not required, you should always close your files on execution. If you are building an application, whether it's just one person using it or hundreds, you should always close the files used, for resource usage purposes. Too many files loaded into memory can be a bad thing. Note that we also return 0, as a "success flag" for the compiler. The program exits at this point.
When you run the executable, it will generate a text file, as you've specified. This concludes our lesson. You can use these same methods to read another file, filter it and build it another file. You can also build something that will filter the strings being parsed, and write strings with different patterns, or pretty much anything you can imagine.
So copy this code, and try it out. If you have any questions, or need general help, be sure to ask in our forums. I will gladly help others trying to learn who are stuck on something. Till then, enjoy!!
Tags: c, Programming
So, you want to be a computer programmer? It's a lot easier (and cheaper) than it used to be. When I first started programming in the 90s, I remember having to shell out $300 bucks for a compiler package, and that was the "standard" edition. At the time it was pretty much your only option if you wanted to do C++ programming. A lot has changed since then.
If you want to do serious commercial development, you'll have to spend a considerable amount of money on a really good suite of tools to do so, that much hasn't changed. But what if you want to just learn programming? It would be helpful if you could find out whether it's your thing or not without spending hundreds or even thousands of dollars right? Well, thanks to a lot of hardworking and generous people, you can. I'll list off some free stuff you can get if you want to get rolling as a programmer. You might like it, you might not, but at least you'll find out without breaking the bank.
C++
There are tons of great free C++ tools out there. I'll list the two that I've tried, that I can vouch for.
To start out, I would recommend Dev C++ by Bloodshed Software. This is a simple, yet powerful compiler that is perfect for those simple lessons you'll be going through as a beginner. You don't need all the extra stuff yet, so a simple compiler like this is perfect. You would be surprised how powerful it is though, you can build a lot with this product.
When you start getting into building GUIs, installers and other things, step up to the Microsoft Visual Studio Express Edition. Even after a year I'm still shocked at how much they're giving away here. This product is good once you've gone through the beginner tutorials, and will provide awesome power for building apps.
Special Note: I don't generally don't recommend C++ to beginner programmers. This language can be very steep for beginners, and they get discouraged easily. If you are super dedicated, you can learn it, and the knowing the basics of this language will make it far easier to learn others.
C++ is a great language for those who want really fast, powerful programs, but it's not always the best solution. If you're building something relatively basic that doesn't require a lot of CPU power, you may want to look for something closer to C# or Visual Basic.
C# .net
So you wanna be a C# programmer? This is a fast growing language due it it's power and simplicity. It's easy to learn, and you can pump out a lot of things fast, which is why it's great for beginners.
Again, download the Microsoft Visual Studio Express C# edition. It's quite powerful and easy to learn.
Visual Basic .net
Visual Basic is exactly what it sounds like: basic. I may get flamed for saying this, but usually I steer even beginner programmers away from it. 10 years ago VB was a great program for beginners, but these days I think if you are going to invest time learning a language, you'd be better off going for C# . It is as simple as VB, yet more powerful and I feel the industry has been leaving VB for years. If you want to be employed as a programmer, there aren't as many avenues for VB programmers, with the exception of those working on legacy code.
If you do want to learn VB anyway, download the Microsoft Visual Studio Express VB edition. I've tried it, and it works very well.
Java
Getting into the java world is like stepping onto another planet. Java is, in fact a whole other world. There are arguments for and against Java, but in my personal opinion, I feel it's the most valuable of all the desktop development languages to learn. It's cross platform, and you can build software to anything from servers to PDAs, or microwave ovens. And Java is everywhere, so the employment opportunities are great.
Java is modeled after C, yet they started it from scratch so there aren't all the backward compatibility features of C++. It's not a difficult language to learn, but there is a lot to learn. It takes a long time to master, but it's a worthwhile effort.
I recommend getting the JDK with NetBeans. This environment will give you all the tools you need to get started as a Java programmer.
PHP
This is a web based language so it doesnt quite fit in with the above languages, but is easily the fastest growing and most popular language on the web. Want to get started with PHP? It's easy.
Get the Zend Core Package from Zend. This will install a fully functioning php webserver on your local machine, so you can build web apps right on your desktop. When you're done you can upload them to a webserver. You don't need to know much about setting up servers, or messing with Apache because the Core does all the work for you.
For an IDE, I suggest Notepad++. This is the absolute best tool for text editing I've ever seen. You can edit php files, or even files for all the languages up above, and it does syntax highlighting and complicated text features. Download it now!
So, if you want to get into desktop or web programming, you don't have to spend a dime. If you decide you really like it, and want to move on, there are products out there with far more features you'll need for serious commercial development. But why not spend some time learning with the free stuff? Heck you may not need anything more than that. I know quite a few professional developers who still use the free tools.
Have fun, and I'll post some more tools up here soon.
Here is some good info on getting started in programming and another list of free compilers.
Tags: .net, c, c programming, desktop programming, development, ide, java, java programming, php, php programming, Programming, software, visual basic, visual basic programming