Larkin, Power BASIC cannot be THAT good:

many if

written in

routine.

me nice

Crimson Editor has this "search" thing that lets me find all references to a label. Pretty nifty.

John

Reply to
John Larkin
Loading thread data ...

many if

written in

routine.

me nice

Sure, I use a fancy editor too, but it won't tell you where the execution came from to get there. docxx does.

I think a lot of these differences of opinion come from different people's strategies for managing complexity. I like to do it hierarchically, using well-defined interfaces between levels, and keeping each level simple. Classes and templates are a huge help to me there. I don't use the C++ library very much.

Most of my big programs are either instrument code or simulators of one kind or another--e.g. a big 3D electromagnetic simulator, an optimizing filter design program (back in the day) and a bunch of physics-based device simulations. Those kinds of things map pretty well onto classes, and some care in choosing the class hierarchy will generally yield a good program that runs fast and doesn't have weird bugs. I don't use exceptions, because for what I do, the best response to most kinds of errors is to print an informative error message and then abort. If I were writing web apps or vehicle control systems, I'd certainly do it differently.

C++ was originally a C front end, designed to be like Simula 68, which is more or less how I use it.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
 Click to see the full signature
Reply to
Phil Hobbs

It could be worse.

The FORTRAN "Assigned GOTO" was distinctly worse than a C "goto".

The worst such in a traditional language, I think, was the use of the ALTER verb in COBOL, which could modify (at runtime!) the intended target of a single-sentence GOTO paragraph. As a result, you couldn't trust any such GOTO in COBOL to do what the source code said it did - you had to check the rest of the program to see if it was ever ALTERed.

Reply to
Dave Platt

many if

written in

numbers,

routine.

allowed me nice

Well, I design electronics, and this is sci.electronics.design. I certainly wouldn't write a web browser in assembly or in BASIC, but then I wouldn't write a web browser at all.

At some level of complexity, bugs are unavoidable. One approach to preventing bugs is to not design stuff that complex.

Embedded systems have nowhere to print informative error messages to, no option to abort. Simplicity, visibility, and control of *all* the code is the safest way to do mission-critical stuff.

My old XP machine is getting pretty stable, though. I don't have to do a forced reboot more than a couple of times a week.

John

Reply to
John Larkin

True. Every line number was effectively a label. Blech.

Wow. And why were you using this abomination? You got it free from your brother-in-law or something?

Cheers

Phil Hobbs

Reply to
Phil Hobbs

Agreed. That feature was years (maybe decades?) before "GOTO considered harmful".

Naah. I joined the repeater project after the decision to buy/use it was already made. The other guys on the team recruited me because (I strongly suspect) they realized that they were in rather over their heads. It's actually a very flexible and powerful multi-radio- capable controller... it's just *weird* (and a good object lesson as to why hardware engineers ought not to be the sole designers of projects that have a software component :-)

I took it as a challenge. It was... but some careful coding and design discipline (and a custom compiler for its language that I scribed up in Perl) actually made it tolerable to program.

The most important rule I figure out was "Don't try to optimize changes between operating modes. On any change in mode, reset

*everything* to a single known starting state, and then apply one set of mods per mode to handle the variable aspects of the configuration."

The users and control operators are happy with the system... that's all that really matters. I've gotten over the trauma, mostly, and don't wake up screaming more than once a month or so :-)

--
Dave Platt                                    AE6EO
Friends of Jade Warrior home page:  http://www.radagast.org/jade-warrior
 Click to see the full signature
Reply to
Dave Platt

anyways,,,

now that

think.

networking

learn

BYTE

CONTENTS

BUFFER

I guess you are having fun with it. I found this example to be one of the most opaque things that i have ever seen. Ugly as well.

Just remember over half of programmers / engineers / instructors / managers / technicians / etc., are not very good at what they do.

Reply to
JosephKK

Only opaque to people who can't read BASIC.

So show us some of your beautiful TCP/IP code. Or any of your beautiful code.

The BASIC code is part of my test/cal program for this,

formatting link

and it works great. As does the product, run by about 7K lines of assembly coded by yours truly. Zero bugs in the first release. You'd probably think it's ugly, too. I've got a guy who wants 50 of them to replace a bunch of racks full of 20-year-old HP gear that they can't maintain any more. We'll save him about 50:1 on both volume and power consumption.

Well over half. What are you good at?

John

Reply to
John Larkin

:-)

At some point object oriented programming turns out to be very convenient. It is possible to use OO programming techniques in plain C, but it is a pain in the ass and memory allocation becomes tedious (just look at the Linux kernel). Thats where C++ kicks in. I have the same background but I gradually started to use more and more C++.

--
Failure does not prove something is impossible, failure simply
indicates you are not using the right tools...
 Click to see the full signature
Reply to
Nico Coesel

On a sunny day (Wed, 20 May 2009 18:23:38 GMT) it happened snipped-for-privacy@puntnl.niks (Nico Coesel) wrote in :

:-)

I really do not know for WHAT? The whole paradigm (difficult word had to look it up one time) or say perhaps "concept" of "objects' and 'object oriented' to me only means that the one who talks about it does not realize that processors normally (Turing machines) process things sequentially,

No problem with Linux kernel in C, it would have been super-bloated and dead long time ago if Linus had allowed C++ in it.

I will give an example from the Linux area about C++, and how bad it is; You must have (as a Linux user) have heard of Qt. Qt is some toolset to create a GUI interface... basically. Qt3 was big, and heavy, KDE desktop and a whole lot of applications for that, were, or are, based on it. Qt was a product from Trolltech. Then Qt4 was released, it did not do anything much new, but it took several hours to compile, was incompatible with Qt3, and even the kernel build tools. It was that same adventure - a dead end street- that MS took when using C++ as language -> into bloatware. It bounced (Qt). The people at Trolltech were smart, and sold the whole thing to Nokia IIRC. Now what Nokia wants with it I dunno, but it is the WORST possible thing to have on a small platform with a simple slow processor and little memory like for example a mobile phone. So... but it made Trolltech some money. As a money making machine the commerce in C++ compilers, C++ books, and as a stimulus for ever more powerful hardware buying, C++ does the hardware manufacturers some service. Now I am not against GUIs, I am against C++ related bloat crap... You see you do NOT need an object oriented language for things that perhaps look like objects, like widgets on a screen. If you want a good, fast, small, practically stable, almost bug free, toolkit to make GUIs in Linux use xforms, I use it all the time, libforms is:

-rwxr-xr-x 1 root root 1580536 2008-02-04 14:42 /usr/X11R6/lib/libforms.so.1.0* Wow, almost 1.6 MB!!!!

Now if I do (du reports in kB): du /usr/local/Trolltech/Qt-4.1.0/

348855 /usr/local/Trolltech/Qt-4.1.0/ 384 MB YES three hundred eighty four Mega Byte!

There is your f*cking C++;

Now that should switch on a light in somebodies head.

Yea, kicks the bucket I hope.

Well, drugs are addictive too.

If you do not mind my asking : What is that incredible application you need that

++ in C for?
Reply to
Jan Panteltje

about :-)

were,

hours

language -> into bloatware.

have

stimulus

some service.

look

to make GUIs in Linux

that ++ in C for?

As I said earlier, it's very good for simulations and instrument code, where a class corresponds to a thing or a specific process (e.g. an oscilloscope, a tunnel current process, or a volume of uniform composition in an EM simulator. If you get the abstractions right and the class hierarchy right, you can handle a lot more complexity with fewer bugs than in C. (Well I can, and so can lots of others. YMMV.)

One of the best things about it is that you can replace the implementation of the lower-level stuff and the higher level stuff never even has to know. That's a big help in code profiling and optimization--you can code simple and obvious for the most part, and put the tweaks where they actually do something useful.

Of course you have to know what C++ is doing under the covers, e.g. you don't want to call a lot of copy constructors all the time, or you'll die of bloat. That's a minor language wart, about the same nuisance level as checking for null pointers all the time in C.

In general OO doesn't make that much difference in programs smaller than, say, 10k lines of code--just the front end of my EM simulator is

12k, and that's a script!

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
 Click to see the full signature
Reply to
Phil Hobbs

Sure. Let's do everything in assembler. Or, better, directly in the machine codes.

That's the point.

stimulus

some service.

  1. Bloated crap makes money.
  2. C++ is just a tool. If used properly, it helps avoiding certain kinds of the dumb mistakes and simplifies the cooperation between the developers.

Who cares.

that ++ in C for?

If you don't mind my questions, what was the largest program piece that you wrote yourself? What was the largest commercial software project that you participated to as a part of a team?

Vladimir Vassilevsky DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D

D()!

1E9*E!/(10*64E6))

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D

nto 64-million 32-integer sums.

ake the measurement duration more reasonable.

he system("date") functions.

t ) *

d_data,

=A0 =A0// 10 x

E; ++index )

und_data[index];

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D

From what little I remember about C pointers, I believe using subscripts in this case is identical to using pointers. But it's been awhile, so I could be wrong.

I am surprised your programmer did not free() the malloc()'ed pointers.

Not an issue here, since the program will free() everything upon exiting, but still...

Michael

Reply to
mrdarrett

about :-)

The whole idea behind OO is to keep the data and the functions that process the data together in one unit. Even more, functions and data that are internal are hidden from other objects in the program. Sounds complicated but the static keyword makes symbols hidden to other object files in C.

Imagine you create a library. The library obviously has internal functions and data that you don't want to export so you declare them static or tell the linker not to export some symbols. That is already some sort of OO programming. OO programming is like building your application from small internal libraries.

Another thing they added is object inheritance so you can create derived classes from a base class. Last year I wrote a class that can drawn signals on a 'canvas' (drawing area). From this class I derived two new classes. One that can draw to a printer canvas and one to draw to the screen canvas. Ofcourse the same thing can be done in plain C, but the code would have been much harder to understand.

Under the hood a C++ object is nothing more than a pointer to a struct containing pointers to data and functions (vtable).

Sorry, but this doesn't make any sense to me. OO has nothing to do with multi-threading or parallel processing.

Yup. Heard of it. I stayed away from Qt since the beginning. Never liked the fact it is actually closed source.

It is way more, it is intended to create cross platform applications. So you can have one source which builds for several platforms. Therefore Qt must provide a universal replacement for several Windows and Linux APIs. That takes a lot of code! I use wxWidgets for that purpose.

were,

to make GUIs in Linux

I use wxWidgets to write portable applications (I do most development on a Windows machine). I admit wxWidgets is bigger than libforms but wxWidgets does a lot more. I still manage to put X-Windows, GTK2 libraries + engines, a wxWidgets C++ application and misc Linux stuff (busybox, ftp server, etc) into 12MB of flash with several MB to spare on an embedded device (industrial control application).

that ++ in C for?

See above. But I doubt C++ has anything to do with Qt being bloatware.

Look into Gnash (gnu flash player). Entirely written in C++. It also runs on the hardware platform I mentioned above with plenty of space to spare.

--
Failure does not prove something is impossible, failure simply
indicates you are not using the right tools...
 Click to see the full signature
Reply to
Nico Coesel

1E9*E!/(10*64E6))
32-integer sums.

duration more reasonable.

functions.

The assembly code produced by the C program is only five opcodes, and appears to be about as smart as it can be. The only improvement I can suggest is to count down, not up, so a simple test for zero can end the loop.

That was just a test. In the real system, we're going to allocate the buffers (two ADC buffers, one summing buffer) contiguously at startup time and use them forever, shared between various processes.

Our "exit" is the power switch!

John

Reply to
John Larkin

On a sunny day (Wed, 20 May 2009 20:42:22 GMT) it happened snipped-for-privacy@puntnl.niks (Nico Coesel) wrote in :

Yes, but this can be done in C in functions with local vars very easy.

Well, that is one aspect.

I think not, even the contrary, anytime you define a function and give it a sensible name like (referring to your example):

#define DESTINATION_PRINTER 1 #define DESTINATION_SCREEN 2 ... draw_line (int destination, int x1, int x2, int y1, int y2),

and you see that even in the C code example I posted early in this or a related thread, it can be called from anywhere in a program simply by name. If you correctly prototype it, then there will be no errors in the way of calling it with the wrong variables. And do parameter checks in the function itself. Important is to use clearly readable defines, function names, and variables.

Yea, I know that, but I also think that perhaps with statements like 'new' a lot of people do not know what really happens under the hood.

Oh, but it does! What you are referring to seems to be 'modular' (given the example of libs and compacted functions with their own variables).

I do not think C++ is anything else then a bad programming style, a speech disability.

For commercial apps it is nice, as you do not have to release source then of your embedded systems that you sell. You could buy a Qt license, and you would be OK using it commercially. Or are you telling me you are not releasing source and using Linux apps like busybox (see your statement below) in your products?

Well, that may be important if you use different platforms. I bought a copy of Xp for a computer here some month ago, already am sick of it (so now I have win 98 and Xp here LOL). It was actually to try things like that Sony Vegas video editor. I found however it was worse then what I already wrote myself, except for some effects that seem nice... The rest of the Xp apps seem crap too... I installed Visual studio (the free version) on it, but already was longing back for gcc so much that I have not used it. So there really is only one system, Unix (or Linux if you will), that is of any use in this world.

Yes that Wxwidgets or whatever it is called today did not want to compile here, needed things... So rm * -rf fixed that. I think I just found that rm * -rf on that Qt dir would likely make no difference here as I think I use no Qt stuff? Maybe Opera? dunno, but would generate an other

300 MB free disk space, nice for the very long audio and video files I am working with.

I have a web server and stuff in the Linksys WAP54G in < 4MB flash. I have an 2 GB? SDcard with Puppy Linux somewhere....

mmmm I have the macromedia? flashplayer.

Reply to
Jan Panteltje

On a sunny day (Wed, 20 May 2009 14:57:47 -0500) it happened Vladimir Vassilevsky wrote in :

stimulus

some service.

I do not think it helps developers. I have seen a clear example how it did help make a bad product from a reasonable one.

I do, and a lot. Bloat sucks, takes up my time, costs money, under performs, sucks basically.

that ++ in C for?

SO??????????????????????????????????????

That was actually a hardware project, I contributed the hardware design, and the drivers for the hardware. The software department did integrate that with the rest. That was a multi million dollar project.

The largest thing I wrote myself, if you mean lines of code, say 70000 lines of C, around that sort of size, for several apps, like for example this newsreader. No problem whatsoever. Else I would not post here now could I?

I think (my take) you just got VisualC++, and now are trying to justify you using it? This right? Ever used gcc and Linux?

Reply to
Jan Panteltje

Sun bought Trolltech, now it is LPGL for all platforms. Some time ago, before Sun bought the company, you could bought a commercially licence for Linux, embedded platforms and Windows, or you could use the GPL version (not for Windows). Now you can use it with commercial applications for all platforms for free, if you publish all changes to the Qt library you made. But with LGPL you don't have to publish the source code of your program any more.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

But not global variables inside one object file. C++ adds the ability to have multiple levels of variable scopes.

thread,

Okay, imagine working with several people on one project. You create a function called draw_circle and your co worker creates a function called draw_circle. Now that is a bit of a problem if you are not using objects. Either you need to refactor or he.

Absolutely wrong. Where did you get that idea?

needed things...

You should have read the manual installed the proper packages and run configure. wxWidgets compiles out of the box on Windows.

FYI that doesn't run on MIPS platforms.

--
Failure does not prove something is impossible, failure simply
indicates you are not using the right tools...
 Click to see the full signature
Reply to
Nico Coesel

I tried merging the two arrays into a single array, thinking that this might help the CPU data cache, since the x and y would be right next to each other. Theoretically, the cache should read ahead, and grab both x and y, versus having the two arrays in completely different locations in memory. However, after trying it, it actually runs slower than the original!

Original = 1.703 s (best of 3 attempts) Merged = 2.922 s (best of 3 attempts)

I'm completely at a loss to explain why it's slower. Maybe someone familiar with the CPU cache can chime in?

Compiled with bcc32, running on a dual core Pentium something-or-other laptop.

Here's my merged code, modified from Tim Williams' code.

#include #include #include

#define ARRAY_SIZE 64000000

typedef struct{ int x; short y; } packet;

int main(void) {

int i, j; int startTime, endTime; packet *arr;

if( !(arr = malloc(ARRAY_SIZE * sizeof(packet))) ){ printf("Memory allocation failed.\\n"); return -1; }

printf("Starting...\\n"); startTime = GetTickCount();

for( j=0; j

Reply to
mrdarrett

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.