Hi all,
A summary of my complains.
So, sadly, I can't do much functional programming on embedded system.
For example, should the compiler warns on {.compileTime, register, volatile, global.}?
How could I believe a compiler that can't generat clean C code?
Maybe this should be renamed to NIM_MAYBE_CONST.
IMHO, libaries should be carefully designed.
Too many options. I can find documentation on none, stack, region.
Now, Nim is getting ARC, the "one GC to rule them all". So none is dying now? But I am working on embedded systems. This is not a good signal to me.
Araq stated:
The point is: Nim APIs are not designed for chaining because for chaining use a 'chain' macro.
I can't buy this. I can't find the chain macro, either.
Oh, the last and the least one, those It templates do not look fancy to me now.
school.students.filterIt(it.grade == 3)
I will never use it to represent a student in this example.
- There are only two kinds of languages: the ones people complain about and the ones nobody uses.
- ― Bjarne Stroustrup
I hope Nim is getting better and better, day by day. Bye-bye.
Now, Nim is getting ARC, the "one GC to rule them all". So none is dying now? But I am working on embedded systems. This is not a good signal to me.
"Embedded systems" is a vast field and most systems have memory for a heap and you always have a heap. Proof: You can use static char myHeap[100]; in C as the storage for the heap.
"clean" C is meaningless, the C compilers do not agree on a set of warnings and warnings are not errors.
Interesting. All those stupid C compilers should treat -w as default, an explicit +w is needed to enable warnings, but not the opposite.
-w is used when invoking C compiler > How could I believe a compiler that can't generat clean C code?
There are test code that check correctness of Nim. https://github.com/nim-lang/Nim/tree/devel/tests
Warnings in C compiler are for preventing C programmer making mistake. I don't think how people make mistake when writing C by hand and generating it from a programm is same. Clean C code would be important when you work with C programmers who read or edit your code. But Nim genereated C code is not supposed to be read or edit by human. Correctness and efficiency are more important than generating a C code easy to read for humans in Nim.
NIM_CONST is nothing for C++
const in C++ doesn't help optimizer. https://stackoverflow.com/questions/212237/constants-and-compiler-optimization-in-c https://stackoverflow.com/questions/3896050/does-const-help-the-optimizer-c
const in C++ is for preventing programmer making mistake. I don't think it is important for Nim generated C++ code.
Oh, the last and the least one, those It templates do not look fancy to me now. > school.students.filterIt(it.grade == 3) > I will never use it to represent a student in this example.
I think it in filterIt template stands for iterator, not pronoun it. It is possible to make a filterIt template that take an identifier that is used insted of it.
template filterIt(s, name, pred: untyped): untyped =
var result = newSeq[type(s[0])]()
for name {.inject.} in items(s):
if pred: result.add(name)
result
let
temperatures = @[-272.15, -2.0, 24.5, 44.31, 99.9, -113.44]
acceptable = temperatures.filterIt(this, this < 50 and this > -10)
notAcceptable = temperatures.filterIt(that, that > 50 or that < -10)
doAssert acceptable == @[-2.0, 24.5, 44.31]
doAssert notAcceptable == @[-272.15, 99.9, -113.44]
I will never use it to represent a student in this example.
what does this even mean?