Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Do you have any tips to make development speed in plain C faster?

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
larienna
Posts: 106
Joined: 2014-09-27 20:54

Do you have any tips to make development speed in plain C faster?

#1 Post by larienna »

I am tried to search on the Internet on the subject, but I can only find articles about optimizing program execution speed which is really not what I am looking for. I am more interested about the time it takes to develop a project.

I like programming in plain C (without C++), but one thing I realized is that it works well for small projects and programs which is the UNIX philosophy of having lots of small programs. But when you have larger projects, for example a video game, it takes a lot of time to develop compared to higher level languages.

So I was wondering if there was some tips and ideas to help increase development speed in plain C. So far, I found the following ideas:

1. Delegate to another library: For example, I am using Relational Databases in my program. You can perform complex operation in a single line of SQL code that would have take 20+ lines of codes in C to do the same. So if you have a chance to delegate to another library that can do the job for you, it could help speed up development.

2. Use the "No broken Window" philosophy: After having refactored a lot of my code so far, I realized that a lot of code could have been made in a more efficient way that would have required less lines of code. Yes, programming experience takes a big role in that. But I think taking a step back more often and trying to see if there is a better, simpler or faster way to program something could be essential to gain development speed on the long run. Else, you end up like digging mindless in the wrong direction and it becomes more complicated to move back and dig in another direction. I did a lot of do things over and over again, just for the database interface, I think it will be the 3rd or 4th makeover.

3. Decomposing in smaller projects: I am not sure about this one (It's a work in progress), but maybe re-use the UNIX philosophy of many small programs working together. Here, I could make many small libraries and bind everything together. Maybe by taking each library as a separate implementation problem, it is easier to optimize without having to consider the big picture.

Any other ideas?

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Do you have any tips to make development speed in plain C faster?

#2 Post by LE_746F6D617A7A69 »

Engineering triangle: speed vs quality vs low_cost - You can pick only 2 of them.
Three solutions are possible:
- speed at low cost, but without quality,
- quality at low cost, but forget about speed,
- speed and quality, but at a high cost.

Writing of code takes 10% of the time, testing takes 90%.

From this point of view, the number of SLOC is irrelevant (as long as Your program is supposed to have the end users). End users are expecting quality - they don't care how much time it took to fulfil their expectations.

Technically:
Modularity and unit testing helps a lot in improving the speed of development, using external, ready to use libs is also a very good idea, but You have to keep some reasonable balance to avoid unnecessary overheads, like this:
larienna wrote: 2021-08-15 13:57For example, I am using Relational Databases in my program. You can perform complex operation in a single line of SQL code that would have take 20+ lines of codes in C to do the same.
That "single line of SQL code" is a performance killer, even if Your database has only 100 records - it's probably 1000000 times slower(*) than those "20 lines of C code"


(*) f.e. regex compiling and matching is a deadly slow process ;)
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

larienna
Posts: 106
Joined: 2014-09-27 20:54

Re: Do you have any tips to make development speed in plain C faster?

#3 Post by larienna »

That "single line of SQL code" is a performance killer, even if Your database has only 100 records - it's probably 1000000 times slower(*) than those "20 lines of C code"
Maybe still, SQL databases are relatively optimized.

I managed to do things by hand in C in the past, and it ended up having very long and complex to code where I needed to do a query while reading the results of another query.

In SQL, you just do a query with a table joint in it and the problem is solved. So far, with SQLite have not had any speed issues. I think the gain is not necessarily when you have a lot of records, but also when you have a lot of tables and you need to get information from multiple tables at once. SQL does a very good job at making it easier than C.

Also, less debugging is also welcomed. Because most of the time spent programming is generally to debug code rather than type code. I can easily test an SQL query outside my program. I can also be sure that the queries will return the right results,

Automated testing is indeed interesting, when it can be used. It's not all type of software that could be automatically tested, especially in video games. Still there are other techniques like save states, functional test suites and command line interface that could be used. They are not automated, but it makes debugging faster.

Thanks for the input.

Post Reply