Hello everyone,
I use several languages in my work and with big libraries (OpenCV, GDAL). My main language is C++, I use Python to script and sometime Julia. I'm using Nim from 4 weeks for a personal project and I love it.
I didn't write this post to talk about me but the future features that must be developed in Nim to become a main language like C/C++. Every year or mouth maybe a new language is created with lots of features to create everything, easy to learn/read/write, efficient ... but only some new languages gain popularity.
For me the features missing in Nim are by priority order:
1. C/C++ auto binding : A new programing language must propose a binding solution with an other language or ecosystem with lot of packages developed during several years and maintained. All new languages has their compiler and propose a binding feature often with C and sometime C++. But in my case, who going to develop a complete binding of very big library ? I use OpenCV and I don't want to change it by an other. There is a binding in GitHub (https://github.com/dom96/nim-opencv) but it isn't maintained since 2017. This is the main problem. Nim use C/C++ compilers like GCC and it's a great idea. Thanks to this particularity, the developer should be able to use easily a library without develop a binding and it must be done by the language. A good example is Julia that can call Python code directly in its code with the import keyword "pyimport". For Nim, I don't know how, maybe with a file descriptor to define include files and library path but without define functions and types binding. It's a big job but necessary for me.
2. Debugging tool : Nim code is compiled with several compilers but this implies using different debugger. I know well GDB but in Windows I never used Microsoft's debugger because I use an IDE. Furthermore, in my IDE the debugging commands are the same on Windows, Mac and Linux. I'm not saying that should create a wrapper to all debuggers but this work should be done by the IDE.
3. A great IDE : We can write our code with all editors like Vim or Notepad++ but they are only text editors. Un great language has a great IDE but it is useless to create an other editor only for Nim. For me the best solution is to choose an existing editor and create an plugin for it. I talk about Atom and VSCode, I use VSCode for all my development and a good plugins for Nim already exist. The problems are that the last version was published in February, the development is slow and there isn't a support for the debugging. This plugins should be managed by Nim (in the Nim repository) and a team should be focused on improving it.
It's my opinion and I'm not saying that will be easy but Nim has been released and lot of curious people will want to use it. It's better if it's easy. You can develop the best GC in world but if the language is hard to use then few developers will use it. Now you should think developer-friendly.
Thank you for reading me and sorry for my bad English.
Hi, AMoura.
I don't care about language popularity, university ranking and the like, specially the kind of popularity that one measures with tools, such as TIOBE index and Webometrics. Let me tell you why. Let us consider university ranking. There is a very low ranked university in Russia, which is Bauman State Technical University. In The Times Higher Education - World University Ranking, the Bauman University is bundled in the 801-1000 bracket, together with University of Lagos, São Paulo State University, Rochester Institute of Technology, Catholic University of Peru, and 200 other low impact institutions. You will probably conclude that alumni of such a low ranked school don't even know the periodic table... Well, they not only know the periodic table, but they invented it. The periodic table was discovered by Dmitri Mendeleev, who happened to be a professor at Bauman. You are receiving my answer thanks to the miracle of satellite-relayed long distance communications, which was invented by people from Bauman University. By the way, Sergei Korolev from Bauman created the first satellite, and the second, and the third probe to reach the moon, and the second, and the first probe to reach Venus, and the second, and all nine probes that reached Venus. The first man in orbit was another feat of Sergei Korolev, the father of astronautics. Sergei Korolev and Dmitri Mendeleev were not exceptions, sinc Bauman University has other bright alumni: Pavel Sukhoi (airplane designer), Andrey Tupolev (first supersonic commercial jet), Vladmir Chelomei (aerospace engineer), Nikolay Dollezhal (first nuclear reactor for producing electricity), Sergei Lebedev (created the first practical computer, which as used to launch Sputnik 1, the first artificial satellite), Alexander Kermudzhian (interplanetary rovers), Zou Jiahua (industrialization of China), etc. Anyway, we are here for discussing Nim. Then, let us discuss Nim. Here is how to call a C procedure from Nim:
1 -- Write the C procedure, and save it in, say, addints.c
// File: addints.c
int addTwoIntegers(int a, int b) {
return a + b; }
2 -- Compile the C procedure into a library:
› gcc -c addints.c
› ls *.o
addints.o
› ar rvs addlib.a addints.o
› ls *.a
addlib.a
2 -- Write a Nim program:
# File: addthem.nim
import os, strutils
{.compile: "addints.c".}
proc addTwoIntegers(a, b: cint): cint {.importc.}
when isMainModule:
echo addTwoIntegers(paramStr(1).parseInt.cint, 7)
3 -- Compile it and run:
› nim c --passL:addlib.a --nimcache:xx -d:release -o:sum.x addthem.nim
Hint: used config file '/etc/nim/nim.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: addthem [Processing]
CC: addints
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: addthem.nim
Hint: [Link]
Hint: [SuccessX]
› ./sum.x 35
42
It seems that Nim poses no problem for linking an application to C. Let us see the other way around. Let us link Nim to Lisp, which happens to be my favorite Language. I am using a Macintosh, therefore, I will link Nim programs to a .dylib dynamic library. The Lisp I will choose is Chez Scheme, one of the nicest compilers in existence:
1 -- Let us start with a Makefile, since the command line is somewhat long:
# Makefile
all:
nim c -d:danger --noMain --header\
--deadCodeElim:on --app:lib\
--opt:size --nimcache:./lixo\
-o:Fibonacci.dylib --gc:none fib.nim
2 -- Here is the nim program:
# This module provides a simple "Fibonacci"
# function to test Nim FFI.
# An asterisk * exports an identifier and
# makes it available for use by modules or
# other languages. E.g. FibNum* makes
# FibNum available with the "nfib" name.
proc FibNum*(n: int): int {.exportc: "nfib"} =
if n < 2: 1
elif n < 3: n
else:
FibNum(n - 3) +
FibNum(n - 2) +
FibNum(n - 2)
3 -- Finally, let us run the Nim programa from another language:
~/nim/libs$ scheme
Chez Scheme Version 9.5.3
Copyright 1984-2019 Cisco Systems, Inc.
> (load-shared-object "Fibonacci.dylib")
> (define fb (foreign-procedure "nfib" (int) int))
> (fb 5)
8
> (time (fb 42))
(time (fb 42))
no collections
0.001091174s elapsed cpu time
0.001445000s elapsed real time
0 bytes allocated
433494437
Hi, AMoura, thats me again. I think that the main problem with computer languages is not lack of features. My major concern about computer languages is that most of them do not keep backward compatibility. I liked the Yi text editor, which happened to be written in Haskell. Do you know why I quit using the Yi editor? Because I could not compile it anymore.
There are many pieces of software around that people stopped using simply because developers were not able to build the applications anymore. Consider the Daisy Model, which is so important in The Gaia Hypothesis and global warm studies. I wrote to the author, and he sent me the source code in Basic. The difficulty is that no Basic compiler available can build the thing.
Lisp is not a popular language by any means. However, there are many impressive Lisp applications. Here is a short list:
1 -- ACL2 -- a system developed by Boyer and Moore to prove the correction of hardware and applications. It is one of the most impressive programs that I know:
http://www.cs.utexas.edu/users/moore/acl2/
2 -- Maxima, Computer Algebra System:
http://maxima.sourceforge.net/
3 -- PTC Creo CAD/CAM allows you to design and manufacture from clothes and shoes to complex machines. It seems that the Jarvis butler in the film Iron Man was inspired on PTC. My students have a complimentary copy of PTC and, believe me, the thing is amazing, specially the programs in Lisp. Here is a link:
https://www.ptc.com/en/products/cad/creo
4 -- PVS. You probably saw PVS in the film The Marcian. Yes, that strange language that appears in the film is Lisp, doped with an overdose of macros:
https://github.com/nasa/pvslib/blob/master/power/exponentiation_aux.prf
5 -- Cyc is probably the most accomplished Artificial Intelligence program ever:
The list could go on and on, Mirai, Orbitz, Robot Motion Grammar, Biobike, Grammarly, Scream, Dendral, ... How could Lisp programmers write such beautiful pieces of software? I have a theory: They had time. Simple as that, they have time. Lisp programmers took years to create Cyc and Maxima. Such a lengthy effort was possible because Lisp does not change with time. You can still use the very Lisp programs that Svyatoslav Lavrov and Rifat Appazov used to launch artificial satellites and interplanetary probes.
What about Nim? I believe that Lisp does not become obsolete due to its high content of Mathematics. As you probably noticed, Mathematics does not change either. When I was a student at Cornell, my professor of Mathematics used a book written by Gauss, and except for being written in Latin, the book was by no means obsolete. Mathematics is optimized, it has a minimum of entities. Optimization is minimizing or maximizing a utility function. Lisp grammar is the smallest possible, therefore you cannot change it. Any change would make it larger, which is against the principles that govern Lisp evolution.
I hope that Nim finds a guiding principle that keeps it backward compatible with the work of the generations of programmers that will keep science moving.
I think for a language to take off, it needs to be able to delegate to the community, especially self-contained parts that will not impact interoperability between Nim users (unlike something like serialization/deserialization API). An editor plugin is pretty much self-contained and there is no interoperability issue so this fits the bill.
I think the comment is more related with wrapper-free interop like in zig lang.
For people like me (mere human -no pro-dev- ;oP ), a feature like this would make plenty of libraries suddenly accesible. I have tried (and failed) to wrap a few libs myself.
I agree that nimterop and company are great and that they are becoming even better. But it would be really nice not needing them.
wrapper free interop
Can that really work? Do zig, jai, vlang and all the other new candidates have high level gtk support at least, or C++ support for Qt, CGAL, BOOST? I don't think so.
For zig it may work for C, as zig does manually memory management, and as zig is basically a C better only.
My impression is that even Go is struggling with GTK, and Rust has put very much effort in GTK bindings.
And for which languages are really good Qt bindings available? I think only C++ and Python has full support.
For a high level language like Nim it is always hard, as Nim has automatic memory management, and as C interfaces are not well defined by header files -- is that *char a single string or a string array, is it in, out, who frees the memory.
> wrapper free interop
Can that really work? Do zig, jai, vlang and all the other new candidates have high level gtk support at least, or C++ support for Qt, CGAL, BOOST? I don't think so.
https://donpdonp.github.io/zootdeck
https://github.com/donpdonp/zootdeck/blob/master/src/gui/gtk.zig
The word "popular" is maybe a bad word and I can understand that somebody can disagree with it.
@edu500ac, you are passionate of Lisp and I understand that you are heap up when a guy say that a good language is a popular language. Lisp is certainly a good language and as you say lot of great applications or libraries was developed with it. But I'm an industrial developer and I create architecture and develop code for embedded board where the performance and an perfect memory management is primordial. We use C/C++ and my scientist co-workers use MatLab and Python to develop and test algorithm quickly. And my clients need code in C and C++ especially when your program must works in autonomous car or in a space robot like ExoMars. Then yes, COBOL, Fortran, Pascal etc are maybe great languages but they don't support all platforms or architectures and few people know them in my field of work.
Languages change, evolve and sometime disappear, now CNRS use Python instead of Scilab/Matlab to make scientific algorithms and some big companies (Electronic Arts, Red Hat) use RUST instead of C++. Why not Nim ? I like Nim because I can write easily my code and it offers me the capability to use my libraries in C++ in my personal project. Maybe one day in my work or never.
Thank you @mratsim for nimterop, I'll try it with OpenCV. Use GDB in Windows in not a solution because when I work on Windows then I use the Visual C++ compiler and never mingw. Yes only 3 paid full-time developers working on Nim and it's pity but I prefer this rather than a big company behind a language like Sun with Java.