Author Topic: Too many programming languages?  (Read 49180 times)

0 Members and 1 Guest are viewing this topic.

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Too many programming languages?
« Reply #375 on: November 30, 2019, 11:12:02 pm »
Like I said, highlighting all tabs in Gedit/Pluma (by searching for \t with backslash escapes enabled in the search dialog) makes the tabs visible.

Nice trick  :D

I wrote a text editor years ago. It looks like "nano", it's very simple and features limited; after your comment, yesterday I implemented a way to highlight all tabs. So now they are visible.
 

Offline blacksheeplogic

  • Frequent Contributor
  • **
  • Posts: 532
  • Country: nz
Re: Too many programming languages?
« Reply #376 on: November 30, 2019, 11:41:04 pm »
avionic rule #13: "{ }" must always be preceded by if() | else | do | while() | switch() | for() | function()

Be interesting to know why that got written into the code standard. I'm guessing someone abused it to work around a scope issue and in typical corporate fashion all problems are fixed by updates to the documentation.
 

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Too many programming languages?
« Reply #377 on: December 01, 2019, 12:09:00 am »
Be interesting to know why that got written into the code standard

Mostly because it simplifies the team working activities. Especially in the testing squad.
It's a de-facto benefit.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Too many programming languages?
« Reply #378 on: December 01, 2019, 12:36:16 am »
Quote
[many ways of expressing an empty while loop. almost all for C/C++]

Ok, now I'm curious.  The empty while loop is a staple of embedded programming.Does anyone have a newer favorite language that has a syntax that they like BETTER than their favorite C syntax?

Quote
I implemented a way to highlight all tabs.

I have an EMACS hack that continually highlight tabs, and any trailing whitespace on a line (dark gray instead of a black background.)It's handy (especially since tailing spaces can break things "mysteriously" if you don't see them.)

« Last Edit: December 01, 2019, 01:09:24 am by westfw »
 

Offline Cerebus

  • Super Contributor
  • ***
  • Posts: 10576
  • Country: gb
Re: Too many programming languages?
« Reply #379 on: December 01, 2019, 01:39:35 am »
Ok, now I'm curious.  The empty while loop is a staple of embedded programming.Does anyone have a newer favorite language that has a syntax that they like BETTER than their favorite C syntax?

To me the obvious construct to use is an explicit no-op of some sort. C doesn't have one, just the implicit null statement, which is what leads to difficult to read code.

Ironically, older languages than C had explicit no-ops (Algol-68: SKIP, FORTRAN: CONTINUE) but you've asked for newer languages. Some example of explicit no-ops from newer languages, not exhaustive: Ada - null, Python - pass. I'm sure the list is longer but I can't be bothered to scrape my memory/the net for other examples.

I've no problem with something like this (in C) that is effectively making up an explicit no-op (Which, let's face it, is part of the grand tradition of extending C in ad-hoc ways, but at least I haven't #def'd a made up SPIN_WHILE() operator.):
Code: [Select]
void spin_no_op ()
{
    /* As well as usefully doing nothing, acting as a marker for a no-op and probably getting optimized away, writing */
    /* this as a procedure also has the advantage that, if the particular platform we are on has a wait-for-interrupt */
    /* instruction or something similar that reduces power consumption in a busy-wait loop we can drop it in here     */
    /* and automatically get it used by any code that calls here. e.g.: */
#if defined(GNUC) & defined(__x86_64__)
    asm volatile ("PAUSE");
#endif
}

void do_work()
{
// ...
extern volatile int waiting_for_interrupt_from_turboencabulator;
// ...
    while (waiting_for_interrupt_from_turboencabulator) spin_no_op();
}

« Last Edit: December 01, 2019, 01:41:26 am by Cerebus »
Anybody got a syringe I can use to squeeze the magic smoke back into this?
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: nz
Re: Too many programming languages?
« Reply #380 on: December 01, 2019, 03:12:34 am »
I have an EMACS hack that continually highlight tabs, and any trailing whitespace on a line (dark gray instead of a black background.)It's handy (especially since tailing spaces can break things "mysteriously" if you don't see them.)

M-x whitespace-mode

.. will basically do that. It doesn't interfere with your editing mode, and you can toggle it on and off at will.

By default it shows spaces as a . on light yellow background, tabs as >> on a khaki background, and trailing whitespace as angry red. But you can tune that to your heart's content, changing styles or what elements are highlighted at all e.g. "don't show me spaces"
 

Offline blacksheeplogic

  • Frequent Contributor
  • **
  • Posts: 532
  • Country: nz
Re: Too many programming languages?
« Reply #381 on: December 01, 2019, 08:28:02 am »
Mostly because it simplifies the team working activities. Especially in the testing squad.
It's a de-facto benefit.

Companies I've worked out change occurs because one of 5,000 people working on the product does something not considered kosher by some opinionated bastard so we all get punished by a process update. I don't recall off-hand anything being done for beneficial reasons.
 

Offline GeorgeOfTheJungle

  • Super Contributor
  • ***
  • !
  • Posts: 2699
  • Country: tr
Re: Too many programming languages?
« Reply #382 on: December 01, 2019, 09:04:16 am »
[...] something not considered kosher by some opinionated bastard [...]
:-+

This is how Linus does it: https://github.com/git/git/blob/29d76d4b05bc537ac59fd1e6f849ab3386c01502/rev-tree.c#L141-L146

Code: [Select]
static unsigned long parse_commit_date(const char *buf)
{
  if (memcmp(buf, "author", 6))
    return 0;
  while (*buf++ != '\n')
    /* nada */;
  if (memcmp(buf, "committer", 9))
    return 0;
  while (*buf++ != '>')
    /* nada */;
  return parse_time(buf);
}
The further a society drifts from truth, the more it will hate those who speak it.
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11634
  • Country: my
  • reassessing directives...
Re: Too many programming languages?
« Reply #383 on: December 01, 2019, 09:16:29 am »
that is a kind of poor or lazy programming practise (if not taken with cautious) that gave C/C++ a bad name, who wrote that? it expects correctly formatted buf input, otherwise the famous buffer overrun... ps: added/corrected.
« Last Edit: December 01, 2019, 09:57:57 am by Mechatrommer »
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: nz
Re: Too many programming languages?
« Reply #384 on: December 01, 2019, 09:40:11 am »
that is a kind of poor or lazy programming that gave C/C++ a bad name, who wrote that? it expects correctly formatted buf input, otherwise the famous buffer overrun...

That code is unchanged since April 2005.

I guess you could craft a malicious commit blob, but what are you going to achieve on your own machine, in your local git repo? I don't think that would survive packing, which happens before sending to a server.
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11634
  • Country: my
  • reassessing directives...
Re: Too many programming languages?
« Reply #385 on: December 01, 2019, 10:15:55 am »
that is a kind of poor or lazy programming that gave C/C++ a bad name, who wrote that? it expects correctly formatted buf input, otherwise the famous buffer overrun...
That code is unchanged since April 2005.
doesnt mean its a good practice (added/corrected my previous msg) esp to those who dont know what they are doing. will open up opportunity to some interesting exercises for those who are interested (crackers) i dont care its not my business. for this reason, coupled with negative zero days or whaever hat color exploits news... some swore by things such as ADA, Python or whatever so called safe programming (without they knowing boundary checks are performed in every single lines of memory access). however, this (no boundary check) practice can be intentional by some serious analysts to trade for performance, this is also usually missed by those "safe programming" fanboyz, meh because we can and you cant, anyway.. ignorance is the enemy :P
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline GeorgeOfTheJungle

  • Super Contributor
  • ***
  • !
  • Posts: 2699
  • Country: tr
Re: Too many programming languages?
« Reply #386 on: December 01, 2019, 10:47:31 am »
That is a kind of poor or lazy programming [...] who wrote that?

Some ignorant git it seems: https://github.com/git/git/commit/40e88b95cdce955059e94d288e8ebdb7d1e9fa88   :popcorn:
The further a society drifts from truth, the more it will hate those who speak it.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: nz
Re: Too many programming languages?
« Reply #387 on: December 01, 2019, 11:27:00 am »
that is a kind of poor or lazy programming that gave C/C++ a bad name, who wrote that? it expects correctly formatted buf input, otherwise the famous buffer overrun...
That code is unchanged since April 2005.

Opps, my mistake. I didn't look closely and that's actually a snapshot from April 2005. I don't even know where the equivalent code is now.

Quote
doesnt mean its a good practice (added/corrected my previous msg) esp to those who dont know what they are doing. will open up opportunity to some interesting exercises for those who are interested (crackers) i dont care its not my business. for this reason, coupled with negative zero days or whaever hat color exploits news... some swore by things such as ADA, Python or whatever so called safe programming (without they knowing boundary checks are performed in every single lines of memory access). however, this (no boundary check) practice can be intentional by some serious analysts to trade for performance, this is also usually missed by those "safe programming" fanboyz, meh because we can and you cant, anyway.. ignorance is the enemy :P

I don't disagree that it's bad practice. I'd personally write it more safely, even as a q&d prototype, and I'd ask for changes before commit if I was reviewing the code.

The calling parse_commit() code actually gets the length of the input back from read_sha1_file, and then *ignores* it.

I'd change the arguments to parse_commit_date(buffer) so it would be called as parse_commit_date(buffer, limit) (where limit would be earlier calculated as (char*)buffer+size.

And then:

Code: [Select]
static unsigned long parse_commit_date(const char *buf, const char *limit)
{
if (buf > limit-6 || memcmp(buf, "author", 6))
return 0;
while (buf < limit && *buf++ != '\n')
/* nada */;
if (buf > limit-9 || memcmp(buf, "committer", 9))
return 0;
while (buf < limit && *buf++ != '>')
/* nada */;
return parse_time(buf, limit);
}

I'd challenge anyone to notice any speed difference.

But more likely I'd save myself a lot of typing and write it using some auxiliary functions.
 

Offline GeorgeOfTheJungle

  • Super Contributor
  • ***
  • !
  • Posts: 2699
  • Country: tr
Re: Too many programming languages?
« Reply #388 on: December 01, 2019, 12:13:36 pm »
We've seen Torvalds' style. Let's see Fabrice Bellard's:

Code: [Select]
while (*p && *p++ != '\n')
  continue;
https://gitlab.com/xk/quickjs/blob/master/quickjs.c?expanded=true&viewer=simple#L26930-26931

=>

Fabrice Bellard:
Code: [Select]
while (condition) continue;
Linus Torvalds:
Code: [Select]
while (condition) /* nada */;
I like both! (And kudos to @Nominal Animal for proposing Torvalds' style above in this thread)

Quote
I don't disagree that it's bad practice. I'd personally write it more safely

The rule you guys are trying to apply doesn't apply here. One thing is not to trust anything you've got from somebody/somewhere else (especially the net), => be extra careful, and another thing is not to trust the data you're creating yourself, that's silly! If you know you've put something in a string, you can rest assured it's there unless the computer is broken.
The further a society drifts from truth, the more it will hate those who speak it.
 
The following users thanked this post: Tepe

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: nz
Re: Too many programming languages?
« Reply #389 on: December 01, 2019, 12:33:24 pm »
We've seen Torvalds' style. Let's see Fabrice Bellard's:

Code: [Select]
while (*p && *p++ != '\n')
  continue;
https://gitlab.com/xk/quickjs/blob/master/quickjs.c?expanded=true&viewer=simple#L26930-26931

Yes, good. Checking for terminating null or limit pointer are pretty much as good as each other.

Quote
Quote
I don't disagree that it's bad practice. I'd personally write it more safely

The rule you guys are trying to apply doesn't apply here. One thing is not to trust anything you've got from somebody/somewhere else (especially the net), => be extra careful, and another thing is not to trust the data you're creating yourself, that's silly! If you know you've put something in a string, you can rest assured it's there unless the computer is broken.

Or, if the code you yourself wrote to create it is broken. It's good to be defensive.

In the git case it's parsing disk files that are normally created by git, but it's perfectly possible for other software to create them or even to do it by hand -- there are tutorials for that.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14472
  • Country: fr
Re: Too many programming languages?
« Reply #390 on: December 01, 2019, 05:26:48 pm »
We've seen Torvalds' style. Let's see Fabrice Bellard's:

Code: [Select]
while (*p && *p++ != '\n')
  continue;

Yeah, altough I still find the above typical of bad C style.

I would write the above as, for instance, such:

Code: [Select]
while (*p != '\0')
{
    if (*p++ == '\n')
        break;
}

Isn't that much easier to read and not needing any kind of empty statement?
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11634
  • Country: my
  • reassessing directives...
Re: Too many programming languages?
« Reply #391 on: December 01, 2019, 05:46:10 pm »
That is a kind of poor or lazy programming [...] who wrote that?
Some ignorant git it seems: https://github.com/git/git/commit/40e88b95cdce955059e94d288e8ebdb7d1e9fa88   :popcorn:
i kind of know the answer before i asked the question, so dont take it personally, that was a partial joke, its kind of troll feed :P for "safe program" fanboysm. thats why i said some "serious analysts" did that deliberately, its just the noobs who follows the style can get into problems.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 
The following users thanked this post: GeorgeOfTheJungle

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6260
  • Country: fi
    • My home page and email address
Re: Too many programming languages?
« Reply #392 on: December 01, 2019, 08:18:58 pm »
IMO, proper style is utterly context-dependent.

If it is an existing project, then the style it uses (hopefully consistently) is the proper one.

If you are teaching new programmers, or showing new programmers how to do things, you want to use a style that helps them get the correct intuitive grasp of things.  They will eventually shift away from that initial/learning style, and that's perfectly okay too.

If you write example code for someone coming from another programming language, you can use examples written in their "intuitive" style and an in some other style that is context-appropriate, to help them understand the differences between the languages.  You can even use styles you personally detest here, to positive effect.

So, I really don't see the purpose of comparing styles outside a specific context.
 

Offline GeorgeOfTheJungle

  • Super Contributor
  • ***
  • !
  • Posts: 2699
  • Country: tr
Re: Too many programming languages?
« Reply #393 on: December 01, 2019, 10:27:51 pm »
Yeah, although I still find the above typical of bad C style.

That's fine, you can write C your own way :-+. But in my book, Torvalds and Bellard are among the best C programmers in the world.
The further a society drifts from truth, the more it will hate those who speak it.
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11634
  • Country: my
  • reassessing directives...
Re: Too many programming languages?
« Reply #394 on: December 02, 2019, 02:10:56 am »
Yeah, although I still find the above typical of bad C style.
That's fine, you can write C your own way :-+. But in my book, Torvalds and Bellard are among the best C programmers in the world.
i never interested to have a look at his code before, but to my surprised, he's the first guy i think to use "my" style of coding ie..

Code: [Select]
while() {
  // codes here
}
instead of...
Code: [Select]
while()
{
  // codes here
}

so we must have something in common somewhere 8) (at least we both have 2 eyes) but whats not in common is he still use the "old" style on function name

Code: [Select]
func()
{
  // codes here
}
instead of...
Code: [Select]
func() {
  // codes here
}

so i must be more "uniformed" (consistent) in term of coding style :P
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Too many programming languages?
« Reply #395 on: December 02, 2019, 04:25:21 am »
That's fine, you can write C your own way :-+. But in my book, Torvalds and Bellard are among the best C programmers in the world.

Torvalds?   :palm:
 

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Too many programming languages?
« Reply #396 on: December 02, 2019, 04:40:02 am »
serious analysts to trade for performance, this is also usually missed by those "safe programming" fanboyz, meh because we can and you cant, anyway.. ignorance is the enemy :P

"safe C" aka "avionic C" is mostly a ruleset to facilitate "code instrumentation" for (e.g.) dynamic coverage analysis.  Performance comes into consideration after this, and it's code running not in instrumented mode (it runs in profiling mode), nor in debug mode (under ICE).
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: nz
Re: Too many programming languages?
« Reply #397 on: December 02, 2019, 04:51:10 am »
That's fine, you can write C your own way :-+. But in my book, Torvalds and Bellard are among the best C programmers in the world.

Torvalds?   :palm:

Torvalds has prototyped several very influential ideas/projects, but I'd say his main talent is then managing contributions by others.

Fabrice Bellard has done a ton of very cool stuff solo. I mean ... three time winner of the Obfuscated C contest, breaking the record for digits of Pi, FFMPEG, QEMU, and other emulators, such as ones that run in a web browser eg RISC-V Fedora Linux in your browser here:

https://bellard.org/jslinux/vm.html?cpu=riscv64&url=https://bellard.org/jslinux/fedora29-riscv-2.cfg&mem=256

Or, a version with X GUI here (takes longer to start):

https://bellard.org/jslinux/vm.html?cpu=riscv64&url=https://bellard.org/jslinux/fedora29-riscv-xwin.cfg&graphic=1&mem=256


Other candidates for top programmer based on multiple amazing projects include:

Andrew Tridgell: rsync, samba, SourcePuller (the reason indirectly that Torvalds started git lol), huge improvements to ArduPilot.

Julian Seward : bzip2, valgrind
 

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Too many programming languages?
« Reply #398 on: December 02, 2019, 05:58:44 am »
Torvalds has prototyped several very influential ideas/projects, but I'd say his main talent is then managing contributions by others.

Precisely. Torvalds is definitively not good for his code-style(1), and his monolithic kernel is a very bad idea in the long term. But his main talent is managing contributions by others, and his GIT is a very great tool.


(1) last time we analyzed the possibility of certifying Linux for avionics ( and I am talking about DO178B level E, the lowest ), even due to his code-style, it would have cost more money than rewriting it from scratch.
 

Offline obiwanjacobi

  • Frequent Contributor
  • **
  • Posts: 988
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: Too many programming languages?
« Reply #399 on: December 02, 2019, 06:35:23 am »
Code: [Select]
while() {
  // codes here
}
instead of...
Code: [Select]
while()
{
  // codes here
}

See, if you would use indents (ala Python) you would not be having this discussion in the first place!  :-DD
Arduino Template Library | Zalt Z80 Computer
Wrong code should not compile!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf