Archive

Archive for the ‘programming language’ Category

Getting started with the Rust programming language

December 24, 2014 Leave a comment

I heard a lot of good things about Mozilla’s Rust prog. language, so I decided to give it a try. A very nice starting point is The Rust Guide.

Installation

$ curl -s https://static.rust-lang.org/rustup.sh | sudo sh

I modified this script a little bit:

#!/bin/sh

DEST=/tmp

cd $DEST
rm -f $DEST/rustup.sh
wget https://static.rust-lang.org/rustup.sh -O $DEST/rustup.sh
sudo sh $DEST/rustup.sh

But it does the same thing. If you install Rust via this rustup.sh script, it has two advantages: (1) it installs the latest version of Rust, and (2) it also installs Cargo, the package manager and build system of Rust.

Print the version number: “rustc -V“.

Hello World

// hello_world.rs
fn main() {
    println!("Hello, World!");
}

Compile it with “rustc hello_world.rs“.

Troubleshooting
Under Ubuntu I had no problems, but under Manjaro got the following error: “rustc: error while loading shared libraries: librustc_driver-4e7c5e5c.so: cannot open shared object file: No such file or directory“.

Solution #1
Add the following line to your ~/.bashrc:

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib

Solution #2
Create the file /etc/ld.so.conf.d/rust.conf with the following content:

/usr/local/lib

Then execute the command “ldconfig” as root.

More info
Check out The Rust Guide.

Categories: manjaro, programming language, ubuntu Tags:

Learn a language in a few minutes

November 16, 2014 Leave a comment

Short summaries of different programming languages: http://learnxinyminutes.com/ .

Getting started with Clojure

December 6, 2013 Leave a comment

I wrote my first “Hello World” program in Clojure :) Here I sum up what I managed to figure out.

Clojure (pronounced as “closure“) is a dialect of the Lisp programming language created by Rich Hickey. Clojure is a functional general-purpose language, and runs on the Java Virtual Machine, Common Language Runtime, and JavaScript engines.” (via wikipedia)

Learning a new language, especially a new programming paradigm is always useful. I’ve been interested in functional programming for a long time but I could never find time to dive into it. Once I started to learn Haskell but at Chapter 2 I gave up. Maybe once… However, I heard very good things about Clojure, so I would like to investigate it from a closer range. I also like the idea that it’s built upon the JVM.

Mark Volkmann wrote an excellent introduction to the language, it’s a very good starting point.

Hello World
Clojure is built upon the JVM. The good news is that you don’t need to download different JAR files and put them to the classpath. There is an excellent command-line tool called Leiningen (“lein” for short) that does this job for you. Steps to follow:

  • download the lein script
  • put it in your PATH (I put it to ~/bin)
  • make it executable (chmod u+x lein)
  • launch it (it will download the necessary files)

Create a new project:

lein new app hello

Lein will make the folder “hello” and it will create a simple project structure.

Open the file src/hello/core.clj and edit the last line:

  ...
  (println "Hello Clojure!"))

Enter the project “hello” (the folder where the file project.clj is placed) and run the project:

lein run

Normally you should see the “Hello Clojure!” output. Starting the JVM is expensive, the runtime of this simple basic script is more than 4 seconds on my laptop. But I’m pretty sure that once the JVM is loaded, it’s fast.

Links

Categories: programming language Tags:

Cobol Tutorial

January 14, 2013 Leave a comment

Just for fun: Cobol tutorial.

To be clear, I don’t ever want to touch Cobol. This is just for the record :)

Categories: fun, programming language Tags: ,

Side-by-side comparisons of programming languages

Programming Language Naming Patterns

February 18, 2012 Leave a comment

Most of you have noticed that programming language names tend to fall in several different themes. Here is an attempt to catalogue them.

http://c2.com/cgi/wiki?ProgrammingLanguageNamingPatterns

Getting started with the Haskell programming language

February 9, 2011 Leave a comment

Some quotes from Wikipedia:

Haskell is a standardized, general-purpose purely functional programming language…
The language continues to evolve rapidly, with the Glasgow Haskell Compiler (GHC) implementation representing the current de facto standard.
It is a purely functional language, which means that in general, functions in Haskell do not have side effects.
There is an active community around the language, and more than 2600 third-party open-source libraries and tools are available in the online package repository Hackage.

Installation

sudo apt-get install haskell-platform

Hello, World! (compiled)

Create the file hello.hs:

main = putStrLn "Hello, World!"

Compile it:

ghc hello.hs -o hello

Run it with ./hello.

Hello, World! (interpreted)

#!/usr/bin/runghc

main = putStrLn "Hello, World!"

Then “chmod u+x hello.hs” and “./hello.hs“.

Tutorials

There are tons of tutorials on the Web.

Links

Follow

Get every new post delivered to your Inbox.

Join 76 other followers