BSD Foundation, Using plain C?

So we agree that you’re a professional boutique development shop focusing on the craft that can also afford to reject customers. Cool, good for you. That’s a good position to be in. Your use-case just doesn’t apply to anything besides your niche and doesn’t answer the question why scripting languages are used for certain tasks instead of C.
 
So we agree that you’re a professional boutique development shop focusing on the craft that can also afford to reject customers. Cool, good for you. That’s a good position to be in. Your use-case just doesn’t apply to anything besides your niche and doesn’t answer the question why scripting languages are used for certain tasks instead of C.

Some customers cost you more than they're worth, especially those with unreasonable expectations.

Isn't the answer to why scripting languages are used obvious? They allow you to reach a solution faster (with less possible bugs, as certain classes of bugs involving memory management and other low level issues like proper string handling are avoided). They also often have high level libraries that allow you to tackle issues without having to deal with small details.
 
Actually, a colleague (who has a master's degree in electrical engineering) tells me that you can now get a EE degree without ever learning how to solder. At first, that sounds shocking. But then, as you think about it: a typical EE these days hardly ever has to solder something. Even if he is doing discrete circuits, those are simulated and designed on a computer, and then sent out to a manufacturing house.

That should be criminal. When I first started in electronics back in 1988, one of the first things we learned was how to solder. It's a very useful skill to have. But there is a major difference between a craftsman and a tradesman (quoting from above). The EE who never touches a circuit is the tradesman because he/she is just doing it as a job. The true EE is the one who also works on and fixes equipment. I was going to be the latter before I saw what the job prospects for EEs were and changed my major to computer science.

Similar, I think that one can be a perfectly good programmer and software engineer without having ever programmed in assembly. On the other hand, a very solid understanding of OOA&D = Object Oriented Analysis and Design is absolutely necessary in today's world, unless one wants to just write small device drivers and javascript web pages. As is a good understanding of how a computer actually works, where the data goes, how fast it travels; the "speeds and feeds" or "cost and value". I'm not sure I see a place for learning C in all this.

They still teach assembly in school. Although it's been awhile (1993 I think) since I took a class in it, Intel x86 is still in my head and gets used from time to time depending on what I am doing. It is still a required course for Computer Science majors because CSC-137: Computer Architecture and Organization requires it because that is the hardware class (verilog) and you get to understand the hardware that actually executes the instructions.

A buddy of mine is a mechanical engineering major who hasn't touched a wrench in his life. In fact, I had to show him how to change a flat tire. So it's the same thing. There are the theoretical engineers and the practical engineers. Both are still restrained by the laws of physics, but the practical engineers are also wrench turners while the theoretical guys have never touched a wrench in their life.

In my opinion, the ones who work on or repair the equipment that is in their major area (electrical, chemical, mechanical, software, etc...) of engineering expertise are better engineers because they understand the practicalities of how things really work than someone who just read books and got their degree.

Through this link I discovered: http://harmful.cat-v.org/software/c++/I_did_it_for_you_all

Please tell me this is satire.

I really don't think it is. With the multitude of languages out there (C, C++, C#, Visual Basic, Java, Python, Ruby, Perl, Assembler, Scheme, Prolog, PHP, 4th, Ada, Pascal, etc...) it's now become right language for the job. C/ASM has been relegated to mostly systems level programming (you can add firmware to that list as well). C++ for GUI apps because that's what the libraries are written in. Scheme was invented to make C programmers suffer hair loss. The other languages have their niche.

Sounds like a nifty little operation. It's great that you're able to pull this off. It's also the exception. I would argue that this may be true for you but not generally. What I mean by "efficient" in this context is development time rather than resource usage. A well crafted C application will always outperform any scripting language, no question about it. But the effort to code, maintain and secure it will probably outweigh its performance properties except in large deployments with heavy load.

In my experience, the most time consuming effort to write a web (or any) application in C is writing all the custom libraries that you will be using. Instead of peppering printf statements throughout your code, make a library call. Once a function is written, you don't have to touch it again. For web servers, there's a lot of code reuse, especially in the site layout code where all the pages have the same look and feel.

I don't disagree with you but I do always say that, too often, programs, and web sites specifically, are slapped together using "other people's code" in order to crank things out the door with as little thought as possible and, kid programmers today never want to think about anything so it fits right in line with with them. (Editorial smirk)

Which is why we have all the security problems with websites today. Remember the Experian breach last year? 153 million Americans had their financial details exposed. Currently, it appears that it was perpetrated by a state sponsored actor. The problem with using someone else's code like that is you do not know what you are going to get with it. At least by using in-house code, if a problem is found during a review or audit, it can be fixed right away and deployed without anyone being the wiser. When you are using someone else's code and an announcement comes out there's some security bug, there is a window of time between the announcement and deploying the fix which leaves a site vulnerable. In the afore mentioned Experian breach, my understanding was that happened to be the case. They were testing the fixes to make sure that nothing broke before deployment.

When I say all that, someone eventually comes along and says something about "reinventing the wheel", "don't repeat yourself", and "doing everything from scratch", and even, "You can't do that without X library and Y framework!!!", but smart programmers know about code re-use. (More editorial smirk)

Especially with custom libraries. You can pull the function out of one library, or even link to the original source file to use it in a different project. Code reuse being easy.

I had to learn at our local university that it's apparently possible to get a CS bachelor nowadays without actually learning to program.
No joke. I learnt that when a fresh CS bachelor in our club desperately asked for help with a simple text extraction problem worth 4, 5 lines of Perl script.

That should be criminal. But here's something else that might be of interest. I recently learned that...HP I think...did a study about correlation between GPA, schools, and the quality of an engineer. As it turns out, GPA doesn't tell the whole story. In fact, there was no correlation between GPA and job performance. As for the schools, they pitted graduates from ivy league schools such as MIT, Harvard, and Stanford against those from the CSUs and UCs. Guess what? The CSU/UC graduates were on par with those from the ivy league schools. Better in fact in some cases. Just goes to show you it's not really the school, it's the curriculum that is being taught at that school.

We’re homing in on the most important point. Craft vs. Trade. If you’re serious about what you do, if there’s a sense of purpose to what you do, you’re probably a craftsman. If you’re doing it because it’s your job, you’re closer to being a tradesman.

Like it or not (and you really don’t like it, it seems), tradesmen are in the vast majority. Which has always been and always will be that way. As long as there’s money and the need to earn it to live, it will be like that. Maybe even then it would be like this because not everyone wants to do a deep-dive for every little thing they do. In a perfect world maybe. However, time is finite. If you decide to spend it on expert-level C, obsessing over shaving milliseconds off processing time, that’s totally impressive and you’re probably a great craftsman.

I guess that makes me a craftsman. I code in three stages.

  1. Make it work.
  2. Make it secure.
  3. Make it fast.
I usually combine 1 & 2 though.

But as you so colorfully illustrated yourself: certain customers aren’t for you. Instead of explaining why it takes you this long to do things, you turn around and leave. It’s your prerogative. It’s also arrogant. The client has different needs, simpler. Not everything has to be on your level of technical sophistication. That’s why pragmatic solutions often prevail over technically pure ones.

It follows the old engineering motto: fast, cheap, good; pick 2.

With that being said, a good selling point will be that the code requires less system resources, therefore you do not need as many servers to do the same work, which saves on total cost of ownership in the form of fewer servers and electricity consumption. Considering how long the platform will be in use, the savings in the long run could be huge, and not just monetary. Less power usage means less greenhouse gasses. But most people don't think of this.

People do need to eat, and therefore need to make a living. If they want it fast, then a CMS like Wordpress would be the way to go. If they can tolerate the development time, then a C or C++ solution could be the way to go and you save in the long run.

However, someone who writes a web application in assembler is insane. Not saying that it can't be done, but pick your poison.
 
You can use C++ in the kernel, but it's not efficient. Linus had a few words to say about that awhile back.
That statement is wrong, whether Linus believes it or not. I know that two of the highest-performance commercial subsystems in kernels are written in object-oriented C++ (because I worked on them).

They teach more than just coding, they teach how to write software.
This is REALLY important. There is a huge difference between coding or programming on one hand, and good software engineering on the other hand. They are different skills, but they have to go hand-in-hand.
 
When I first started in electronics back in 1988, one of the first things we learned was how to solder. It's a very useful skill to have.

I got an EE degree in 1989 through the Cal state university system. Never had a class where we were actually taught to use a soldering iron and assemble circuit boards. Though I had been doing that kind of thing (assembling circuit boards) long before I went to college so it wasn't something I needed to learn there. All the circuits we built in labs were done with a solderless breadboard.

I did take some classes in programming as part of my degree, but back then the lines between computer science and electrical engineering were more well defined. Now they're pretty fuzzy. You can't really be a software engineer without knowing quite a bit about hardware and be a hardware engineer without knowing quite a bit about software. Sometimes the difference between the two is subtle.
 
Never had a class where we were actually taught to use a soldering iron and assemble circuit boards
I don't wonder anymore, at least here in USA... I had a colleague who got a degree in software development but had zero knowledge in math, he had no idea about trigonometric functions for example. However, he was the main developer of a C++/C# GUI application for laser marking!
 
I got an EE degree in 1989 through the Cal state university system. Never had a class where we were actually taught to use a soldering iron and assemble circuit boards. Though I had been doing that kind of thing (assembling circuit boards) long before I went to college so it wasn't something I needed to learn there. All the circuits we built in labs were done with a solderless breadboard.

I started electronics as a freshman in high school. I kinda knew how to solder before then, but then I really learned how.

I did take some classes in programming as part of my degree, but back then the lines between computer science and electrical engineering were more well defined. Now they're pretty fuzzy. You can't really be a software engineer without knowing quite a bit about hardware and be a hardware engineer without knowing quite a bit about software. Sometimes the difference between the two is subtle.

In today's world, EE (or EEE) is less focused on computer hardware and more focused on other areas such as electrical distribution, radio and RF, microwave, and sensors. They still teach the fundamentals with resistors, capacitors, diodes, transistors, etc.... However, computer engineers specifically design computer hardware, but there is a lot of cross pollination between a CE and a CS as we both take a lot of the same classes. For instance, CSC-142 (advanced computer architecture and organization) is an elective for CS majors, but required for CE majors. EEE majors don't even take it as their focus is elsewhere. It is interesting though that EEEs can calculate power consumption of digital circuits while CEs can't. An EEE can do computer design, but the problem is that there is a huge body of knowledge that students are required to know to be able to do that, in addition to knowing everything else that a EEE is required to know. This is why the degree was split into EEE and CE.
 
I don't wonder anymore, at least here in USA... I had a colleague who got a degree in software development but had zero knowledge in math, he had no idea about trigonometric functions for example. However, he was the main developer of a C++/C# GUI application for laser marking!

I find that hard to believe because CS majors are REQUIRED to take calculus math and linear algebra for the major. For me, I have cleared through differential equations, so my math is pretty solid. The person that you speak of probably just did the user interface part of the program which is 90% of an application. The other 10% is the nitty-gritty parts which were probably done by someone else.

One thing I want to point out though. Us system programmers tend to be better overall coders because we take more things into account and write much more robust code. Because we deal with operating systems, we have too. Application programmers are a dime a dozen these days, especially web developers. But the system guys have the real know how on actual programming. The firmware guys are under even more pressure to get it right the first time.
 
I don't wonder anymore, at least here in USA... I had a colleague who got a degree in software development but had zero knowledge in math, he had no idea about trigonometric functions for example. However, he was the main developer of a C++/C# GUI application for laser marking!

Without maths, it is impossible to do much programming.

Graphics (Image files, image and graphical manipulations, 2D projections,...) all need at least some good knowledge in mathematics if you make it in C.

Alternative is to use SDL ;)
 
... I had a colleague who got a degree in software development but had zero knowledge in math, he had no idea about trigonometric functions for example.

Any accredited university engineering program is going to require a pretty high level of math. Even general education in college includes some math. If your associate was not educated in math he probably did not get an engineering degree from an accredited four year college. In my case I went past the minimum for the engineering school with electives. In retrospect some power systems electives would have been helpful in practice, but I enjoyed the math classes.
 
As there appear to be quite knowledgeable C programmers in this thread and the main question is probably resolved, I have one question for everyone:

Say I'd be interested in learning to code proper and modern C — what's the best way and the best resources to go about it?

Short-term, I'd like to be able to write software I might otherwise write in Python with a long-term path towards understanding systems programming. Do you think this is even possible without trying to get a university CS degree? I'm too old for a formal school education and have only basic experience with compiled languages.
 
herrbischoff There is a quite recent thread about books on C, with some good links.

As you know Python, I think you know the basics already. I'd recommend to get a copy of K&R 2nd edition as bloat-free intro and reference, even if it is not latest standard.
Looking at good written C software sources probably will teach you more than most books that are often aimed at programming beginners, which you probably are not.

Another classic I recommend every C programmer to have is "C Traps and Pitfalls" by Andrew Koenig. It is particularly helpful for people with previous experience in other languages.
(BTW, I hope this link is legit. If it is not, I kindly ask to delete it)
 
The C language is BSD foundation.

@herrbischoff: You can learn C by just making yourself the C compiler. There is a good example: PDP C compiler or tcc for this. This will increase learning curve.
Link about first C compilers and Unix source code: url , small C source (url), and CC V7 Unix source Url (see cc.c),... and more.

Snurg : We should not have Python and Perl packages in *BSD, because there is Linux for that.
 
I still say that the easiest book to learn C with is the original K&R book. It may not be up-to-date but you'll find out the differences when you compile the examples. It's a small and easy to read text. My copy from 1985 still sits on my book shelf of honor though I can't tell you the last time I opened it.
 
For Spartrekus ,

I will add my 10 cents this already long and interesting thread.
Consider my academic background is Mathematics and Finance, I learnt many programmnig languages because I like to program computers.

First of all, from your question I guess you do not know any "scripting" language. So I will make some considerations any script-savy programmer knows very well.

1] Choosing a programming language is also a matter of aesthetics. As Wittengstein said "My language is my world". So, if I decide to use e.g. Ruby I know that in my world there are not pointers, I can not refer directly to memory location addresses. On the other side in Ruby world everything is an object. An integer, a float, a string, a file etc. all is an object. Each object can "receive commands" so, suppose "s" is a string, I can convert a string to a floast as "s.to_f" , suppose now "s" is a data-structure, i can convert the structure to JSON with "s.to_json". I can read a file content with "text = File.open("./foo.txt", "r").read" .
Can you see the beauty and elegance of all of this ?

2] Sometimes it is at all not possible to use C. Consider web development, if your code must run in a browser you must use Javascript. If you don't like it you need to find a XXX --> Javascript compiler or you are out of the game.

3] Portability. In the years I wrote some programs in Python (wiht Tk) for customers using Windows. I always developed all the stuff in Linux and then run them on the customer machines with almost zero issues ! ("almost" because, path names are not the same across different OS(es) )
No problem, i fixed the issue in a few minutes changing the source code on the customers machine !

4] If you try to use: Python, Common Lisp, Scheme, Ruby, Node ... you will see they have wonderful thing: the REPL (Read Eval Pring Loop) ! Developing with a REPL is pure happiness.

4] Libraries. Sometimes you must develop niche stuff. During phd I wrote a lot of statistical software. In that case I decided to use R. In my opinion R is really an ugly language but it has so many high quality libraries it would have been stupid to use another language.

5] Goodies. Some languages let you do very cool stuff like modifying functions when the code is running ! I tried this on Allegro CommonLisp many many years ago, I admint I neved had the need to use this feature.

6] Time - Money - Happiness. If your customer asks for a program written in language X, ok you do it that way. But usually they ask a program that solve a specific problem, running in a specific OS and costing below a given amout of $. So, now the choice is up to you, the programmer, you choose the language which maximizes the objective function:
obj = f(HappinessInDevelopment, RequiredDevelopmentTime, ExpectedPortabilityIssues)

7] Ipse Dixit. In "The Unix Programming Environment" by Kerninghan and Pike, more than half of the book is devoted to shell and shell programming (which is how to use the system default scripting language). So, you see, also the Masters belived a scripting language is useful and a more appropriate tool than C in many occasions ;) Personally i prefer not to use "sh" because of portability, If i write a script in FreeBSD in sh, I can not expect it to run in Linux. Not because of "sh" per se, but because core commands are different e.g. "ls".

Bye
Nicola
 
My copy from 1985 still sits on my book shelf of honor though I can't tell you the last time I opened it.
That it's getting dusty in your bookshelf has a reason - it is so outdated (1978) that it is of no practical use nowadays. Not even as a quick reference.
2nd edition (1988) covers ANSI C, and that is basically still a valid subset of today's C, just a bit less strict (which will be obvious to you when clang occasionally tells you this or that is old style and you have to change this or that to match modern C).
herrbischoff asked for a good book that is usable with modern C, not for a book about history.
 
Snurg Then you shouldn't be recommending the second edition either. I agree, I should have said the second edition but they're all the same to me but my nephew learned from my first edition. He now works at Google as a C programmer.
 
Back
Top