Go to advanced search

by jahboater
Mon Nov 23, 2020 10:35 pm
Forum: C/C++
Topic: Which programming language to learn first
Replies: 35
Views: 1969

Re: Which programming language to learn first

The original question was:

Code: Select all

Should I learn C first and then learn C++?
Why are we discussing python?

:) But I agree with JamesH: Python first then C :)
by jahboater
Mon Nov 23, 2020 8:57 pm
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

With -O0 GCC follows the logic and the goto's exactly.

Is that Borland Turbo C ?
I used it long long ago.
by jahboater
Mon Nov 23, 2020 8:48 pm
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

What -0 level? Unfortunately my favorite compiler does not allow GOTO which I always considered A Good Thing. And also would never think of deleting code that I have written and do not want to disappear. Anything except -O0 (GCC). Whats your favorite compiler? GCC happily removes code where it can ...
by jahboater
Mon Nov 23, 2020 7:48 pm
Forum: C/C++
Topic: Which programming language to learn first
Replies: 35
Views: 1969

Re: Which programming language to learn first

That was going really well, till the 8086 part. What a nightmare, having to juggle around with that 64K segmented memory. Brings back horrible nightmares. Still have memory models ..... GCC options for Aarch64 on the Pi! -mcmodel=tiny Generate code for the tiny code model. The program and its stati...
by jahboater
Mon Nov 23, 2020 7:35 pm
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

Is goto infinite loop faster than while(1)? write simple volatile statements in a loop (e.g., 1 million single loops) Measurement is good. Not sure about the volatile. Anyway, I tried this: int main( void ) { int n = 42; for( int i = 0; i < 10; ++i ) n += i; printf( "n = %d\n", n ); } Pre...
by jahboater
Mon Nov 23, 2020 10:42 am
Forum: Raspberry Pi 400
Topic: 64GB SD on a Pi400
Replies: 5
Views: 487

Re: 64GB SD on a Pi400

Yes 64GB or more works fine. The A1 class cards are designed for high rates of random 4kb I/O. Normal class 10 cards are designed for streaming huge video and image files. The A1 class cards are the best for use as an OS system disk. https://www.sdcard.org/developers/overview/application/index.html ...
by jahboater
Mon Nov 23, 2020 10:29 am
Forum: Raspberry Pi 400
Topic: 8GB Version?
Replies: 17
Views: 887

Re: 8GB Version?

Just curious, why did RPF decide not to use onboard eMMC flash? Not as fast as a SSD but at least it would stopped kids in class stealing the SD cards. Mess up your OS and brick your PI, switch SD cards, Pi unbricked. If the onboard eMMC dies of old age then its buy a new Pi time, if an SD card die...
by jahboater
Sun Nov 22, 2020 7:43 pm
Forum: Off topic discussion
Topic: Is learning to code more difficult if you don't speak English?
Replies: 38
Views: 2495

Re: Is learning to code more difficult if you don't speak English?

We now have _Decimal64 etc included in IEEE 754-2008 which is great for currency and other simple arithmetic.
For example (0.1 + 0.2) - 0.3 would equal zero.

I am guessing its the modern replacement for BCD and the like?

C has decimal arithmetic in the draft C2x standard.
by jahboater
Sun Nov 22, 2020 10:36 am
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

From this description I would wager that most of the time your system as a whole is not even running your code. It will be spending a lot of time in the kernel as it schedules and reschedules all these processes and threads. It will be spending a lot of time in the kernel as it handles whatever com...
by jahboater
Sun Nov 22, 2020 6:10 am
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

Take a look at gprof (see "man gprof" for details). You can get an execution profile showing which routines use the most time. Common saying: "90% of the time is spent in 10% of the code". Its only worth optimizing that 10% (or less). ---------------------------------------------...
by jahboater
Sat Nov 21, 2020 8:04 pm
Forum: Raspberry Pi 400
Topic: 8GB Version?
Replies: 17
Views: 887

Re: 8GB Version?

so we wouldn't have to boot that thing from these fragile and slow microSD cards. I personally don't find them fragile at all (vaguely remember one problem, long ago, in many years of using countless Pi's on a daily basis), and not slow enough to be a problem (8GB of memory means most stuff ends up...
by jahboater
Sat Nov 21, 2020 4:50 pm
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

You won't get far replacing control structures with gotos. Yes indeed. Likely make things worse! You can do one or two simple things that might make a slight difference: For example "do while" is usually faster than a plain "while" loop (one jump instead of two). Counting down t...
by jahboater
Sat Nov 21, 2020 4:39 pm
Forum: Troubleshooting
Topic: How to compile Cherrytree on Raspberry Pi 4?
Replies: 2
Views: 160

Re: How to compile Cherrytree on Raspberry Pi 4?

HJAST101 wrote:
Sat Nov 21, 2020 4:05 pm
What should I do?
Have you looked at www.gtkmm.org ?

Looks like 2.65 is available.
by jahboater
Sat Nov 21, 2020 4:31 pm
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

buja wrote:
Sat Nov 21, 2020 4:26 pm
So if you come from B repeat might make sense. I come from Pascal, so if I see repeat I expect to see until somewhere.
Good point!
by jahboater
Sat Nov 21, 2020 4:25 pm
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

You should prioritize ease of understanding. Ease of understanding is generally important but rarely the 1st priority. That will depend on context. Is memory tight, is there surplus processor capacity, are there strict timing requirements, how accurate? There is no generic rule as to what is most i...
by jahboater
Sat Nov 21, 2020 4:23 pm
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

Don't go crazy with micro-optimisations like this or you'll make your code harder to understand and maintain. As shown above, it doesn't even change anything as the compiler is smart enough to remove the constant expression. Only hand tune the critical sections of your code if it is absolutely requ...
by jahboater
Sat Nov 21, 2020 2:44 pm
Forum: Beginners
Topic: Screen brightness for bedside
Replies: 10
Views: 429

Re: Screen brightness for bedside

I use this for a clock. You can reduce the brightness.
https://thepihut.com/products/zeroseg
by jahboater
Sat Nov 21, 2020 1:37 pm
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

while (1) and for (;;) are normal C idiom that every C programmer should understand. Of course. I just find "repeat" easier to read while rapidly scanning code. You may not, and that's OK! By the way, "repeat" was the original keyword in B that did exactly for(;;) . I always tho...
by jahboater
Sat Nov 21, 2020 12:48 pm
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

rckanta, To answer your question, why not take a look at the code the compiler has produced? gcc -Os -S -fverbose-asm hello.c -o hello.s This compiles your program in, for example, "hello.c", and writes out the assembler in hello.s. You can look at hello.s with any editor or viewer. Try va...
by jahboater
Sat Nov 21, 2020 12:28 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 381
Views: 17238

Re: A Birthday Present for Fido

Heater wrote:
Sat Nov 21, 2020 10:05 am
Yeah, the house is Finish style log house built on the side of a slight incline of solid Finish granite.
I like the sound of the solid granite. Our last house, and this one, are built on clay ... cracks!
Mind you, in Cornwall, areas with granite have radiation worries.
by jahboater
Sat Nov 21, 2020 11:54 am
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

B.Goode wrote:
Sat Nov 21, 2020 9:05 am
How, in your mind, is the 'size' of a piece of code related to how fast it will execute?
More likely to fit in the cache, or within one cache line. or in the case of Intel the loop stream detector ?
by jahboater
Sat Nov 21, 2020 11:45 am
Forum: C/C++
Topic: while(1) vs goto infinite loop
Replies: 35
Views: 1404

Re: while(1) vs goto infinite loop

while(1) might attract warnings like "constant in conditional context" from static checkers or simple compilers. So better to use for(;;) GCC does not warn about this because it is such a commonly used idiom and it knows what the programmer wanted to do. As noted above, with a decent compi...
by jahboater
Fri Nov 20, 2020 6:40 pm
Forum: Other programming languages
Topic: [Rust] Executable size
Replies: 10
Views: 624

Re: [Rust] Executable size

It wouldn't recommend it but its your decision. I'm sure somebody here will complain about bloat but ~150K per executables is nothing compared to the capacity of SD cards. It would only affect startup time, and then only the first time the program is run (it will be in the cache after that). Its an...
by jahboater
Fri Nov 20, 2020 5:12 pm
Forum: Other programming languages
Topic: [Rust] Executable size
Replies: 10
Views: 624

Re: [Rust] Executable size

The Rust calling Rust calling convention is specifically not fixed because they want the freedom to change it for language and optimisation reasons. Fair enough. You can tell it to use the C calling convention but non-optimal etc... I didn't mean anything specific to C, I meant the ABI for the plat...
by jahboater
Fri Nov 20, 2020 4:51 pm
Forum: Other programming languages
Topic: [Rust] Executable size
Replies: 10
Views: 624

Re: [Rust] Executable size

trejan wrote:
Fri Nov 20, 2020 4:39 pm
Rust doesn't have a stable ABI so you can't do much about this at the moment.
Do you know why it doesn't just use the normal ABI for the platform?
The same ABI it uses to access the functions in glibc.

Go to advanced search