EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: legacy on September 22, 2013, 03:07:52 am

Title: nimrod, new language, interesting compiler/interpreter
Post by: legacy on September 22, 2013, 03:07:52 am
nimrod (http://nimrod-code.org/tut1.html) appears as a mashup between python and pascal, pretty cool, let's have a see !

i am discussing (http://forum.nimrod-code.org/t/251) about any usage in micro controller.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: Bored@Work on September 22, 2013, 06:44:15 am
Excuse me while I yawn.

The last thing the world needs is another programming language. Especially not the "me too" kind.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: jancumps on September 22, 2013, 07:09:09 am
So the number of blanks at the beginning of a line have a meaning in nimrod  :o
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: BravoV on September 22, 2013, 07:44:18 am
Any reasons why we should even consider it ? Please, not just because its hip, new & cool.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: AndreasF on September 22, 2013, 08:33:59 am
Quote
Native code generation (currently via compilation to C)...

So, it sounds like just another higher-level abstraction on top of C. I agree with the others: it doesn't sound very useful (yet).
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: legacy on September 22, 2013, 12:58:54 pm
it is elegant and well defined about the grammar, two things in where C is lacking a lot!
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: mrflibble on September 22, 2013, 02:33:51 pm
This looks awesome! Time to take action now and ... mark it down in the agenda to take another look in 5 years or so.

I mean over many years python managed to get from WTF-are-they-thinking  to  Not-great-but-usable. So maybe nimrod can do the same. From what I gathered from the FAQ + quick scan of docs the current state is ... meh, come back in 5 years.

If you currently happen to be looking for something better than C for embedded, just use C++. That at least takes care of some of the "C is not elegant enough"...
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: amyk on September 22, 2013, 02:44:21 pm
So the number of blanks at the beginning of a line have a meaning in nimrod  :o
Even for the comments... :o

And as for the name... it doesn't exactly inspire confidence (http://en.wiktionary.org/wiki/nimrod).
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: c4757p on September 22, 2013, 03:07:43 pm
it is elegant and well defined about the grammar, two things in where C is lacking a lot!

The former is subjective and the latter is false.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: andyturk on September 22, 2013, 03:27:56 pm
... over many years python managed to get from WTF-are-they-thinking  to  Not-great-but-usable. So maybe nimrod can do the same.
Looks like nimrod is yet another untyped scripting language that's sensitive to indentation. Yuck! I thought the programming world learned the lesson that tabs/spaces shouldn't be significant decades ago (e.g., FORTRAN, Make, etc.). I blame Python for spreading the whitespace disease.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: legacy on September 22, 2013, 03:28:52 pm
false ? C has an ugly grammar

e.g.

if (a=2) // instead of if(a==2)
{
}

this is horrible, and may cause a lot of troubles !

switch (ch)
{
case a:
// break;
case b:
break
}

the missing of a break may be a mistake and may cause a lot of troubles

etc etc

too ugly grammar, not safe at all, and this is the reason why you'd go for Misra checker !
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: c4757p on September 22, 2013, 03:34:16 pm
Ugly? Maybe. I really like it.

But not well defined? Horseshit. And that's the part I said was false.

I fail to see what's wrong with any of those.

Code: [Select]
if (a=2) {}

Yep, you're setting 'a' equal to two, then using it as a Boolean. What's hard about that? I'd say "not well defined" would be using the same damn operator for comparison and assignment. And modern compilers will complain about that with warnings turned on, as anybody who has no delusions of being a macho man-coder will have done.

Code: [Select]
switch (ch)
{
case a:
// break;
case b:
break
}

Again, perfectly consistent. The "case" lines are labels, not blocks, you jump to them and then keep going. The only way you'd be prone to leaving out 'break' is if you don't understand that they are labels. And if you don't understand the language, of course you'll screw it up. If you want blocks instead of labels, you're free to use the if/else-if chains that are used in Python.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: sleemanj on September 22, 2013, 03:59:31 pm
I blame Python for spreading the whitespace disease.

It's quite a shame really, if Python had brace denoted blocks rather than the silly whitespace is important, I think it could have really been a lot more successful, it is not a too bad language as I recall, apart from the bloody whitespace.

As for nimrod... I don't really see a place for it.  Especially not in microcontrollers.

There is absolutely a market there for a higher level (or perhaps simply better) language than C/C++ that could be used in the tight confines of microcontrollers, but this ain't it. 
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: free_electron on September 22, 2013, 04:02:10 pm
Sensitive to indentation ? Will somebody shoot it please before it spreads like pestulence ?
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: mrflibble on September 22, 2013, 04:13:29 pm
Looks like nimrod is yet another untyped scripting language that's sensitive to indentation. Yuck! I thought the programming world learned the lesson that tabs/spaces shouldn't be significant decades ago (e.g., FORTRAN, Make, etc.). I blame Python for spreading the whitespace disease.

Heh, you just touched on pet peeve #1 regarding Python. Many many moons ago when I wrote my first Makefile it didn't work.. check it... mmmh, looks right. Check it again.... wtf? it really seems to be right?!? Oh surely not? Check a working example .... mmmmh, that has tabs in in, I used spaces. Naaaaaaah, that can't be it... But just to be sure, lets replace with tabs. GNNNNN with tabs it's working.  :wtf:  :wtf:  :wtf: Okay, where's the lynch mob? I wanna join!  :box:

And then years later Python comes along and does the same thing. BAM! Instant dislike! And the language features + lack of libs at the time didn't really motivate to use it either. So screw that. Only fairly recently I had reason to check out Python again. Alright, enough libs + other stuff around to make it doable. I still thoroughly despise the F-ing indentation as language construct though.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: c4757p on September 22, 2013, 04:18:57 pm
I actually really like Python for quick, script-y things, but I'd definitely like it a bit more without the stupid indentation thing.

At least the indentation rules aren't completely bizarre. Generally, just following "standard" indenting conventions will produce valid Python.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: vvanders on September 22, 2013, 04:37:01 pm
Not really understanding the Python hate, just set your editor to insert spaces as tabs @ 4 spaces and I've never had any issues. I actually like the whitespace because it forces consistency which is more important to me than whatever coding standards you are using.

Of all the scripting languages I've found I like python the most(although Lua has a special place in my heart for being so compact and bloody fast for a scripting language).
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: legacy on September 22, 2013, 04:44:11 pm
I am a C programmer but i do not like C, i use it just cause i have no other language.

i use
- SierraC for 68000 (it is C89, very old but prettier than gcc-m68k)
- AnalogDevices VisualDSP++ C for Blackfin
- SGI MIPS PRO C/C++ for IRIX
- Cosmic C for 683xx and 68hc11 (it runs on XP and it has Misra checker plugin)
- SONY PSX Gcc
- MIPS.SDE C, for MIPS32
- KEIL ucVision C/C++ for Arm
- MPLAB C for dsPIC
- gcc for powerpc, super hitachi, x86

i have modula2/3 (based on gcc) ables to crosscompile for
- host=x86, target=PowerPC
- host=x86, target=arm (nintendo GBA)
- host=x86, target=avr8

i have freePascal ables to crosscompile for
- host=x86, target=PowerPC
- host=x86, target=arm (nintendo GBA)

i have green hills ADA
- host=x86/linux, target=PowerPC
- host=sparc/sunOS, target=PowerPC

i have gnat-ADA able to compile for
- host={x86, PowerPC, Arm}

ADA for 68hc11/Avr8 has no sense and gnat is broken for the most


so that's all, no other compilers languages, just C/C++!
may be i can use eLUA as interpreter, it is working on Discovery ARM board, for example, or python on chip, which is working on the same board, but they are interpreters not compilers!

Yep, you're setting 'a' equal to two, then using it as a Boolean. What's hard about that?

that is terrible at all, no sense to admit a "LET" (a=...) inside a conditional statement, it is just a reason to put a bug inside your code if you miss a char "="  !
A LET MUST stay OUTSIDE and end with ";", and a conditional statement MUST be eval-boolean-expression, so it MUST refuse everything does not result as a boolean {True, False}

The only way you'd be prone to leaving out 'break' is if you don't understand that they are labels.

It may be you forget it, it happens when you copy & past, or when you are tired and you miss a piece of code: a pretty compiler should warning or point attention to it! A break is also dangerous cause it may be used to escape a block, while (eval) { blabla; break; } and this cause people to abuse of it producing ugly code.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: free_electron on September 22, 2013, 04:49:07 pm
Not really understanding the Python hate, just set your editor to insert spaces as tabs @ 4 spaces and I've never had any issues. I actually like the whitespace because it forces consistency which is more important to me than whatever coding standards you are using.

Of all the scripting languages I've found I like python the most(although Lua has a special place in my heart for being so compact and bloody fast for a scripting language).
until you copy and paste a chunk of code sends it via email and the tabs get converted to spaces....

or someone touched the code and inserted 1 space somewhere and it is not really obvious and you bang your head out chasing why it doesn't work and it used to.

whitespace is whitespace . it should not be a part of the programming syntax.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: mrflibble on September 22, 2013, 05:16:33 pm
Not really understanding the Python hate ...
whitespace is whitespace . it should not be a part of the programming syntax.

This.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: Bored@Work on September 22, 2013, 07:02:13 pm
A LET MUST stay OUTSIDE

Who says this? And who-tf says that a LET keyword is a good idea?

Quote
a conditional statement MUST be eval-boolean-expression, so it MUST refuse everything does not result as a boolean {True, False}

Who says this?

Quote
while (eval) { blabla; break; } and this cause people to abuse of it producing ugly code.

Who says this?
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: legacy on September 22, 2013, 07:22:52 pm
Who said that ?
Misra, for example, giving suggestions to build/fix languages in order to avoid ugly (and probably bugged) code.
C is so ugly that requires a Misra-C checker in post process, so as soon as you have finished to code you C source code you have to check if it pass the Misra check: too ugly, too boring, (too expensive, a Misra checker like QAC is not for cheap), a language MUST be safe, stronger, and beauty by design!

Also, have a look at ADA language, see the reasons why they did ADA in such a stronger-way.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: legacy on September 22, 2013, 07:29:58 pm
anyway, i've planned to give nimrod a try: probably i will use it in a bare board MIPS32-r1 board, and in a linux MIPS SoC board.
I am curious about the C code that nimrod can produce! It may be good and productive enough to switch development into nimrod.

let's have a try, too! it may be fun!
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: mrflibble on September 22, 2013, 07:33:59 pm
A LET MUST stay OUTSIDE

Who says this? And who-tf says that a LET keyword is a good idea?

I think he means LET as "evaluate right hand side, and then assign this value to left hand side", not as a language literal.

And to be fair, the if (a=b) {  versus  if (a==b) { is sneaky and can be a fun source of bugs when you don't watch it. The argument about case and forgetting breaks ... nope, you lost me there. I never ever EVER forget about breaks or a default statement. Just do case statement in verilog for a while and your brain will not even allow you to entertain the possibility of maybe possibly making a tiny error in a case statement. EVER. AGAIN.

let's have a try, too! it may be fun!

That is soooo several hours ago. I already checked it to see if it throws an error/warning for the if (a=b) { statement. And yes, it throws an error. Expression has no type or is ambigious. It even caught my sneakier attempts. :P
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: andyturk on September 22, 2013, 07:40:46 pm
Also, have a look at ADA language, see the reasons why they did ADA in such a stronger-way.
Wait. What? ADA is a failure. Many gov't organizations mandated the use of ADA, but coders never went for it. C won (over ADA, Pascal, etc.) because more people used it to write programs, warts and all.

ADA just wasn't that useful.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: legacy on September 22, 2013, 07:51:06 pm
ADA ? If you work for avionic you MUST use ADA, may be you can use also C for the low level stuff (kernel are written in C), but we are talking about an extremely safe C, which means Misra Checked and Validated.

ADA is cool, the problem is that is very difficult to qualify a compiler as "ADA", i mean that a compiler to be called "ADA compliant" MUST pass a lot of tests.

GNAT is ADA, and is very cool, try it out, it's OpenSource! There is just a little eggs problem: to compile the GNAT compiler you need a GNAT compiler, so if you look at gentoo repository you find that this is only possible (means binary compiler boot-strappers only available) for
- X86/linux
- PowerPC/linux
- Arm/Linux (maybe, there is something old around)

- MIPS/Linux and other arch are not supported!


p.s.
i checked this time ago, it may be changed, check yourself for any updated detail
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: madires on September 22, 2013, 08:54:03 pm
All those discussions about which programing language to use are futile. MCU/CPUs are running with machine code, so any language is just an abstraction layer to formulate what should be done by the CPU. Some programing languages are easier to learn than others, some are optimized for a specific area of features, other ones are less error-prone for beginners and so on. If you're happy with language X then use X. But a programing language isn't a religion so please don't try to missionate anybody else!
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: c4757p on September 22, 2013, 08:58:22 pm
This is basically my argument against "we don't need yet another programming language". Just don't use it if you don't like it... I personally like choice...

Of course, in this case I will choose not to use it because I think it looks dumb. But that is my opinion and I only think I'm a little better than people who disagree... >:D
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: jeremy on September 22, 2013, 09:15:24 pm
Not sure I understand all the python hate here guys  ;)

You can use tabs or spaces, you just can't use both. Any text editor with more brains than notepad automatically converts between the two. You can also indent a single space or five spaces if you like, the interpreter will still accept it as long as it is consistently used (that's the key to python: it forces consistency).

Also, hunting for indentation errors is really not that bad. You get an IndentationError with a line number, so you go to that line and then you change the indent. Even my first year students can work this one out pretty easily  :P

Jokes aside, I'm a big fan of python as an "idea testing" language. Usually anything important needs to be in C anyway for speed. I really don't mind the syntax of C either.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: andyturk on September 23, 2013, 03:11:23 am
Not sure I understand all the python hate here guys  ;)
<rant>
Because what's fricken wrong with fricken braces!

Jeebus! Is it too much to type '{' and '}'? It's not like we're asking you to go back to Pascal with 'begin' and 'end'--we know how that makes your little fingers hurt.

Aw.

But what really yanks my nosehairs is getting a screenful of Python code, indented to N+7 levels and trying to figure out which somewhat less indented code lines up with some other less indented code that scrolled off the top of my emacs window.

Why, Guido? Why?
</rant>
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: amyk on September 23, 2013, 09:44:33 am
Also, hunting for indentation errors is really not that bad. You get an IndentationError with a line number, so you go to that line and then you change the indent.
The problem is a lot of communication mediums which strip leading spaces, completely destroying the structure of the program. With something like C the code still works if you copy+paste and lose all the indentation (and there are programs that will easily put them back so it's easier to read); with Python, you're left with a completely nonfunctional program. Beginners pasting code on forums and such get caught by this the most.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: alm on September 23, 2013, 09:58:08 am
One issue that you might have in C that you won't have in this language:
Code: [Select]
if (success != 0)
    errno = -1;
    return errno;
errno = 0;
When will the last line be executed? ;)
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: Bored@Work on September 23, 2013, 10:03:43 am
One issue that you might have in C that you won't have in this language:
Code: [Select]
if (success != 0)
    errno = -1;
    return errno;
errno = 0;
When will the last line be executed? ;)

Never, and the compiler will warn you. The problem is not with C, it is with the one who wrote that code. Like there will always be people who manage to grap the hot end of the iron, there will always be idiots who can't read their own C code and see what they did.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: komet on September 23, 2013, 10:04:33 am
Beginners pasting code on forums
Programs not working if you copy/paste them without understanding them might be considered a feature.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: alm on September 23, 2013, 10:08:08 am
Never, and the compiler will warn you.
The compiler will only warn because I happened to put a return there. Not if it was some other statement that gets inadvertently executed. Or are C compilers warning for whitespace now? ;)
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: madires on September 23, 2013, 10:12:33 am
One issue that you might have in C that you won't have in this language:
Code: [Select]
if (success != 0)
    errno = -1;
    return errno;
errno = 0;
When will the last line be executed? ;)

If the C equivalent would be:

Code: [Select]
if (success != 0)
{
    errno = -1;
    return errno;
}
errno = 0;

then I'd scratch my head about using whitespaces to define a code block.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: Bored@Work on September 23, 2013, 10:33:42 am
Never, and the compiler will warn you.
The compiler will only warn because I happened to put a return there. Not if it was some other statement that gets inadvertently executed. Or are C compilers warning for whitespace now? ;)

Then you will have to live with the smell of burning flesh. The thing is some people never learn their tools and will again and again grap the iron at the wrong end. Or get their C code wrong.

All these rubbish new languages just show the old saying, try to make something idiot proof and you find better idiots. The reality is, these days the majority of people who write programs should never be let near a computer, and no "idiot proof" programming language can fix these people, who have no talent, no clue, no experience.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: lapm on September 23, 2013, 10:41:48 am
Hate to say this, but i was wondering too why we need yet another language?
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: jucole on September 23, 2013, 11:09:09 am
I think it's ok if you have a thing for languages with that type of syntax,  but I personally much prefer the C, C++ syntax.    Also, in the docs it says "The compiler generates optimized C code"   so why wouldn't you just write it in C anyway?
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: jucole on September 23, 2013, 11:19:55 am
Talking of languages - if you're tired of using C,  you can always try D  http://dlang.org/overview.html (http://dlang.org/overview.html)  ;-)
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: c4757p on September 23, 2013, 11:48:33 am
One issue that you might have in C that you won't have in this language:
Code: [Select]
if (success != 0)
    errno = -1;
    return errno;
errno = 0;
When will the last line be executed? ;)

Stop editing your code on punch cards, and your editor will warn you or fix it...
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: TerminalJack505 on September 23, 2013, 12:13:31 pm
I think the only new programming language that will be available on a wide variety of low-end MCUs (MCUs incapable of hosting Linux, for example) for the next 5 to 10 years is going to be C++11.

You might argue that this isn't a new programming language but they made quite a few changes to the language with C++11.  Some of them are meant to make the language "kinder and gentler" for noobs.  (The auto keyword, for example.)
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: jeremy on September 23, 2013, 12:33:43 pm
The reality is, these days the majority of people who write programs should never be let near a computer, and no "idiot proof" programming language can fix these people, who have no talent, no clue, no experience.

Well that seems rather hyperbolic.

FYI, I still burn myself with the soldering iron occasionally after many years of soldering (it's always the "I'll get this done before it gets too hot to hold" trick), guess I'm just a big ol' idiot.  ;D
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: jeremy on September 23, 2013, 12:39:07 pm
I think the only new programming language that will be available on a wide variety of low-end MCUs (MCUs incapable of hosting Linux, for example) for the next 5 to 10 years is going to be C++11.

I agree, but I wonder if such low end MCUs will be around in a decade? I can get an M0 for less than a chocolate bar and they are definitely capable of running uclinux.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: mrflibble on September 23, 2013, 12:42:31 pm
Code: [Select]
if (success != 0)
    errno = -1;
    return errno;
errno = 0;
When will the last line be executed? ;)

Never. In fact, not a single line from that code will ever be executed because the author wouldn't be able to find the kompail button.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: jancumps on September 23, 2013, 12:58:03 pm
...

FYI, I still burn myself with the soldering iron occasionally after many years of soldering (it's always the "I'll get this done before it gets too hot to hold" trick), guess I'm just a big ol' idiot.  ;D
I'm the other way around: "Think it's cooled down by now" ;D
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: HackedFridgeMagnet on September 23, 2013, 02:05:11 pm
Quote
Talking of languages - if you're tired of using C,  you can always try D  http://dlang.org/overview.html (http://dlang.org/overview.html)  ;-)

D sounds like the best language ever. From my quick reading everything I wanted to do with c and c++, and more importantly everything I wanted taken out of c, c++.
Can you compile code for embedded? It says you can use a gcc back end. I can't see any examples?

Not sorry about the hijack, replacing the bad with the good.


Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: c4757p on September 23, 2013, 02:19:27 pm
I liked D when I looked at it last (about a year ago), but as for compilers, it was in a sorry state. The GCC plugin was massively out of date (IIRC only compatible with D 1.0) and the other compiler only ran on a few platforms and was closed-source.

Looks like some of that has changed now. I just downloaded the source for the main compiler, but the license terms are ambiguous. (The main license.txt says "this is not open source" and all of the individual files I've opened claim to be GPL / "Artistic license", and even some under the Boost Software License |O) The compiler comes in a 64-bit binary version now, but I'm not sure if it will actually compile a 64- bit binary.

It looks like a lot of progress has been made since then, though. I think I may take another look at this. :-+
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: MacAttak on September 24, 2013, 01:04:39 am
Never, and the compiler will warn you.
The compiler will only warn because I happened to put a return there. Not if it was some other statement that gets inadvertently executed. Or are C compilers warning for whitespace now? ;)

No, the compiler will warn you that unreachable code was detected. The whitespace is irrelevant to the token parser. The last line in that example can never be reached, and modern compilers can detect this. And some environments will even do this within the editor before you ever try to compile (for example Resharper addon for Visual Studio).
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: HackedFridgeMagnet on September 24, 2013, 02:58:03 am
Yes the compiler will normally warn of this, but sometimes if you include 3rd party libs, you max out the warnings and you can miss this.

In regards to :
if(a=b)
and the lack of braces after a conditional being ok.

I think these are a couple of cases where c got it wrong.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: dannyf on September 24, 2013, 04:13:45 am
Quote
I think these are a couple of cases where c got it wrong.

Not sure about that. The C syntax allows the combination of assignment + logic test into one statement.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: HackedFridgeMagnet on September 24, 2013, 07:03:18 am
Quote
The C syntax allows the combination of assignment + logic test into one statement.

That's what I mean, they made a mistake by allowing it. Obviously this is my point of view, but I doubt I am the only person who thinks this.

It has led to lots of confusion and I am sure lots of errors, for the sake of what? To save a bit of typing, are there any other reasons why you want this?
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: alm on September 24, 2013, 09:57:30 am
No, the compiler will warn you that unreachable code was detected. The whitespace is irrelevant to the token parser. The last line in that example can never be reached, and modern compilers can detect this. And some environments will even do this within the editor before you ever try to compile (for example Resharper addon for Visual Studio).
It's unreachable because of that return. The compiler wouldn't complain if I put 'ERROR_LED = 1' instead of return. Or a function call to perform a software reset.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: madires on September 24, 2013, 01:22:48 pm
Quote
The C syntax allows the combination of assignment + logic test into one statement.

That's what I mean, they made a mistake by allowing it. Obviously this is my point of view, but I doubt I am the only person who thinks this.

It's not a mistake , it's a consistent syntax. If we allow the usage of some expressions just in a specific context we would limit the syntax and we would have to learn about those exceptions. Another one would then complain why he doesn't may use a specific expression in a specific context and call that a mistake.

Quote
It has led to lots of confusion and I am sure lots of errors, for the sake of what? To save a bit of typing, are there any other reasons why you want this?

How many people are still using a knife after injuring themselfes with it?  >:D
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: komet on September 24, 2013, 01:34:59 pm
That's what I mean, they made a mistake by allowing it.
The whole design of C revolves around allowing you to make mistakes and leaving it to the programmer to decide.

What sense would it make to disallow inline assignment - an elementary error that I have never made in 25 years - given that one can mess up far more spectacularly by, e.g., not taking care of one's pointers?

If you want your language to make reasonable choices for you - and one often does, of course - then the simple solution is to not use C. Crippling C for those who do in fact want the dangerous features on offer would be foolish.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: dannyf on September 24, 2013, 01:49:08 pm
Quote
It has led to lots of confusion and I am sure lots of errors, for the sake of what?

Like they say: language doesn't make mistakes; stupid programmers do.

There are definitely a place for a "safer" language (PASCAL for example) but C is where it is today because it is C.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: HackedFridgeMagnet on September 24, 2013, 02:44:35 pm
Quote
Like they say: language doesn't make mistakes; stupid programmers do.
Conveniently ignore the question and resort to abuse.

Look I would love not to use C but it is not practical. I don't even dislike C but how many times to you see a crock of shit written by some of these very clever C programmers, with 5 layers of macros and 100s of warnings. Cant be bothered typing decent names for variables.

Stupid code from a not stupid programmer. Look I realise it is hard to write widely used libraries, but trying to find debug in this sort of stuff is hard.
Code: [Select]
/* Create SFN in directory form */
mem_set(dj->fn, ' ', 11);
for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */
if (si) cf |= NS_LOSS | NS_LFN;
while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */

b = i = 0; ni = 8;
for (;;) {
w = lfn[si++]; /* Get an LFN char */
if (!w) break; /* Break on end of the LFN */
if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */
cf |= NS_LOSS | NS_LFN; continue;
}

if (i >= ni || si == di) { /* Extension or end of SFN */
if (ni == 11) { /* Long extension */
cf |= NS_LOSS | NS_LFN; break;
}
if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */
if (si > di) break; /* No extension */
si = di; i = 8; ni = 11; /* Enter extension section */
b <<= 2; continue;
}

if (w >= 0x80) { /* Non ASCII char */
#ifdef _EXCVT
w = ff_convert(w, 0); /* Unicode -> OEM code */
if (w) w = cvt[w - 0x80]; /* Convert extended char to upper (SBCS) */
#else
w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */
#endif
cf |= NS_LFN; /* Force create LFN entry */
}

if (_DF1S && w >= 0x100) { /* Double byte char */
if (i >= ni - 1) {
cf |= NS_LOSS | NS_LFN; i = ni; continue;
}
dj->fn[i++] = (BYTE)(w >> 8);
} else { /* Single byte char */
if (!w || chk_chr("+,;[=]", w)) { /* Replace illegal chars for SFN */
w = '_'; cf |= NS_LOSS | NS_LFN; /* Lossy conversion */
} else {
if (IsUpper(w)) { /* ASCII large capital */
b |= 2;
} else {
if (IsLower(w)) { /* ASCII small capital */
b |= 1; w -= 0x20;
}
}
}
}
dj->fn[i++] = (BYTE)w;
}

if (dj->fn[0] == 0xE5) dj->fn[0] = 0x05; /* If the first char collides with deleted mark, replace it with 0x05 */

if (ni == 8) b <<= 2;
if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */
cf |= NS_LFN;
if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended char, NT flags are created */
if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */
if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */
}

dj->fn[NS] = cf; /* SFN is created */

return FR_OK;

At least Madires gave me an answer to a question that I was wondering.
Quote
It's not a mistake , it's a consistent syntax. If we allow the usage of some expressions just in a specific context we would limit the syntax and we would have to learn about those exceptions. Another one would then complain why he doesn't may use a specific expression in a specific context and call that a mistake.

But I when I weigh up consistent syntax vs what make sense. I prefer statements that make sense.
I don't really know what is consistent about a single assignment statement within parenthesis for a conditional, is somehow consistent with the 'for' statement?





Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: Bored@Work on September 24, 2013, 03:41:27 pm
Quote
Like they say: language doesn't make mistakes; stupid programmers do.
Conveniently ignore the question and resort to abuse.

Look I would love not to use C but it is not practical. I don't even dislike C but how many times to you see a crock of shit written by some of these very clever C programmers, with 5 layers of macros and 100s of warnings. Cant be bothered typing decent names for variables.

Stupid code from a not stupid programmer.

Oh dear, Elm Chan's FAT library. Known to be faulty and itchy. The guy itself is certainly not stupid but he is not a good programmer when it comes to stuff like maintainability. And that is my first point.

My second point would be that one could create the same mess in any language, it doesn't require C at all.

My third point would be that this is the kind of code where you need additional documentation.Because, even if well written, the task as such defeats self-documenting code. (most stuff does, self-documenting code is largely a myth).  So what is missing in that particular case? The Windows FAT file system specification. You can't squeeze that into a few comments in the code.

My forth point would be, while one actually needs the FAT specification to write this properly, Elm Chan probably didn't have it. And what you see is the result of (incomplete) reverse engineering or using dubious web sources. Garbage in - garbage out.

Non of this has anything to do with the language. It is all about the competence of the programmer and the available documentation.

Quote
but trying to find debug in this sort of stuff is hard.

Well, I have a suspicion here. There is a generation of coders (I refuse to call them programmers), who think the only way to debug is plastering code with printf's.  Debugging code like the one shown becomes at least twice as hard when using printf's instead of learning how to use proper debugging techniques, like ICE, a simulator and/or a hardware logic analyzer together with a proper SW debugger.

Still, you need the specification to debug that code, which no debugger can provide.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: HackedFridgeMagnet on September 24, 2013, 11:11:52 pm
Quote
Oh dear, Elm Chan's FAT library
lol


I like to put in links to documents or specs or whatever I ported from.
I agree with just about all of what Bored@Work said.
except the forth point, where I would say c programmers seem to have a mentality that if you can do 5 things in one line and name your variables in the most abbreviated form possible then the code will run faster. 



Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: madires on September 24, 2013, 11:26:13 pm
except the forth point, where I would say c programmers seem to have a mentality that if you can do 5 things in one line and name your variables in the most abbreviated form possible then the code will run faster.

People doing that aren't programmers, they are just hacking code together. But you'll see that done using other languages also.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: dannyf on September 25, 2013, 01:28:55 am
Quote
with 5 layers of macros and 100s of warnings.

That kind of programming style makes lots of sense to me. One friend used to tell me that an easy way to tell if a piece of code is properly done is to count the number of ASSERT() used. Superficial but true.


I think you may be in a situation where you insist that others slow down so you can catch up with them. A happier approach might be to run with like people.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: dannyf on September 25, 2013, 01:37:34 am
Quote
where I would say c programmers seem to have a mentality that if you can do 5 things in one line and name your variables in the most abbreviated form possible then the code will run faster.

I think you find that people do that tend to program for fun, rather than program for a living: that kind of code has no chance of passing QA in any respectable shop.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: amyk on September 25, 2013, 10:26:43 am
Stupid code from a not stupid programmer. Look I realise it is hard to write widely used libraries, but trying to find debug in this sort of stuff is hard.
I guess it's mostly subjective as I deal with code like that all the time and don't find it any harder to understand... the use of SI and DI there suggest either this was ported to C from x86, or the programmer came from an x86 background, or it was RE'd from x86 code (the MS filesystem driver?) Although I think the indenting is a bit excessive.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: nasteban on September 26, 2013, 12:48:13 am
Not really understanding the Python hate, just set your editor to insert spaces as tabs @ 4 spaces and I've never had any issues. I actually like the whitespace because it forces consistency which is more important to me than whatever coding standards you are using.

For me you answered your own question: The editor can do it. Almost any programming editor can indent automatically, so you're never more than a couple of keystrokes away from the way you like to have it indented. Unless, of course, you're using a language where indentation is significant. Then the editor can't indent correctly without your input. By making indentation part of the syntax, they "fixed" a problem that didn't exist, and in doing so they annoyed many people -- myself included.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: Rick Law on September 28, 2013, 01:57:07 am
That's what I mean, they made a mistake by allowing it.
The whole design of C revolves around allowing you to make mistakes and leaving it to the programmer to decide.

.....



This what language is better is getting to be like reading the political section of the news paper.

This is a little like the Democrat Republican/Libertarian thing.  One prefers minimal government and let individuals decide, another prefers government sets the value and you live within it, and yet another will care for you craddle to grave, as long as you don't assign too many variables on the same line, and your program generates the exact same output as all the other programs written by high school kids from any background, and PhD candidates of any fields alike.  Equality of outcome is only fair.

Yes, I am tolerant as long as I agree with you.  So shut up and use the language I choose for you mere mortals.

You programmers has an easy job, so stop grumping about the language.  You spend the whole day setting things into just ones and zeros.  Just ones, and zeros.  How hard can that be.

Tax time - Now pay up for the 65536 bits of one you set just in the first 4 minutes this morning at $1/bit, and the next 65536 bits of ones at $2/bit, and $4/bit the next 65536, and....  Bits set exceeding the average will be tax at twice your annual income.  That should teach you not to unfairly set more bits than your fellow programmers.  It is not democrats who can't count, it is the citizen because after tax, they are left with nothing to count.

I think I am a liberterian, (edit: clicked too soon, missing these)

I think I am a liberterian, I like C.  I program in C.  I program for myself.  I am the sole judge of my output.  I choose the risk, the mistake, the reward and I live with the consequences of my decision.
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: legacy on October 01, 2013, 12:34:27 am
I have found this "nimrod-return-of-pascal (http://steved-imaginaryreal.blogspot.it/2013/09/nimrod-return-of-pascal.html)" review
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: dannyf on October 01, 2013, 12:36:28 am
Quote
I live with the consequences of my decision.

PASCAL: I am the government, and I am here to help.

:)
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: Rick Law on October 01, 2013, 05:08:35 am
Quote
I live with the consequences of my decision.

PASCAL: I am the government, and I am here to help.

:)

But you can't find me...  I have no new knee, no new pace-maker, no new hip, so no RFID in my body.  So there.

This note will self destruct in 10 seconds and you will have even one less clue.  Excuse me, I am heading back into my "cone of silence"...
Title: Re: nimrod, new language, interesting compiler/interpreter
Post by: jucole on October 02, 2013, 10:05:16 am
I liked D when I looked at it last (about a year ago), but as for compilers, it was in a sorry state. The GCC plugin was massively out of date (IIRC only compatible with D 1.0) and the other compiler only ran on a few platforms and was closed-source.

Looks like some of that has changed now. I just downloaded the source for the main compiler, but the license terms are ambiguous. (The main license.txt says "this is not open source" and all of the individual files I've opened claim to be GPL / "Artistic license", and even some under the Boost Software License |O) The compiler comes in a 64-bit binary version now, but I'm not sure if it will actually compile a 64- bit binary.

It looks like a lot of progress has been made since then, though. I think I may take another look at this. :-+

I tried it a while back but struggled to make much progress, but now they seem to have got the libraries sorted;  I created a little console app for work using it and I was nicely surprised.