# BSD Foundation, Using plain C?



## Spartrekus (Feb 1, 2018)

Hello,

Something very obscur to me. I was just wondering.

_*Why to use Perl or Python when you can use plain C? *_
Dennis would use C.

I wonder why today *BSDs aren't more focused on making an operating system, which is closer to its original common programming ideas.

I can give you example if you want, but you may think from your own daily use (see some *BSD packages).

The _C Foundation _and BSD-_Programming_ _origin_ are my opinion vital to *BSD.
BSD looks too much a Linux, but it is less closer than original first PDPs machines.

see source code of PDP-7 for instance.
(I am talking to a programmer).


----------



## ShelLuser (Feb 1, 2018)

I think you should reverse the question: why not use Perl or Python when you can use plain C?

Not everyone will be fluent with C, and in some cases Perl / Python (/ Java?) can help to reach a certain solution much quicker. I can simply code my Perl script and then run it, I don't have to bother with compiling, optionally linking, etc. I script, I `chmod +x` and I'm done.

For me this simply boils down to using the right tool for the job at hand. Sometimes that's a shell script, sometimes it's a Perl script and sometimes it's a C or Java program. And sometimes it's simply personal preference.


----------



## Spartrekus (Feb 1, 2018)

ShelLuser said:


> I think you should reverse the question: why not use Perl or Python when you can use plain C?
> 
> Not everyone will be fluent with C, and in some cases Perl / Python (/ Java?) can help to reach a certain solution much quicker. I can simply code my Perl script and then run it, I don't have to bother with compiling, optionally linking, etc. I script, I `chmod +x` and I'm done.
> 
> For me this simply boils down to using the right tool for the job at hand. Sometimes that's a shell script, sometimes it's a Perl script and sometimes it's a C or Java program. And sometimes it's simply personal preference.



Programmers MUST be fluent in C. This is basics. 

Turbo C must be on curriculum of programmers in Japan, so why not in Europe?


----------



## ralphbsz (Feb 2, 2018)

Spartrekus said:


> Why to use Perl or Python when you can use plain C?


Perhaps because the same thing that takes 1000 lines (hard to debug and error-prone) in C would take 100 lines in Perl or Python, and 10 lines if you find the correct library that already solves most of the problem?  Perhaps because the productivity of programmers in high-level languages is 10x higher than in low-level languages?



> Dennis would use C.


I never asked Dennis what languages he would use for which problem. Sadly, we can't ask him any longer, he's gone.  But he did work on a system that also had languages like ksh (written by his friend Korn) and awk (written by his friends Aho, Weinberger and Kernighan) available, and I would bet that for many problems, he used scripts.

Suggestion: Take a small programming problem, such as "write accounts receivable and billing, with interface to a part number database, a customer database, and an accounting database".  Write the first solution in straight C, including all the string manipulation that is required.  Then write it in a high-level language that has string processing, database interfaces, print formatting built in (like the old dBase language, or in Cobol with Codasyl interfaces, or RPG-3), and you will find that the solution in those languages is much easier, maintainable, faster to write, and less bug-prone.  Just getting the string processing to work correctly without any memory leak bugs in C requires enormous discipline and attention to detail.



> I wonder why today *BSDs aren't more focused on ...


Because they can't focus on a single thing.  If you want a system for educational purposes, you are better of with Minix.  If you want a system with X, you are better of with Y, and so on.  The *BSD, by their nature, have to be a compromise.

By the way, you do know that it is perfectly possible to use (object-oriented) C++ in the kernel of the various Unix-like operating systems?  I've written plenty of C++ code that implements kernel functions such as file systems.



> see source code of PDP-7 for instance.


The first prototype version of Unix for the PDP-7 was not written in C.  It was written in assembly.  I don't remember when C came in, but it was about the same time they moved to a PDP-11.  And the history of C is full of other languages, with names like "B" and "BCPL".



> Programmers MUST be fluent in C. This is basics.


Actually, that is very doubtful, and a matter of great debate.  Good programmers must first and foremost understand good software design, and good engineering practices.  It is not clear that low-level languages (such as C or assembly), with their attention to minutiae, foster that thinking for beginners.  At some point, a good programmer also has to understand how real-world computers actually work, but C doesn't describe the load/store/register/ALU/... architecture of modern CPUs terribly well.

The other question one has to consider here: do you want to educate programmers, software engineers, or computer scientists?  These terms are not at all synonymous, and require different (but overlapping) skills.  I think most CS and CE degree programs today use Java or python as the first language.

Disclaimer: I was taught programming before C was in widespread use, and learned PL/1, Pascal, 370 assembly, and Fortran and Cobol as high-level languages.  With a lot of Basic and microprocessor assembly thrown in for small computers.


----------



## ralphbsz (Feb 2, 2018)

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.

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.


----------



## drhowarddrfine (Feb 2, 2018)

I haven't read the thread but the reason for C is speed and small size. Stuff an operating system needs. You will never find anything else in a competent operating system except assembly except in areas where it doesn't matter.

I find it amazing when I talk to programmers and talk about the flow of data from processor to memory to disk  via data lines etched on circuit boards and bits in memory and they have no clue what I'm talking about.

I have not done any serious electronic design since 1992 except one-off projects for the theatre and film. I've always been a sloppy solderer and was always grateful to have a technician to do that for me except, sometimes, for prototypes. But, as the designer, one needs to understand the issues around circuit board fabrication and the soldering involved. It's a sad statement on today's education that an EE does not need to learn essential fundamentals.


----------



## Maxnix (Feb 2, 2018)

May Master Foo enlight you through these koans  :
http://www.catb.org/esr/writings/unix-koans/ten-thousand.html
http://www.catb.org/esr/writings/unix-koans/shell-tools.html


----------



## Maelstorm (Feb 3, 2018)

As someone who writes low-level software, C and assembler are a requirement.  Take FreeBSD for instance.  95% of the kernel is written in C.  The last 5% is written in assembler.  Those assembler parts are in the CPU specific branches which allows C to have access to different processor features and constructs which is not defined in the language.  You can use C++ in the kernel, but it's not efficient.  Linus had a few words to say about that awhile back.

The below link has a bad language alert.

http://harmful.cat-v.org/software/c++/linus

One other thing...  Sac State is Java heavy.  However, since I am almost done, so far I have only needed Java in two different classes: Algorithms and Analysis, and Object Oriented Graphics.  They do teach other languages though.  Python, C, Scheme, and Prolog to name a few.  It depends on what you are trying to do.  One of the required courses, Computer Architecture & Organization, teaches Verilog.  I also took the advanced CA&O class where we get to design and simulate a CPU.

They teach more than just coding, they teach how to write software.  Now when I look back on some of my older code, it looks to be a sloppy mess compared to how I am coding now.


----------



## herrbischoff (Feb 3, 2018)

Spartrekus said:


> Programmers MUST be fluent in C. This is basics.



It entirely depends on what you're working on, high level or low level and how efficient you want/need to be. Try building a web application in C and you will quickly recognize there are way more efficient ways to do that. You could do it but beyond a certain level of complexity it just wouldn't be a good choice. Being able to effectively manage complexity is also a sign of a good software engineer — and one that's increasingly underrated. What's important is understanding how things work and how to design good software. But you don't need to know everything. Just as I'm sure you don't intimately know about the CPU firmware in the machine you're using. Because you really don't have to. Same as getting into a car, turning the key and drive. You don't need to know about the engineering concepts behind it. On the other hand, if you're an automobile engineer, you absolutely do.


----------



## herrbischoff (Feb 3, 2018)

Maelstorm said:


> http://harmful.cat-v.org/software/c++/linus



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

Please tell me this is satire.


----------



## drhowarddrfine (Feb 3, 2018)

herrbischoff said:


> Try building a web application in C and you will quickly recognize there are way more efficient ways to do that.


Well...actually...my business is founded on just that. And we do very well though it's a niche in a way.

We create high performance web sites for the entertainment industry mostly. Everything we do is in C from page generation to serving it up. In a way it's a niche but it's where all web sites should be if companies could find enough people to do what we do in C. While many complain about the speed of serving up pages, we coast along with smaller servers doing 10x the work. 

But our clients are those not looking for web sites that look the same or work the same as everyone else's. No Wordpress here.


----------



## herrbischoff (Feb 3, 2018)

drhowarddrfine said:


> In a way it's a niche but it's where all web sites should be if companies could find enough people to do what we do in C.



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.


----------



## Snurg (Feb 3, 2018)

ralphbsz said:


> 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.


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.

By the way, I haven't touched C seriously for years until recently.
I felt myself like doing assembly language. Tedious and cumbersome. Bleech!
Perl probably made me even more retarded as I was anyway...


----------



## drhowarddrfine (Feb 3, 2018)

herrbischoff said:


> What I mean by "efficient" in this context is development time rather than resource usage.


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)

I also like to say that, if it weren't for the slap it together mentality, we might not need the CPU power, exorbitant amount of memory and disk space we see on Mom's home computer today (though 640KB would not be enough). As an example, we have some cheap e-commerce sites that don't get a lot of traffic but it is decent at times. They've been with us for years and all share the same old server with a 256GB hard disk and 512MB of ram but the pages blink on when you access them. No slow down here and we don't do anything special with them but use the same standard HTTP/HTML/JavaScript/etc, database and all put together with C and current with today's standards.

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)


----------



## drhowarddrfine (Feb 3, 2018)

Snurg I don't know which university that is but I always question that when you look at such "schools" that claim to be universities and colleges. I went to school for EE, not programming, but people forget that a Computer Science degree is in the field of Computer Science, not programming.


----------



## Spartrekus (Feb 3, 2018)

ralphbsz said:


> Perhaps because the same thing that takes 1000 lines (hard to debug and error-prone) in C would take 100 lines in Perl or Python, and 10 lines if you find the correct library that already solves most of the problem?  Perhaps because the productivity of programmers in high-level languages is 10x higher than in low-level languages?



Unefficient coding, it is sure, with less lines (apparently), and just to spoil memory and resource. 
So, why to use Perl when finally the programmer has 60 pct resource to waste.

There are many good examples that may show how much over-used is Perl.


----------



## Snurg (Feb 3, 2018)

drhowarddrfine
The problem I see is that learning theory only doesn't help much when one wants to actually practice a trade. See Phishfry's post above.
And, see herrbischoff's post (#11) what happens when things are being developed by pure theoreticists.

And regarding your post #15, it's actually some interesting truth in it. When one considers the resources (hardware, electricity) consumed by assembly (or C == near-assembly) programming products, one could contemplate how many nuclear power plants less would be needed if all the web stuff would be done in assembly instead of Perl, PHP, etc.
On the other hand, how little technology would be in actual use when there were no tools like NC machines that can mass produce things that only a few highly skilled masters of craft trades can produce without sophisticated tools...

Regarding Arkham University, I love H.P. Lovecraft's stories.

@Spartekus
I wonder how much of the gigahertzes and terabytes are actually being used in many cases. When hardware idles 99.9999% of the time it probably does not matter much when that "efficiency" gets reduced to 99.99%...


----------



## Spartrekus (Feb 3, 2018)

Snurg said:


> drhowarddrfine
> The problem I see is that learning theory only doesn't help much when one wants to actually practice a trade. See Phishfry's post above.
> And, see herrbischoff's post (#11) what happens when things are being developed by pure theoreticists.
> 
> ...




Interesting...
More nuclear plants is likely THE solution to our informatic's evolution (devolution?).


----------



## herrbischoff (Feb 3, 2018)

drhowarddrfine said:


> all put together with C and current with today's standards.



Okay, so back on topic: I think we can agree that while C may be a powerful tool at your disposal if you have it, it is not strictly necessary for a developer to know it to write good software, yes?


----------



## herrbischoff (Feb 3, 2018)

Spartrekus said:


> Interesting...
> More nuclear plants is likely THE solution to our informatic's evolution (devolution?).



Quick question: was your original question just meant as a rant fueled by a superiority complex because you believe by being a C programmer you have seen the light? Or are you truly interested in the actual practical reasons behind why scripting languages are used in certain instances instead of compiled ones like C – and are open to the answers even though you may disagree on a purely theoretical level?


----------



## drhowarddrfine (Feb 3, 2018)

Snurg There is "craft" and there is "a trade" and I may not be correct with the definitions but it falls back to my comment about "slapping things together" which I find so prevalent in the web dev industry. 

I had a company approach us about re-doing their web site. It was last updated in 1999. His brother did web dev for simple "business card" sites using common CMS systems and he had done the programming for his current site. He asked how long it would take for us to put together a layout package/concept, I told him three weeks. "Three weeks!", he replied, "My experience is you should complete the whole thing in three weeks!".

Needless to say, I ended the conversation and left. We are craft, not trade. "Fast, cheap or good. Pick two.", as the saying goes. 

herrbischoff I'm not trying to say you can't write good software without C. I'm saying the goals are different.


----------



## Preetpal (Feb 3, 2018)

drhowarddrfine said:


> We create high performance web sites for the entertainment industry mostly. Everything we do is in C from page generation to serving it up. In a way it's a niche but it's where all web sites should be if companies could find enough people to do what we do in C. While many complain about the speed of serving up pages, we coast along with smaller servers doing 10x the work.



Are you doing CGI programming in C?


----------



## Preetpal (Feb 3, 2018)

herrbischoff said:


> Quick question: was your original question just meant as a rant fueled by a superiority complex because you believe by being a C programmer you have seen the light? Or are you truly interested in the actual practical reasons behind why scripting languages are used in certain instances instead of compiled ones like C – and are open to the answers even though you may disagree on a purely theoretical level?



This is obviously a joke thread IMO (or written by someone who does not understand the concept of trade-offs).


----------



## herrbischoff (Feb 3, 2018)

drhowarddrfine said:


> There is "craft" and there is "a trade"



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. 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.


----------



## drhowarddrfine (Feb 3, 2018)

Preetpal We use what's needed. 



herrbischoff said:


> Instead of explaining why it takes you this long to do things, you turn around and leave.


I never said that. Of course we explained things. We're professionals.


> The client has different needs, simpler. Not everything has to be on your level of technical sophistication.


I did say that.


----------



## herrbischoff (Feb 3, 2018)

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.


----------



## Preetpal (Feb 3, 2018)

herrbischoff said:


> 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.


----------



## Maelstorm (Feb 3, 2018)

ralphbsz said:


> 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.



ralphbsz said:


> 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.



herrbischoff said:


> 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.



herrbischoff said:


> 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.



drhowarddrfine said:


> 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.  



drhowarddrfine said:


> 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.



Snurg said:


> 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.



herrbischoff said:


> 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.


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



herrbischoff said:


> 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.


----------



## herrbischoff (Feb 3, 2018)

Maelstorm said:


> Which is why we have all the security problems with websites today.



Indeed. That's a systemic problem though:



Maelstorm said:


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



All too often fast and cheap is picked. As long as people are asking/willing to stumble forward at breakneck speed, this will not change. It's a very complex and multi-layered problem.


----------



## ralphbsz (Feb 3, 2018)

Maelstorm said:


> 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.


----------



## CraigHB (Feb 3, 2018)

Maelstorm said:


> 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.


----------



## aragats (Feb 3, 2018)

CraigHB said:


> 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!


----------



## Maelstorm (Feb 3, 2018)

CraigHB said:


> 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.



CraigHB said:


> 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.


----------



## Maelstorm (Feb 3, 2018)

aragats said:


> 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.


----------



## aragats (Feb 3, 2018)

Maelstorm said:


> I find that hard to believe because CS majors are REQUIRED to take calculus math and linear algebra for the major.


That what I thought, and that what used to be in the past.


----------



## Spartrekus (Feb 3, 2018)

aragats said:


> 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


----------



## CraigHB (Feb 3, 2018)

aragats said:


> ... 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.


----------



## herrbischoff (Feb 4, 2018)

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.


----------



## aragats (Feb 4, 2018)

herrbischoff said:


> Do you think this is even possible without trying to get a university CS degree?


Definitely! Just need to understand the data types and pointers since in C they represent real things.


----------



## Snurg (Feb 4, 2018)

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)


----------



## Spartrekus (Feb 4, 2018)

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.


----------



## drhowarddrfine (Feb 4, 2018)

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.


----------



## Spartrekus (Feb 4, 2018)

drhowarddrfine said:


> 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.



There is a good link on archive.org: https://archive.org/details/TheCProgrammingLanguageFirstEdition


----------



## Nicola Mingotti (Feb 4, 2018)

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


----------



## Snurg (Feb 4, 2018)

drhowarddrfine said:


> 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.


----------



## drhowarddrfine (Feb 4, 2018)

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.


----------



## Snurg (Feb 8, 2018)

By the way, C++ does not necessarily result in big chunky programs.

From Wikipedia: "The entire game uses only 97,280 bytes of disk space." On Youtube there is a  full gameplay video.


----------



## Spartrekus (Feb 12, 2018)

Snurg said:


> By the way, C++ does not necessarily result in big chunky programs.
> 
> From Wikipedia: "The entire game uses only 97,280 bytes of disk space." On Youtube there is a  full gameplay video.



C++ is not that bad, actually.


----------

