Author Topic: Nimrod: An interesting language that might interest you guys  (Read 14478 times)

0 Members and 1 Guest are viewing this topic.

kryton9

  • Guest
Nimrod: An interesting language that might interest you guys
« on: September 14, 2013, 01:26:45 PM »
http://nimrod-code.org/

I just came across this language today. It has many cool features and bindings and
it and all its libraries are written in Nimrod.

List of libraries: Windows and Linux and wrapper libs:
http://nimrod-code.org/lib.html
« Last Edit: September 14, 2013, 01:39:15 PM by kryton9 »

JRS

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #1 on: September 14, 2013, 01:49:40 PM »
It looks very interesting and reminds me of Euphoria. It has a IUP binding and cross platform. I think some benchmarking is in order.

It doesn't look too difficult creating a scripting language binding. (based on popular scripting language interfaces already in progress or completed)

Quote
Why learn Another Language?

The first answer is: because it's fun. Just as a botanist is excited to find a new plant, programming language nerds like trying out new languages. Secondly, any new language uses new strategies for dealing with the basic problems of communicating algorithms to computers and intents to other programmers. So it is the most sincere form of criticism: a working implementation to constrast with the approaches taken by other languages. There's far too much armchairing and bikeshedding involved in discussions about languages, and you have to admire a guy who has spent a sizeable chunk of his life trying something new like Nimrod's author, Andreas Rumpf.

If you're not a language nerd, a new language might provide a solution to an actual computing problem you are facing. (Who would have guessed?)
« Last Edit: September 21, 2013, 09:53:04 PM by John »

JRS

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #2 on: September 14, 2013, 06:29:42 PM »
I was able to get the Nimrod IUP example to compile and run.



Code: [Select]
# IupTabs: Creates a IupTabs control.

import iup

discard iup.Open(nil, nil)

var vbox1 = Iup.Vbox(Iup.Label("Inside Tab A"), Iup.Button("Button A", ""), nil)
var vbox2 = Iup.Vbox(Iup.Label("Inside Tab B"), Iup.Button("Button B", ""), nil)

Iup.SetAttribute(vbox1, "TABTITLE", "Tab A")
Iup.SetAttribute(vbox2, "TABTITLE", "Tab B")

var tabs1 = Iup.Tabs(vbox1, vbox2, nil)

vbox1 = Iup.Vbox(Iup.Label("Inside Tab C"), Iup.Button("Button C", ""), nil)
vbox2 = Iup.Vbox(Iup.Label("Inside Tab D"), Iup.Button("Button D", ""), nil)

Iup.SetAttribute(vbox1, "TABTITLE", "Tab C")
Iup.SetAttribute(vbox2, "TABTITLE", "Tab D")

var tabs2 = Iup.Tabs(vbox1, vbox2, nil)
Iup.SetAttribute(tabs2, "TABTYPE", "LEFT")

var box = Iup.Hbox(tabs1, tabs2, nil)
Iup.SetAttribute(box, "MARGIN", "10x10")
Iup.SetAttribute(box, "GAP", "10")

var dlg = Iup.Dialog(box)
Iup.SetAttribute(dlg, "TITLE", "IupTabs")
Iup.SetAttribute(dlg, "SIZE", "200x100")

discard Iup.ShowXY(dlg, IUP_CENTER, IUP_CENTER)
discard Iup.MainLoop()
Iup.Close()

jrs@laptop:~/nimrod/examples$ nimrod c -d:release iupex1.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: iupex1 [Processing]
Hint: iup [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/iupex1.o examples/nimcache/iupex1.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/system.o examples/nimcache/system.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/iup.o examples/nimcache/iup.c
gcc   -o /home/jrs/nimrod/examples/iupex1  examples/nimcache/iup.o examples/nimcache/system.o examples/nimcache/iupex1.o  -ldl
Hint: operation successful (8425 lines compiled; 0.498 sec total; 9.922MB) [SuccessX]
jrs@laptop:~/nimrod/examples$ ./iupex1
jrs@laptop:~/nimrod/examples$ ls -l iupex1
-rwxrwxr-x 1 jrs jrs 24456 Sep 14 19:22 iupex1
jrs@laptop:~/nimrod/examples$

Here is the ScriptBasic IUP extension module version of the above.

Code: [Select]
' Creates a Iup::Tabs control.

IMPORT iup.bas

GLOBAL CONST IUP_CENTER = 0xFFFF

Iup::Open()

vbox1 = Iup::Vbox(Iup::Label("Inside Tab A"), Iup::Button("Button A", ""))
vbox2 = Iup::Vbox(Iup::Label("Inside Tab B"), Iup::Button("Button B", ""))

Iup::SetAttribute(vbox1, "TABTITLE", "Tab A")
Iup::SetAttribute(vbox2, "TABTITLE", "Tab B")

tabs1 = Iup::Tabs(vbox1, vbox2)

vbox1 = Iup::Vbox(Iup::Label("Inside Tab C"), Iup::Button("Button C", ""))
vbox2 = Iup::Vbox(Iup::Label("Inside Tab D"), Iup::Button("Button D", ""))

Iup::SetAttribute(vbox1, "TABTITLE", "Tab C")
Iup::SetAttribute(vbox2, "TABTITLE", "Tab D")

tabs2 = Iup::Tabs(vbox1, vbox2)
Iup::SetAttribute(tabs2, "TABTYPE", "LEFT")

box = Iup::Hbox(tabs1, tabs2)
Iup::SetAttribute(box, "MARGIN", "10x10")
Iup::SetAttribute(box, "GAP", "10")

dlg = Iup::Dialog(box)
Iup::SetAttribute(dlg, "TITLE", "IupTabs")
Iup::SetAttribute(dlg, "SIZE", "200x80")

Iup::ShowXY (dlg, IUP_CENTER, IUP_CENTER)
Iup::MainLoop ()
Iup::Close ()

END
« Last Edit: September 14, 2013, 10:05:49 PM by John »

kryton9

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #3 on: September 15, 2013, 05:13:19 PM »
Wow John, you are able to wrap your brain around things a lot faster than I can!  I am impressed.

JRS

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #4 on: September 15, 2013, 06:37:57 PM »
If you experiment (play) with enough languages, they all start looking the same.


JRS

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #5 on: September 18, 2013, 10:48:59 PM »
I thought I would try Nimrod under Windows XP.



  • windows - Contains a wrapper for the Win32 API.
  • ole2 - Contains GUIDs for OLE2 automation support.
  • shellapi - Contains a wrapper for the shellapi.h header.
  • shfolder - Contains a wrapper for the shfolder.h header.
  • mmsystem - Contains a wrapper for the mmsystem.h header.
  • nb30 - This module contains the definitions for portable NetBIOS 3.0 support.
Code: [Select]
# test a Windows GUI application

import
  windows, shellapi, nb30, mmsystem, shfolder

#proc MessageBox(hWnd: int, lpText, lpCaption: CString, uType: uint): int
#  {stdcall, import: "MessageBox", header: "<windows.h>"}

discard MessageBox(0, "Hello World!", "Nimrod GUI Application", 0)

F:\Nimrod\examples>nimrod c -d:release wingui.nim
f:\nimrod\config\nimrod.cfg(36, 11) Hint: added path: 'C:\Documents and Settings\John\.babel\libs\' [Path]
Hint: used config file 'F:\Nimrod\config\nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: wingui [Processing]
Hint: windows [Processing]
Hint: shellapi [Processing]
Hint: nb30 [Processing]
Hint: mmsystem [Processing]
Hint: shfolder [Processing]
gcc.exe   -o f:\nimrod\examples\wingui.exe  f:\nimrod\examples\nimcache\shfolder.o f:\nimrod\examples\nimcache\mmsystem.o f:\
nimrod\examples\nimcache\nb30.o f:\nimrod\examples\nimcache\shellapi.o f:\nimrod\examples\nimcache\windows.o f:\nimrod\exampl
es\nimcache\system.o f:\nimrod\examples\nimcache\wingui.o
Hint: operation successful (35390 lines compiled; 21.982 sec total; 23.235MB) [SuccessX]

F:\Nimrod\examples>wingui
F:\Nimrod\examples>dir wingui.exe
 Volume in drive F is Dev
 Volume Serial Number is 0C60-620E

 Directory of F:\Nimrod\examples

09/18/2013  11:36 PM            79,023 wingui.exe
               1 File(s)         79,023 bytes
               0 Dir(s)  36,617,568,256 bytes free

F:\Nimrod\examples>

Nimrod also has an interpretive mode that is interesting.

F:\Nimrod\examples>nimrod i
f:\nimrod\config\nimrod.cfg(36, 11) Hint: added path: 'C:\Documents and Settings\John\.babel\libs\' [Path]
Hint: used config file 'F:\Nimrod\config\nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: stdin [Processing]
>>> echo "Hello World"
Hello World
>>> var x: int
>>> x = 123
>>> echo(x)
123
>>> quit()
f:\nimrod\examples\stdin(5, 5) Hint: quit() called [QuitCalled]

F:\Nimrod\examples>

This is a nice language feature. (From)

Quote
From statement

We have already seen the simple import statement that just imports all exported symbols. An alternative that only imports listed symbols is the from import statement:

from mymodule import x, y, z

Here is the Windows screen shot of the IUP tab demo. (same as the Linux code above)


« Last Edit: September 19, 2013, 05:13:00 PM by John »

kryton9

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #6 on: September 19, 2013, 01:43:58 PM »
Thanks John, I think I will download and try nimrod out once I install ubuntu on my netbook as dual boot instead of virtual machine.

JRS

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #7 on: September 19, 2013, 01:47:03 PM »
Let me know if you need any help getting there.

kryton9

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #8 on: September 19, 2013, 01:56:29 PM »
John which version of Ubuntu are you using?

My netbook is a dual core AMD, but only 1gHz speed, I did upgrade the RAM to 4gb(max the netbook can take).

JRS

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #9 on: September 19, 2013, 02:12:51 PM »
I run Ubuntu 12.04 LTS 64 bit on my Toshiba 64 bit dual core laptop.

kryton9

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #10 on: September 19, 2013, 02:32:35 PM »
Thanks John, will try that out.

kryton9

  • Guest
ubuntu on messed up windows
« Reply #11 on: September 20, 2013, 12:14:10 AM »
I tried installing ubuntu, the 64 bit version would give an error, so downloaded and installed the 32 bit version.
Got ubuntu installed but it messed up my Windows boot and then when I went to repair Windows it messed up grub so I lost both ubuntu and windows.

Anyways, decided since things were messed up, just to play with ubuntu, so I did a clean install.

I finally got nimrod to compile and compiled the ide Aporia.  I can't get Aporia to run, probably because of missing dependencies but I get no messages.
I couldn't figure out how to get the dependencies in ubuntu. I tried apt-get "name of dependency" but no luck.

I copied and pasted your iup example code john in a text editor and save it as john.nim.  I got it to compile, but it won't run because I can't figure out how to get iup.
I read on the forums about how nimrod is useless without the module libraries and they were talking about coming up with a portable bundle. But I had no luck.

Here is the c code it generated however after the compile in release mode.

Code: C
  1. /* Generated by Nimrod Compiler v0.9.2 */
  2. /*   (c) 2012 Andreas Rumpf */
  3. /* The generated code is subject to the original license. */
  4. /* Compiled for: Linux, i386, gcc */
  5. /* Command for C compiler:
  6.    gcc -c  -w -O3 -fno-strict-aliasing  -I/home/k9/lib -o bin/nimrods/examples/nimcache/john.o bin/nimrods/examples/nimcache/john.c */
  7. #define NIM_INTBITS 32
  8. #include "nimbase.h"
  9. typedef struct ihandle67212 ihandle67212;
  10. typedef N_CDECL_PTR(int, TY67311) (int* argc, NCSTRING** argv);
  11. typedef N_CDECL_PTR(ihandle67212*, TY67680) (ihandle67212* child, ...);
  12. typedef N_CDECL_PTR(ihandle67212*, TY67789) (NCSTRING title);
  13. typedef N_CDECL_PTR(ihandle67212*, TY67773) (NCSTRING title, NCSTRING action);
  14. typedef N_CDECL_PTR(void, TY67476) (ihandle67212* ih, NCSTRING name, NCSTRING value);
  15. typedef N_CDECL_PTR(ihandle67212*, TY67820) (ihandle67212* child, ...);
  16. typedef N_CDECL_PTR(ihandle67212*, TY67698) (ihandle67212* child, ...);
  17. typedef N_CDECL_PTR(ihandle67212*, TY67782) (ihandle67212* child);
  18. typedef N_CDECL_PTR(int, TY67458) (ihandle67212* ih, int x, int y);
  19. typedef N_CDECL_PTR(int, TY67324) (void);
  20. typedef N_CDECL_PTR(void, TY67318) (void);
  21. struct ihandle67212 {
  22. char dummy;
  23. };
  24. static N_INLINE(void, initStackBottom)(void);
  25. N_NOINLINE(void, setStackBottom)(void* thestackbottom);
  26. N_NOINLINE(void, systemInit)(void);
  27. N_NOINLINE(void, systemDatInit)(void);
  28. N_NOINLINE(void, iupInit)(void);
  29. N_NOINLINE(void, iupDatInit)(void);
  30. N_NOINLINE(void, johnInit)(void);
  31. N_NOINLINE(void, johnDatInit)(void);
  32. extern TY67311 Dl_67310;
  33. ihandle67212* vbox1_70003;
  34. extern TY67680 Dl_67679;
  35. extern TY67789 Dl_67788;
  36. extern TY67773 Dl_67772;
  37. ihandle67212* vbox2_70005;
  38. extern TY67476 Dl_67475;
  39. ihandle67212* tabs1_70009;
  40. extern TY67820 Dl_67819;
  41. ihandle67212* tabs2_70015;
  42. ihandle67212* box_70018;
  43. extern TY67698 Dl_67697;
  44. ihandle67212* dlg_70022;
  45. extern TY67782 Dl_67781;
  46. extern TY67458 Dl_67457;
  47. extern TY67324 Dl_67323;
  48. extern TY67318 Dl_67317;
  49.  
  50. static N_INLINE(void, initStackBottom)(void) {
  51.         void* volatile locals;
  52.         locals = 0;
  53.         locals = ((void*) (&locals));
  54.         setStackBottom(locals);
  55. }
  56. int cmdCount;
  57. char** cmdLine;
  58. char** gEnv;
  59. N_CDECL(void, NimMain)(void) {
  60.         systemDatInit();
  61.         iupDatInit();
  62.         johnDatInit();
  63.         initStackBottom();
  64.         systemInit();
  65.         iupInit();
  66.         johnInit();
  67. }
  68. int main(int argc, char** args, char** env) {
  69.         cmdLine = args;
  70.         cmdCount = argc;
  71.         gEnv = env;
  72.         NimMain();
  73.         return nim_program_result;
  74. }
  75. N_NOINLINE(void, johnInit)(void) {
  76.         int LOC1;
  77.         ihandle67212* LOC2;
  78.         ihandle67212* LOC3;
  79.         ihandle67212* LOC4;
  80.         ihandle67212* LOC5;
  81.         ihandle67212* LOC6;
  82.         ihandle67212* LOC7;
  83.         ihandle67212* LOC8;
  84.         ihandle67212* LOC9;
  85.         int LOC10;
  86.         int LOC11;
  87.         LOC1 = Dl_67310(NIM_NIL, NIM_NIL);
  88.         LOC2 = Dl_67788("Inside Tab A");
  89.         LOC3 = Dl_67772("Button A", "");
  90.         vbox1_70003 = Dl_67679(LOC2, LOC3, NIM_NIL);
  91.         LOC4 = Dl_67788("Inside Tab B");
  92.         LOC5 = Dl_67772("Button B", "");
  93.         vbox2_70005 = Dl_67679(LOC4, LOC5, NIM_NIL);
  94.         Dl_67475(vbox1_70003, "TABTITLE", "Tab A");
  95.         Dl_67475(vbox2_70005, "TABTITLE", "Tab B");
  96.         tabs1_70009 = Dl_67819(vbox1_70003, vbox2_70005, NIM_NIL);
  97.         LOC6 = Dl_67788("Inside Tab C");
  98.         LOC7 = Dl_67772("Button C", "");
  99.         vbox1_70003 = Dl_67679(LOC6, LOC7, NIM_NIL);
  100.         LOC8 = Dl_67788("Inside Tab D");
  101.         LOC9 = Dl_67772("Button D", "");
  102.         vbox2_70005 = Dl_67679(LOC8, LOC9, NIM_NIL);
  103.         Dl_67475(vbox1_70003, "TABTITLE", "Tab C");
  104.         Dl_67475(vbox2_70005, "TABTITLE", "Tab D");
  105.         tabs2_70015 = Dl_67819(vbox1_70003, vbox2_70005, NIM_NIL);
  106.         Dl_67475(tabs2_70015, "TABTYPE", "LEFT");
  107.         box_70018 = Dl_67697(tabs1_70009, tabs2_70015, NIM_NIL);
  108.         Dl_67475(box_70018, "MARGIN", "10x10");
  109.         Dl_67475(box_70018, "GAP", "10");
  110.         dlg_70022 = Dl_67781(box_70018);
  111.         Dl_67475(dlg_70022, "TITLE", "IupTabs");
  112.         Dl_67475(dlg_70022, "SIZE", "200x100");
  113.         LOC10 = Dl_67457(dlg_70022, ((int) 65535), ((int) 65535));
  114.         LOC11 = Dl_67323();
  115.         Dl_67317();
  116. }
  117.  
  118. N_NOINLINE(void, johnDatInit)(void) {
  119. }
  120.  

Will try again tomorrow after some sleep. Maybe better luck then.

Screenshot of trying to get IUP, don't know what is wrong? Any help would be appreciated John, thanks in advance.


X
« Last Edit: September 20, 2013, 12:28:40 AM by kryton9 »

Charles Pegge

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #12 on: September 20, 2013, 01:04:46 AM »

Simple practical test for a programming language: Search for it using Google images :)

JRS

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #13 on: September 20, 2013, 07:44:49 AM »
You will need to download and install the IUP libraries from the IUP site. (selecting the proper distribution for your OS) Unzip the the archives (IUP & CD) to a temp directory. Within these directories is an install.sh and a install-dev.sh script to actually install IUP/CD in the proper system directories. (use sudo)

Note I had to change the Nimrod IUP support file to indicate I was running IUP 3.8. Change the IF Linux logic to use libiup.so eliminating the version numbers within the parentheses.

Have you already installed development essentials? (assuming you did if you got Nimrod to compile)

JRS

  • Guest
Re: Nimrod: An interesting language that might interest you guys
« Reply #14 on: September 20, 2013, 11:05:56 PM »
Kent,

Here is a simple Gtk Nimrod Linux example.




ex5.nim
Code: [Select]
import
  glib2, gtk2

proc destroy(widget: pWidget, data: pgpointer){.cdecl.} =
  main_quit()

proc widgetDestroy(w: PWidget) {.cdecl.} =
  destroy(w)

nimrod_init()
var window = window_new(WINDOW_TOPLEVEL)
var button = button_new("Click me")
set_border_width(Window, 5)
add(window, button)
discard signal_connect(window, "destroy",
                       SIGNAL_FUNC(ex5.destroy), nil)
discard signal_connect_object(button, "clicked",
                              SIGNAL_FUNC(widgetDestroy),
                              window)
show(button)
show(window)
main()