Just because you don't know them...doesn't mean they are not good Programming Languages...
I already talked about Old Programming Languages on 5 old Programming Languages you should know about and 5 old Programming Languages you might want to be aware of, so this time let's talk about Programming Languages that not that well known, but that you might find really interesting to work with...
To illustrate how those programming work, we're to use a very basic app called "Fibonacci List" which will simply output a list of requested Fibonacci numbers, for example if we ask for 5, it should return 0, 1, 1, 2, 3, 5.
Let's start our list with
Mercury (1995)
Mercury is a Logical/Functional Programming Language. It looks like Prolog, but feels like strict Haskell or pure OCalm.
On Linux, you can download the source from here and simply do
./CONFIGURE --> MAKE --> MAKE INSTALL
:- module fibonacci.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module string, int.
:- pred fibo(int::in, int::in, int::in, string::out) is det.
fibo(Num, A, B, Fibs) :-
(
if A = 0
then fibo(Num-1,A+B,B,Fib),
Fibs = int_to_string(A) ++ " " ++
int_to_string(B) ++ " " ++
int_to_string(A+B) ++ " " ++ Fib
else if A > 0, Num > 1
then fibo(Num-1,A+B,A,Fib),
Fibs = int_to_string(A+B) ++ " " ++ Fib
else Fibs = ""
).
main(!IO) :-
io.write_string("Enter a number: ",!IO),
io.read_line_as_string(Result, !IO),
( if
Result = ok(String),
string.to_int(string.strip(String), N)
then
fibo(N,0,1,Fibs),
io.write_string(Fibs,!IO)
else
io.write_string("Not a number...",!IO)
).
In order to run this, we need to compile it first by using
mmc --make -E name_of_file.m
You can read my Mercury Introduction here.
Falcon (2001)
Multiparadigm Programming Languages, supporting Procedural, Object Oriented, Prototype-based, Functional, Tabular and Message passing.
It should be already available on most Linux distributions, but if not you grab it from here.
It's syntax is fairly similar to many other programming languages, so it should be easy to pick up.
function fib(num,a,b)
result = ""
if a > 0 and num > 1
result = result + (a+b) + " " +
fib(num-1,a+b,a)
elif a == 0
result = "" + a + " " + b + " " +
(a+b) + " " + fib(num-1,a+b,b)
end
return result
end
print("Enter a number: ")
num = int( input() )
print(fib(num,0,1))
printl("")
In order to run simply type
falcon name_of_file.fal
You can read my Falcon introduction here.
Dao (2004)
Lightweight and optionally typed Programming Language. The author created out of frustration with Perl.
You can download the source code and extract it.
Then type
make -f Makefile.daomake PLATFORM
Where PLATFORM can be linux, macos, mingw and more...
Finally, run
make install
routine fib(num :int, a :int, b :int){
var result = ""
if (a > 0 and num > 1){
result = result + " " + (string)(a + b) +
fib(num - 1, a + b, a)
}else if (a == 0) {
result = (string)a + " " + (string)b + " " +
(string)(a + b) + fib(num - 1, a + b, b)
}
return result
}
io.write('Enter a number: ')
invar num = io.read()
io.writeln(fib((int)num, 0, 1))
To run this, simply type
dao name_of_file.dao
You can read my Dao Introduction here.
Factor (2003)
A Stack-Oriented Programming Language, based on Forth and Lisp.
If you like Forth, you will love Factor.
To install, simply go to the Factor Homepage and download the binary. Then run it.
You will get a listener and that's where you application will be executed.
Type the following on the Listener.
USE: tools.scaffold
"fibo" scaffold-work ! You might get an error saying
! that "fibo" doesn't exist...
! ignore that -:)
This will create a "fibo" folder inside the "work" folder inside your Factor installation folder.
Then edit the "fibo.factor" file that was generated.
! Copyright (C) 2018 Blag.
! See http://factorcode.org/license.txt for BSD license.
USING: math prettyprint kernel io math.parser command-line
namespaces sequences ;
IN: fibo
<PRIVATE
: ask-number ( -- ) "Enter a number: " print ;
: read-number ( -- n ) readln string>number ;
: list_fibo ( x -- )
1 0
pick 1 + [ dup . over over + rot drop ] times 3drop ;
PRIVATE>
: fibo ( -- ) ask-number read-number list_fibo ;
: fibo-run ( -- ) fibo ;
MAIN: fibo-run
On the Listener type
fibo run
You can read my Factor Introduction here.
io (2002)
Pure, dynamic, concurrent and accessible Programming Language. Inspired by Smalltalk, Self, NewtonScript, Act, Lisp and Lua.
To install it just follow the instructions on IO's Github.
#This method needs to go in one line...
fib := method(num,a,b,result,
if(a > 0 and num > 1)
then(result = result .. (a+b) .. " " ..
fib(num-1,a+b,a,result))
elseif(a == 0)
then(result = a .. " " .. b .. " " ..
(a+b) .. " " .. fib(num-1,a+b,b,result));
return result)
"Enter a number: " print
number := ReadLine readLine
fib(number asNumber,0,1,"") println
To run this simply do
io name_of_file.io
You can read my IO Introduction here.
Hope you try some...and see you next time -:)
Top comments (0)