# Using Python for conceptual learning or jump straight into C?



## Beastie7 (Mar 18, 2020)

So I've been contemplating the idea of learning to code to help out with the project and address some aspects of it I feel are lacking. Presumably one would learn C if they'd like to get into contributing to FreeBSD. However, I'm torn as to how I should approach this. I understand C could be a difficult language as a first one, but my interest in contributing to FreeBSD sort of overshadows that notion. On the other side, I'd hate to get frustrated and give up on my attempts to learn due to my lack of prior programming experience. Should I "learn programming" first with a something like Python, or is a C good candidate as a first language as well? I imagine I could save myself the time by just using one language, but I also would like to learn programming concepts, correctly, with the least amount of friction.

Any thoughts?

Thanks.


----------



## SirDice (Mar 18, 2020)

Python is object oriented, C is not. While constructs like loops, if..then..else are largely the same in any kind of language, object oriented programming is different from procedural languages like C. In this respect Python may not be the best option to start with. 

I once started with BASIC on the good old C-64. Then went straight to assembler. Learning C came much later. But knowing a bit about assembler definitely helped with grasping some of the interesting aspects of C; pointers.


----------



## ehanneken (Mar 18, 2020)

My first programming language (not counting Atari Basic or Karel) was Modula-2, which I learned in college. But my second language was C. I think you could start there. It's not _that_ difficult. Sure, it does less to stop you from programming wrong than just about any other language, but a good teacher is more important.


----------



## SirDice (Mar 18, 2020)

ehanneken said:


> Sure, it does less to stop you from programming wrong than just about any other language, but a good teacher is more important.


As someone once said, C gives you a lot of slack, more than enough to hang yourself with.


----------



## ehanneken (Mar 18, 2020)

I think the most challenging part of C compared to Python is that it makes the programmer responsible for managing heap memory. It also provides weak support for organizing a large code base, but that's not so important to someone who's just starting.


----------



## rootbert (Mar 18, 2020)

The most important thing: what do you want to do/achieve? - if you don't know maybe just define a field for yourself...
If you want to contribute to FreeBSD, learning C is probably the best idea. Not only because the kernel, drivers and many system tools are written in C, but also because if you know C by heart you know how a computer really works. Thats one very strong asset you get from learning C. When you know C, learning Python happens really fast. For automation/automated test or so basic knowledge in Python is probably enough - you probably won't need the inner parts. Furthermore, Pythons C API is a big advantage: use your modules/programs written in C from Python is very straight forward.

This advice comes from one who programmed C/embedded and is now using Python almost exclusively for everything. Personally, if I had the time or the money so I could quit my work, I would go back to C and improve the things I don't like about FreeBSD, and there are some (improve bhyve, bring encryption to various tools like ggated, improve HAST, improve fuse/sshfs, enhance jails + ecosystem/linuxAPI so we could use docker/docker-like containers, maintain some cluster filesystems like glusterfs, bring smbv3 protocol support, port OpenBSDs PF version, security/performance improvements ... just an idea if you want to start somewhere hehe)


----------



## obsigna (Mar 18, 2020)

The hard core vi(1) fans will spank me, but for me, when learning programming 30++ years ago, the most helpful thing was a visual symbolic debugger, which let me set breakpoints and step through the code and examine changes of the variables, registers, bulk memory while the code is executing. You see your errors immediately and the effects of corrective measures as well. That time it was MacPascal and then Think Pascal on a Mac (Classic) - I still remember how the pre-release of MacPascal was advertised: _"If you think this is something, then wait till we get out the bugs."_

That said, my advice to all beginners is to look out for a decent IDE with a perfect integration of a visual symbolic debugger. Nowadays, I mainly do coding in C, Objective-C and C++ targeted to FreeBSD, however, I use Xcode on macOS because of the unbeaten integration of the debugger (lldb).

Chances are that the IDE's for C type of languages are more complete than for others. You want to ask for a decent IDE for your preferred desktop system, and then start with, and expand on the obligatory "Hello, World" project.


----------



## zirias@ (Mar 18, 2020)

If you want to, start with C. It's not bad for learning programming. What you need (no matter what language) is a good teacher or book or guide. Once you know programming, you can learn new languages with just references and example code.

C has one drawback for learning: "undefined behavior". While modern languages are fully defined, which means you WILL get some (more or less meaningful) message or indicator on any programming error, this isn't the case with C. So, if you have written a C program that *seems* to work correctly, that's no proof it is correct after all -- it could crash and burn on some other system, or compiled with different settings, etc. I think it's obvious why this is a bit difficult for learning. On the other hand, it forces you to work conscentiously from the beginning and understand every bit of your program 

About OOP: You can do OOP in C, all the primitives (pointers and structures) needed are there, but you have to implement the concepts yourself, so it's not a good language to learn OOP concepts in the first place. But I'd recommend everyone who already knows objects and methods to do some OOP in C. It helps a lot for your understanding how these concepts can be mapped to an actual machine.


----------



## msplsh (Mar 18, 2020)

People are telling you they started with BASIC and then waving you off Python, something incredibly more powerful.  That doesn't make a lot of sense to me. 

Python is not my favorite language, but it has enough resources, is good enough for beginners, and can scale up into "useful" programming.  It would be a fine starting place for learning how to program.

C on the other hand is full of sharp knives.  I program in C and like it, but it is not particularly nice.  As others have pointed out, managing memory manually is a challenge and, really, is a huge security problem.  People are explicitly creating memory-managed languages like Rust that are attempting to "kill C" in order to stop these classes of errors but retain speed.

If you want to get into directly contributing to FreeBSD without any C experience as fast as possible, that's going to be a very difficult road.  I would suggest creating a roadmap that will eventually lead you to where you want to go.  Do you prefer quick results or long periods of study?  First you need basic concepts like loops.  Then you'll need more involved stuff like composition and other large program organization concepts.  Basically, a compressed Computer Science course.  In the meanwhile, you'll have to actually practice what you've learned, so you'll need some kind of program to work on.  Again, I would suggest something in Python so you don't cut yourself on stuff that will just get in the way of learning.  All code is garbage, eventually.  Don't get too hung up on what you make.

Pivoting to C will be easy if you don't lean too hard into Python-specific stuff.  It will be kind of like going on a campout and realizing all you have are sticks and twigs to work with.  Then you'll learn the value of libraries.

What do you do as your day job, anyway?  How much time will you have to devote to this?


----------



## PMc (Mar 18, 2020)

From my experience, learning an language for it's own sake does not work. One can only learn a language when there is a task that needs to be coded. And then, the language should match the task.
So, if there is a piece of hardware with some ports, and it is necessary to make it talk to the computer, then C is a good  choice. And if there is some logical entities that interact and change behaviour, some OO would be appropriate.


----------



## garry (Mar 18, 2020)

Beastie7 said:


> So I've been contemplating the idea of learning to code to help out with the project and address some aspects of it I feel are lacking. Presumably one would learn C.....



Yes, of course learn C because it is a very simple language (few keywords, few big ideas) and you must learn C to read and understand the code you are actually running (FreeBSD kernel, the POSIX utilities, graphics layers, audio processing, and almost all desktop software is written in C/C++.  You must learn C before C++ so start by learning C.

A good course is Introduction to Programming in C (youtube playlist).

Learning to read code is important.  Get a used copy of Code Reading:  The Open-Source Perspective.  The goal is to be code-literate.  I guess right now most of us are illiterate.   We shouldn't be -- code is important!


----------



## zirias@ (Mar 18, 2020)

PMc said:


> From my experience, learning an language for it's own sake does not work. One can only learn a language when there is a task that needs to be coded. And then, the language should match the task.


For initially learning programming *at all*, I don't agree. I'd say you are right for people who already programmed and want to learn a new language -- the best way (and reason) for this is indeed having a problem to solve, for which this new language is a good match, or maybe even a necessity because you want to extend some tool via scripting, plugins, whatever.

But for the programming newcomer, picking a task would often lead to something like "I want to write a cool game" ... (seen that quite often). It's much better to first follow a course and solve some example tasks, aimed at learning how to program.


----------



## Beastie7 (Mar 18, 2020)

Wow. These are all great responses. Thank you, I'll keep all of this in mind. I'm glad I asked my question here. 

I think I'm going to take a plunge and dive straight into C given my end goal. My main motivators are desktop related things; ie. WiFi, Bluetooth, USB, ACPI, real time audio, etc. Especially WiFi and bluetooth. I hope to make FreeBSD a better in that domain. I don't expect this to be a smooth path to take, like others have said, it requires a great deal of studying and practice with C, but I think I'll enjoy the challenge. I have plenty of time on my hands so I'm not too worried about quick results; I just want to learn correctly.

From my research Python was suggested as a first language due to it's readability and ease. I agree with the sentiment that with a good teacher and/or guide (books) I should be ok. I might've glossed over that aspect in my thinking. I intend on reading this book, then follow up the K&R book i've read many others have suggested. There's a huge list of PRs and ideas from the wiki I can keep myself busy with too.


----------



## zirias@ (Mar 18, 2020)

Beastie7 said:


> then follow up the K&R book i've read many others have suggested.


Correct me if I'm wrong, but doesn't this still teach pre-standard C? In that case, I wouldn't exactly recommend it for learning


----------



## msplsh (Mar 18, 2020)

Beastie7 said:


> My main motivators are desktop related things; ie. WiFi, Bluetooth, USB, ACPI, real time audio, etc. Especially WiFi and bluetooth



If you've already made up your mind, choose USB first.  The other things in that list have large and infuriating problems to the most experienced developer.

I have the ANSI K&R book.  This should be fine if you're patient.


----------



## ehanneken (Mar 18, 2020)

Zirias said:


> Correct me if I'm wrong, but doesn't this still teach pre-standard C?


The second edition uses C89.


----------



## garry (Mar 18, 2020)

Beastie7 said:


> .....Should I "learn programming" first with a something like Python, or is a C good candidate ..... but I also would like to learn programming concepts, correctly.....



I put in my recommendation to learn C, heck and enjoy! C -- but I'm concerned about _"I also would like to learn programming concepts"._

For *programming concepts* you read Structure and Interpretation of Computer Programs. The appropriate lectures would be Berkeley CS61a Spring 2008 with Brian Harvey or MIT 6-001 Spring 2005 with Harold Abelson himself. Each of those courses has a full set of notes, assignments, and video lectures. SICP uses a language that is even simpler than C, Scheme, and the scheme you should use would be Racket.   A entire approach to learning computer programming uses Racket.  That's called _How to Design Programs (HtDP)_ and there are courses and lectures for that.  The HtDP courses are excellent and definitely teach concepts that are part of real code literacy.

Happy Journey!


----------



## kpedersen (Mar 18, 2020)

I can never decide which is easier to start with C or C++.
C++ provides a lot of utilities (string, vector, etc) but ultimately C is a simpler language.

Once you have nailed something like a hangman or card game, for something more visual than command line, the following tutorials are great to follow whilst learning C or C++.



			Lazy Foo' Productions - Beginning Game Programming v2.0


----------



## zirias@ (Mar 18, 2020)

kpedersen said:


> I can never decide which is easier to start with C or C++.


I have a strong opinion that the answer to *this* question is C. C++ isn't completely bad, but it has a lot of complexity, and some of it is really unnecessary -- it has proven to be too complex for professionals in some (rare) cases, so I'd say it's definitely too complex for someone looking for a language to use while learning to program.


----------



## drhowarddrfine (Mar 18, 2020)

Beastie7 said:


> I intend on reading this book, then follow up the K&R book i've read many others have suggested.


I think that's backwards. K&R will be shorter and easier to get through but it might not be as up-to-date or inclusive as Modern C which I also hear is a good book.

EDIT: I see the Modern C book is under 300 pages which, I think, is about the same as the Ansi K&R book.


----------



## Beastie7 (Mar 19, 2020)

msplsh said:


> If you've already made up your mind, choose USB first. The other things in that list have large and infuriating problems to the most experienced developer.



Thanks for the suggestion. I figured USB would be the least difficult interface to work with. I'll probably start there. 



drhowarddrfine said:


> I think that's backwards. K&R will be shorter and easier to get through but it might not be as up-to-date or inclusive as Modern C which I also hear is a good book.
> 
> EDIT: I see the Modern C book is under 300 pages which, I think, is about the same as the Ansi K&R book.



From what I've read, the modern approach book is better as an introductory/structured approach to programming using C; which I see as a plus for a beginner such as myself. It also teaches the language itself, hence it's length I believe. Whereas the K&R book is a supplementary book to it.


----------



## drhowarddrfine (Mar 19, 2020)

Beastie7 said:


> Whereas the K&R book is a supplementary book to it.


No. That's not true at all. The K&R book came out long beforehand.


----------



## kpedersen (Mar 19, 2020)

Zirias said:


> C++ isn't completely bad, but it has a lot of complexity, and some of it is really unnecessary.



I do see your point. Possibly it is easier to learn up to about 10% 3% and then once RAII, templates and exception safety kick in, its learning curve skyrockets. Whereas C doesn't really have a learning curve haha.



pyret said:


> Is that in jest?
> 
> Nobody should start with C++ or Java if they want to learn OOP.


I don't necessarily believe the OP should learn OOP (at this stage it is not ideal to get locked into that mindset). The C++ was mainly so that they could experience C without the entirely raw memory handling (which can be tricky for anyone starting out).


----------



## Beastie7 (Mar 19, 2020)

kpedersen said:


> I can never decide which is easier to start with C or C++.
> C++ provides a lot of utilities (string, vector, etc) but ultimately C is a simpler language.
> 
> Once you have nailed something like a hangman or card game, for something more visual than command line, the following tutorials are great to follow whilst learning C or C++.
> ...



Thanks for the suggestion. It looks like another great resource. I hear a lot of game programmers do "C-style C++" and use only a small subset of it's exclusive features that may be lacking in C. But that's another topic. Also, I wonder if that's what the KDE guys do.


----------



## msplsh (Mar 19, 2020)

C++ is terrible.  The "only use a subset" is the only right way to use it, IMO.


----------



## zirias@ (Mar 19, 2020)

msplsh said:


> C++ is terrible.  The "only use a subset" is the only right way to use it, IMO.


Well, a lot of things about C++ are less then ideal. If I have the choice, I always prefer C over C++. For desktop GUIs, I really like Qt, which forces me to use C++, but I also like the fact Qt allows `-fno-rtti -fno-exceptions` 

Recently, a lot of people realize exceptions weren't a great idea after all (and I think they are a _particularly_ bad idea in C++), things like railway-oriented programming and other functional styles are trending. But criticism of exceptions is much older: http://www.lighterra.com/papers/exceptionsharmful/


----------



## rigoletto@ (Mar 19, 2020)

C is good because you will learn how computer works but may give you with too much of hacking mentality (instead of software engeneering), C++ is brain fuck and might be delusional, and Python is likely to give you a lot of vicious.

IMO, the best language to learn programming is Ada[1] because it will force you to do and think things right (software engineering-wise), otherwise you will not be able to write anything that run. OCaml is also a good one. 

[1] but better use Debian for that because that is the OS with the best out-of-the-box Ada support.


----------



## jdrch (Mar 19, 2020)

If you're just learning how to code, definitely start with Python. Python's advantage is its minimal syntactical overhead and automatic formatting allow the student to focus on programming concepts as opposed to syntax. In other words, Python gets out of your way.

Once you get that down, then by all means move on to C.

This won't be a short or quick process, and besides learning the language you're also gonna have to learn the FreeBSD development methods and culture, which may be even more challenging than the language per se. You'll also have to learn about the system(s) you're hoping to develop for. 
All the best!


----------



## garry (Mar 19, 2020)

pyret said:


> .....
> Scheme isn't as large as Racket and is probably easier to start with.....



The reason I had said that you study the SICP book using Racket is that Racket directly supports the SICP code with its SICP language -- Racket can be many languages even simple scheme or even the exact scheme used in SICP by simply stating

```
#lang sicp
```


----------



## toorski (Mar 19, 2020)

Here are few steps for anyone who is seriously interested in so called computer related sciences.
*Study and learn:*

_Calculus One (at least)
Basic Electronics Theory
Basic Electronics Circuits
Basic Digital Electronics
Integrated Circuits
Digital Controllers
CPU/ALU Instructions_


Then you can learn low level assembled computer code to understand how digital circuits and their logic work. After you master and understand the basics, you can decide which high level computer language you want to learn, such as C,  that will teach you how to program and control computer system to do some useful things. When you get handy with all the above, you should enter College or University program that may help you become Professional Software Engineer who can tackle any software related project(s), in any computer software language.


----------



## mark_j (Mar 19, 2020)

Beastie7 said:


> Thanks for the suggestion. I figured USB would be the least difficult interface to work with. I'll probably start there.



Yikes! Please look at USB standards before you make that leap; it's very, very demanding. USB specs are notorious for adding standards before standards. Just look at usb 3.2 v 4.0. It's a standard where manufacturers can pick & choose what to implement.

As to coding language, if you're writing device level drivers then you have no choice; it's C. Once you know C you can expand to C++ and its massive verbosity. C++ will also give you more acces to the application layer of a gui as it seems the most common language for widget toolkits.

C is not as scary as some would say, with the only proviso being its handling of memory access via pointers and this is where SirDice's opinion of knowing assembly really does help, but short of that remember in C everything is just a memory location; a function, a variable, a pointer, a structure and so on.

<scandalous troll> python's a toy language good for teaching OO concepts </scandalous troll>


----------



## 20-100-2fe (Mar 19, 2020)

In order to learn, you need to practice, to experiment, in order to make sense out of new notions, to check the correctness of your understanding and to effectively memorize.

My advice is to choose a concrete project first and to learn the language used to develop it. The more non-IT knowledge you have about the chosen project's domain, the easier your learning will be because the IT notions you'll learn will immediately make sense to you in a concrete and familiar way.

It doesn't matter which language you start with, once you know how to learn one, you can learn any other as well.

Also keep one thing in mind: learning to code is not your main activity, you don't have much time to spend on it and this time comes at the end of a work day. The more meaningful your learning, the more sustainable and successful.


----------



## garry (Mar 20, 2020)

Beastie7 said:


> .....Any thoughts?
> 
> Thanks.



And *thank you* Beastie7 for continuing to participate in this thread so actively.  It's been a joy to see your reactions to such big and ambitious suggestions and differing viewpoints.


----------



## Beastie7 (Mar 20, 2020)

garry said:


> And *thank you* Beastie7 for continuing to participate in this thread so actively.  It's been a joy to see your reactions to such big and ambitious suggestions and differing viewpoints.



No problem.  Im glad I was able to incite a constructive discussion amongst the members here in the forums, and am thankful for the feedback. It's really encouraging


----------



## unitrunker (Mar 20, 2020)

I would break up learning C/C++ into four stages.

1. Standard C with structs and pointers and classic FILE* I/O.
2. C++ with object oriented structs (class).
3. STL for strings, containers, iterators and streams.
4. Templates.

Using a well defined template library is easy enough but writing your own requires much more thought.

Many people think FreeBSD is C only. Not so. I was looking at the source for devd the other day. It is C++.

I think C is easier to learn for someone who has already learned on form of assembly.


----------



## SKull (Mar 20, 2020)

Beastie7 said:


> So I've been contemplating the idea of learning to code to help out with the project and address some aspects of it I feel are lacking. Presumably one would learn C if they'd like to get into contributing to FreeBSD. However, I'm torn as to how I should approach this. I understand C could be a difficult language as a first one, but my interest in contributing to FreeBSD sort of overshadows that notion. On the other side, I'd hate to get frustrated and give up on my attempts to learn due to my lack of prior programming experience. Should I "learn programming" first with a something like Python, or is a C good candidate as a first language as well? I imagine I could save myself the time by just using one language, but I also would like to learn programming concepts, correctly, with the least amount of friction.
> 
> Any thoughts?
> 
> Thanks.


Actual professional programmer here.
I'd recommend python.
Why?
To actually learn programming, you need to program (and encounter problems) A LOT.
Python gives you the benefit of not having to know every single detail from the start.
Even 'bad' python can get you actual useful results. The keyword here is useful. You need lots of little projects. Python lets you accomplish those projects.
With C, you need to force yourself in the beginning to even come up with projects that seem realistic and it's usually a bit more complicated. So the danger of being overwhelmed and giving up is way bigger than with python.

Good luck!


----------



## rpx (Mar 20, 2020)

C is not difficult to learn and is the language you ultimately want to use. Learning C will  also teach you a lot about how computers work. Just get a copy of this classic and beautiful book and work through the problems:
'The C Programming Language' by Kernighan & Ritchie








						The C Programming Language - Wikipedia
					






					en.wikipedia.org
				



Good luck!


----------



## Pummelchen (Mar 20, 2020)

Python is not a proper programming language but a script on the same junk level as Javascript. Both cannot ensure that your data stays valid, so you end up with NAN's in arrays and your data result is bs. 

Only C++ and C99 guarantee that you data stays valid at all times and you get protected by compiler errors and program crashes.


----------



## Crivens (Mar 20, 2020)

Pummelchen I do think I have a bridge to sell you. Or a tower.


----------



## shkhln (Mar 20, 2020)

Pummelchen said:


> Python is not a proper programming language but a script on the same junk level as Javascript. Both cannot ensure that your data stays valid, so you end up with NAN's in arrays and your data result is bs.
> 
> Only C++ and C99 guarantee that you data stays valid at all times and you get protected by compiler errors and program crashes.



You jest, but C really makes one think twice whether a fancy feature is actually worth implementing.


----------



## 20-100-2fe (Mar 20, 2020)

SKull said:


> With C, you need to force yourself in the beginning to even come up with projects that seem realistic and it's usually a bit more complicated.



In any language, C included, you can begin with writing a very simple, yet useful program. An example of such simple program is a filter (read stdin, parse, transform, write stdout).

You can do lots of useful things with filters, and Unix commands illustrate this - just have a look at some shell scripts and count the number of pipe characters used to combine cat, grep, sed, cut...
And a simple filter fits in a single source file, whatever the language.

The difficult part in software development is to correctly analyze the problem to solve, not to code.


----------



## ralphbsz (Mar 20, 2020)

20-100-2fe said:


> The difficult part in software development is to correctly analyze the problem to solve, not to code.


You got it. The discussion which languages to use for teaching is ancient. A lot of stuff that was said in this thread is nonsense, but I don't feel like arguing with it. Because it is irrelevant.

The single biggest task in software development (or system building) is to learn how to interact with other people. How to find out what they want, what pressures are driving them, how they make decisions, how to share information. Come to agreements on what the problem is that needs to be solved, what the requirements and the resource/schedule situation is, what the risk/reward tradeoffs are. All of this has nothing to do with C versus Python. This is why I say that the two most important books about software engineering are "Mythical Man-Month" and "Peopleware".

The second biggest task in software development is to find out what needs to be done, and why. Write down the requirements, write down the schedules, write down the "speeds and feeds" (what other systems the intended product needs to interact with). Be clear about what the economic benefit is, and what factors that depends on. Without clear use cases and a clear requirements documentation, there is no point even opening an editor to work on source code.

Once we know what we are doing and why, the rest follows somewhat automatically. We need an overall design, we need a breakdown into components, we need detailed designs for the components, we need to think through testing and quality assurance, we need to write test cases. When I say "write", I don't mean in a programming language, I mean in documents. We need everyone involved to review these documents, and come to an agreement.

The remaining 20% of the task are coding. There are zillions of very smart hackers on the planet who can code. Sadly, there are very few software engineers who can design and socialize systems that actually accomplish what needs to be done, efficiently and trouble-free. Learning how to code (whether it is C, Python, or Snobol) is the least of the worries.


----------



## PMc (Mar 20, 2020)

ralphbsz said:


> The single biggest task in software development (or system building) is to learn how to interact with other people. How to find out what they want, what pressures are driving them, how they make decisions, how to share information. Come to agreements on what the problem is that needs to be solved, what the requirements and the resource/schedule situation is, what the risk/reward tradeoffs are. All of this has nothing to do with C versus Python. This is why I say that the two most important books about software engineering are "Mythical Man-Month" and "Peopleware".



Well, sorry, I disagree. This is not about programming, this is about making money.

Programming is a craft. It is the craft to make a computer do some things in a way that it does not break apart and that we can rely on it during the manned Jupiter mission. Just like the blacksmith's metal-work is the craft to make horse-shoes in a way that they do not break apart.

"Speeds and feeds and schedules" are something different, and independent from the former. This is called project management, and a project manager is not expected to have any coding skills. He is not even expected to know what a computer is. He is only expected to ascertain the money-making.

When we talk about programming, we talk about empowerment. Today we are surrounded by gadgets, and to most people these gadgets are "magical", meaning, they have no idea how these work. But these gadgets tend to make decisions, and so people are subdued to foreign decisions where they do not understand how these come to pass. That way, people are mentally trained to become slaves.

Learning to program is the way out of the trap. It is the way to understand how these "magical" things are achieved, and thru understanding to regain empowerment. This is not about getting a job and blablabla, this is about being even able to develop self-confidence (in contrast to the shallow illusion of a big ego).

When we stop to distinguish that properly, and when we start to say that the actuall skill of the programmer is not the craft but the businesscrap, then we are right here where we are, where we can no longer fly to the moon (or build an airport, or handle a flu): in guaranteed zeroskill land.


----------



## 20-100-2fe (Mar 20, 2020)

Of course, a developer needs technical expertise to do his/her job.

But human factors are always the root cause of project failures - or failure to deliver on time, on budget. The most common are:

- Inflated ego / manipulation
- Political maneuvers / hatred / rivalry
- Poor communication skills

In a large company, it usually start with an airy-fairy vision of some manager with no field experience (and not willing to have any), then architects make technical choices on the basis of the vendor's fame (when the project will appear bound to fail, the architect will say: "I have chosen the leader, it's not my fault, it's the developers'.").

And at the bottom of the hierarchy, developers are supposed to deliver working software...

You get it: instead of learning to code, they'd better pass a PhD in Advanced Wizardry!

And of course, it doesn't stop here. Developers are usually reluctant to meet end users (when they're allowed to do so, which is seldom the case) and communicate with other departments by email, CCing half of the company. They also tend to be somewhat haughty with production engineers, which doesn't really help...

And when some piece of software is eventually delivered, late and well over budget, end users complain that it not only doesn't help, but complicates their job, causing frictions with customers.

When they are lucky, they just don't use it and the application is discretely uninstalled 6 months or a year later.


----------



## mark_j (Mar 21, 2020)

Jeez louise, people, please stop confusing poor beastie7 talking about projects and personal inter-communications. He hasn't even decided on a language yet. 

For crying out loud, all he wants is an insight into what's a better language to focus on... 

But seriously:

It's really not a decision you have a choice in. If you want to write device drivers or any code remotely to do with the kernel then it's C. Period.

In a proper structured course or book on C, it will begin by going through the keywords, assignment, functions, tests, then arrays (stack based), "strings", I/O,  data types etc. Only after a thorough understanding of program flow and C basics should it begin hitting you with heap based stuff (like free/malloc) and, what most people dread most about C,* * pointers *.*

Any book that starts with a discussion on double indirection and dynamic structure creation is most assuredly too advanced.

I will not beat around the bush here, you have a VAST amount of learning to do. If you were conversant with another language and had written code in it,  I would suggest converting that code into C as a way of learning (if possible).
As you don't then I would suggest you get yourself into an introductory course at a local university or whatever aptly named tertiary institution exists in your area.

Failing that, take a look at a first year university course on C and see what text books they use and buy them. Most of these have exercises and tests at the end of each chapter to test your knowledge.

Don't take this the wrong way, but because you're a complete n00b    you should aim to do some introductory course to find out if both programming and programming in C is for you.

I tutored C back in the day and saw quite a few smart kids give up and change university course streams because they couldn't take to programming.


----------



## 20-100-2fe (Mar 21, 2020)

mark_j said:


> what most people dread most about C,* * pointers *.*



Pointers are not so dreadful. I teach Java (among other topics) and found it quite helpful to my students to draw the memory layout of objects, and to explain how a program is compiled. With a couple of drawings on a whiteboard, a whole lot of notions become obvious to explain and to understand.

I also found out that people with no prior development experience have less trouble learning an object-oriented language than former mainframe developers.

I live in Luxembourg, a heavily multilingual country where children learn 3 languages at school. Some of them coming from another country speak a fourth language at home and they'll learn one more in high school. If you don't tell them it's difficult, they will just learn those 3/4/5 languages quite easily and naturally.


----------



## tommiie (Mar 21, 2020)

I am currently reading Head first C. It is more modern than K&R's C book, is light reading and provides an introduction to Valgrind, Makefiles, etc.


----------



## shkhln (Mar 21, 2020)

pyret said:


> One of the fundamental reasons for choosing Scheme is the lack of syntax.



The number and placement of parentheses in those "no-syntax" constructs are actually quite difficult to remember.



pyret said:


> But try coding that in Java and explain, why do I need to do
> 
> ```
> import java.io.*;
> ...



You need some kind of module system and therefore imports in every language. Unless you arguing for global visibility for everything, of course.


----------



## tommiie (Mar 21, 2020)

pyret said:


> The authors have spent fifteen years developing HtDP





pyret said:


> One of the fundamental reasons for choosing Scheme is the lack of syntax.





pyret said:


> When in Racket a student could type


Are you now recommending HtDP, Scheme, or Racket?



Beastie7 said:


> So I've been contemplating the idea of learning to code to help out with the project and address some aspects of it I feel are lacking.


Keep in mind the goal of OP: helping out with the FreeBSD project. Learning some obscure language no one uses, will not help achieve that goal.

To OP: You can start with either Python or C. Learning Python is easyer and I believe you will be able to write working programs faster. If you want to write some small tools/scripts, Python is the way to go. If you want to tinker with existing code, it depends on the code you want to tinker with. Start with Python, write small scripts and when they turn out to be too slow, you can learn C and rewrite them.


----------



## PMc (Mar 22, 2020)

I don't think the theoretical approach is very helpful.

Once, when I came upon a bunch of obvious bugs, I dared to ask why that particular piece of software hadn't been theoretically verified (it was the time when developers weren't yet in the ivory tower). The reaction was disgust: how could one be so aloof in theoretical computing?
In fact the opposite is true: I'm 100% from practice. And in practice, you should take 20% of the time to make the damned thing work, and the other 80% to find all the cases where it will _not_ work properly. And I don't care how this is done, only that it is done.

In the end, there will be some people who just want to code a cool game. And there will be other people who will recognize that these 80% have to be done. And no theoretical education will change that. I think, what would change it, is, when the people's very lifes would depend on that software working (that's the idea behind the Jupiter mission).


----------



## 20-100-2fe (Mar 22, 2020)

PMc said:


> I don't think the theoretical approach is very helpful.



Theory helps a lot. When you want to go somewhere, you need a map. Theory is that map.

The problem with academic stuff is that the people who provide it don't have to use it in production.

The best way to train developers is to use real-world languages and tools, provide theory so they have the map, and expose them to real-world problems so they understand theory through practice and grow their problem solving skills and self-confidence. And at the end of the training, trainees will leave with a real-world application they have built themselves.

My customers return, so I guess they liked that way of doing.


----------



## tommiie (Mar 22, 2020)

I will study theory when I need it. I'm currently writing a piece of software in C and I need to sort a doubly linked list. First I will try to come up with my own algorithm. If it works, great, I can optimize it later should I have the time, the interest, or discover my program is too slow.

Spending days or weeks studying a dozen different sorting algorithms only succeeds is scarying everyone away from programming. Start with practical challenges, the theory will come later.


----------



## 20-100-2fe (Mar 22, 2020)

Developers in 2020 have way much more to learn than in 1988, when I started. This means trainers have to divide the learning path in small, as independent as possible sections.

Because the OP is his own trainer, I'd recommend he:

- Learns C, because what motivates him is to write device drivers.
- Starts with simple programs that have nothing to do with drivers, just to practice and understand.
- Has a look at the source code for existing, simple device drivers: /dev/null and /dev/zero, for instance.
- Reads Kong's book
- Chooses one of his own needs as a first project.
- Looks at what others have already done in this field and find out why it doesn't work (or apply) in his case.
- Imagines solutions and experiment with them.

Be aware that many device drivers need a good understanding of the digital circuitry they interact with.
Depending on your prior background, this may on may not be a problem.
However, problems are also occasions for further learning and, depending on your personality, this may or may not be exciting. 

Even if you don't finally come up with a viable device driver, you'll have learned quite a lot of interesting things and, even more important, you'll have learned about yourself - what you like and don't like in this new field, and what kind of exciting uses you'll be able to find to your new knowledge and skills.


----------



## 20-100-2fe (Mar 22, 2020)

tommiie said:


> Spending days or weeks studying a dozen different sorting algorithms only succeeds is scarying everyone away from programming.



But you don't need to do that!

You only need a coarse-grained map of the Land of Software Development so you always know where you are and are able to decide appropriately where you want or need to go next, and are able to get there quick and safe.

Finer-grained theory is only needed in very specific cases.


----------



## tommiie (Mar 22, 2020)

I couldn't agree more, 20-100-2fe. Your recommendation is exactly how I would start too.



20-100-2fe said:


> Reads Kong's book


Do you mean K.N. King's book _C Programming: A modern approach_? I started reading this book but there are two big downsides:

It's not "modern" anymore, e.g. it does not cover `intn_t` and `uintn_t`, though they are (I believe) widely used nowadays.
Even second-hand the book costs a fortune ($100 USD) on Amazon. On the German Amazon the book is about $50 USD so depending where you live the book just may be too expensive. And I prefer studying from a real book rather than a PDF (which I could not find either).


----------



## 20-100-2fe (Mar 22, 2020)

tommiie said:


> Do you mean K.N. King's book _C Programming: A modern approach_?



No, for the OP, I was thinking of FreeBSD Device Drivers, by Joseph Kong





						FreeBSD Device Drivers
					

FreeBSD Device Drivers is the first and only book to teach readers how to develop device drivers for the FreeBSD operating system.




					nostarch.com


----------



## 20-100-2fe (Mar 22, 2020)

20-100-2fe said:


> You only need a coarse-grained map of the Land of Software Development so you always know where you are and are able to decide appropriately where you want or need to go next, and are able to get there quick and safe.



Every developer instinctively builds his own over time.
In fact, everyone instinctively does this in every field of life, it is a natural way of making sense out of complexity.
A good idea for a newcomer in the development field is to deliberately build his to support his learning.
You can use mind mapping for this, at least at the beginning.
You place the first thing you learn in a bubble in the middle of a sheet of paper, then you draw lines to other bubbles as the need to dig other related subjects arises.
You can also weigh each subject's relative importance - in your context - so as to organize/prioritize your learning.


----------



## tommiie (Mar 22, 2020)

Do you also have a recommendation for learning the basics of C? I started with K. N. King's book and I'm now reading _Head first C_ but other good resources are always welcome.


----------



## 20-100-2fe (Mar 22, 2020)

tommiie said:


> Do you also have a recommendation for learning the basics of C? I started with K. N. King's book and I'm now reading _Head first C_ but other good resources are always welcome.



There are several conceptually distinct areas in learning C:

- The language in itself (I mean: reserved words, syntax, data types, expressions, control structures) is simple
- The division between interface (.h files) and implementation (.c files), and C pre-processor macros
- The standard C library
- How to build a program, starting with a single hello.c (immediate, working result), then extending to a 2 .c + 1 .h project, which is enough to learn about compiling and link editing
- How to structure larger projects (make and makefiles)
- What are static libraries and shared objects, and how to build them

This list is the beginning of your own map of the Land of Software Development. It consists in the 'core learning', you'll add much more to it depending on:

- The functional area in which you want to use C (e.g. systems programming, GUI development), 
- The design of your application  (e.g. software architecture, technical architecture), 
- The interactions of your application with the rest of the information system (e.g. connectivity and interfacing, deployment, operations)
- And the context of your work (e.g. open source project, agile team).

I'd say any book will do as long as it suits your taste, and no single book has to cover all aspects.
Besides books, you can also learn from open source projects, both as a source of inspiration and as a starting point for experimentation.

The standard C library is documented in man pages and you have the header files on your system, so all you need on your desk is a 'cheat sheet' with all available functions grouped by theme.

For the rest, you're already aware of the importance of practice, so it shouldn't be a problem. What is really difficult when you start learning something is to figure out what you need to learn: you don't know what you don't know before you learn it... Hence the list at the beginning of this post.

You may also need to learn later about the GNU tools collection, used in a great many open source projects, and about CMake and meson, also widely used.


----------



## PMc (Mar 22, 2020)

20-100-2fe said:


> Theory helps a lot. When you want to go somewhere, you need a map. Theory is that map.



This is horrible. It brings up pictures of Zombies helplessly trying to follow the paths they used to tread in their lifes.

In the instance: if I want to go somewhere, I need the coordinates of position and target, then I can use my own brains to see how to overcome obstacles. Much more fun that way. (But I noticed that the cherry trees in our vicinity are no longer plucked from. That is because they are not recorded in Google maps, so people do not notice them anymore.)

In software: the language is fully defined; there is not even something unknown that would need a map or such. (If you need a good algorithm for something, well, just look out for one, understand it and use it. Don't need "theory" for that.)
When I go into the FreeBSD code, I never experience that I would suffer a lack of theory to understand it. But what I almost always experience is that there is a huge lot of conventions (like how a device driver or a kernel module is connected into the whole), and one needs to understand these to do something. One would indeed need a kind of map to understand them, but these are project (=FreeBSD) specific things, so "theory" will not help much.



> The problem with academic stuff is that the people who provide it don't have to use it in production.



Well, then we might just have a naming discrepancy. The stuff that you can use in production - I don't call that "theory", I call it best practice. There I agree, the research, study and understanding of best practices is most important. (And in contrast to theory -which is considered abstract and mostly static- the best practices can be continuously improved.)

Over all, we have far too many people strolling around and only trying to follow maps (of doubtful quality): when I go to the doctor due to some ailment, he doesn't treat me anymore. Instead, he looks up my symptoms in some database to find the diagnosis, then he looks up the diagnosis in some other databse to find the "allowed" treatments for it. I could do that myself (or let a robot do it), don't need a doctor for that. (Obviousely, those databases are created in the interest of the healthcare business in order to maximise revenue.)  Damn, we have a real problem. 

Stop believing in maps. Stop believing at all. Think for Yourself.

Addendum: the practical things You describe afterwards (mind maps, structured learning, etc.), I completely agree with these.


----------



## hruodr (Mar 22, 2020)

I think K&R is the right book for a beginner: it is not (only) about C, but about programming (in C). And concise.


----------



## tommiie (Mar 22, 2020)

hruodr said:


> I think K&R is the right book for a beginner: it is not (only) about C, but about programming (in C). And concise.


I disagree as it teaches the old syntax. C has evolved since then and you should learn from a more modern book.


----------



## hruodr (Mar 22, 2020)

It teaches good programming, and C in a syntax that is till now standard. Stop spreading confusion!


----------



## 20-100-2fe (Mar 22, 2020)

PMc said:


> Well, then we might just have a naming discrepancy.



Likely. From what you explain in your post, I think we're talking about different aspects of coding and learning to code, and with different words. This happens all the time in online conversations, and just a little bit less in real-life conversations - including discussions occuring in the course of any IT project.


----------



## hruodr (Mar 23, 2020)

20-100-2fe said:


> I think we're talking about different aspects of coding and learning to code, and with different words.



I think coding and learning to code is one thing, to find the right algorithm that one will code other.

People can be very eloquent and speak best English, but unable to speak other think than nonsense.

Even when programming trivialities like a program for parsing something one notes how theory helps, a lot.


----------



## hruodr (Mar 23, 2020)

20-100-2fe said:


> I also found out that people with no prior development experience have less trouble learning an object-oriented language than former mainframe developers.



I had big problems to understand what object oriented programming is and for what it is good, I found it abstract inflation that makes programming stranger to the machine and less efficient.

At the end, reading about TclOO and javascript, I understood that it has a sense for encapsulating and for avoiding to deal with pointers, for making big programs better readable and easier to deal to many developers, but in spite of it I never wrote an object oriented program and perhaps I will never do it.

I learned programming with the pseudo machine language of an old pocket calculator, I always think about "goto" even if all are hidden in "while" statements. I think it is an error to begin with something else than the algorithmic paradigm, to begin with object oriented, functional or declarative paradigm. One must get first a feeling of how the CPU works. With other ways you are not teaching programming, but bloating.


----------



## tommiie (Mar 23, 2020)

hruodr said:


> It teaches good programming, and C in a syntax that is till now standard. Stop spreading confusion!


I'm not spreading confusion. C has evolved since the K&R book so there are better resources to learn C from.


----------



## zirias@ (Mar 23, 2020)

I learned that the second edition of the K&R book uses the first ANSI standard, so it isn't all that bad. Original K&R syntax would be completely unacceptable nowadays.
Still, C89 is not "till now standard", it was replaced by C99, C11, C18. I would consider C11 sufficiently up to date, as C18 are only some error corrections.


----------



## hruodr (Mar 23, 2020)

tommiie said:


> I'm not spreading confusion. C has evolved since the K&R book so there are better resources to learn C from.



You are definitively spreading confusion. The minimal changes after C89 that could introduce few insignificant and easy avoidable incompatibilities or the few new features added do not make K&R worse for learning, even not a little worse, they are insignificant for judging if the book is good, better, worse or bad.


----------



## tommiie (Mar 23, 2020)

I never said the book was bad. I just believe there are better books to learn from nowadays.


----------



## shkhln (Mar 23, 2020)

hruodr said:


> I learned programming with the pseudo machine language of an old pocket calculator, I always think about "goto" even if all are hidden in "while" statements.



Dijkstra would like to have a word with you.


Spoiler



"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."


----------



## kpedersen (Mar 23, 2020)

hruodr said:


> I learned programming with the pseudo machine language of an old pocket calculator, I always think about "goto" even if all are hidden in "while" statements.



For C, I am not entirely against goto's for memory management (kind of like poor mans RAII). The following code gives good examples of gotos in practice.

https://github.com/openbsd/src/blob/master/sys/dev/ata/wd.c

What I really don't like is a bunch of checks that repeat the same cleanup code and early exit. It is so easy to miss one when maintaining / expanding the code a few years later.

Gotos are not nearly as confusing as success / fail callbacks that Javascript developers seem to think constitutes "asynchronous code".


----------



## 20-100-2fe (Mar 23, 2020)

hruodr said:


> I had big problems to understand what object oriented programming is and for what it is good



Too bad you haven't found a good explanation.

Basically, software development is a translation activity: you have to understand what your users want to do and translate it into a language a computer can understand, using concepts it can understand too.

This is absolutely not trivial and the purpose of object-oriented languages is to offer developers a computer language that eases this process by raising the conceptual level that can be used in the translation process.

Object-oriented programming is intended for complex domains (i.e. in which many objects interact) and is particularly appropriate for software used by humans.



hruodr said:


> I never wrote an object oriented program and perhaps I will never do it.



Depending on your functional domain, you may never need to, for it wouldn't bring you significant benefits.
If you write device drivers, for instance, you don't need OOP.



hruodr said:


> One must get first a feeling of how the CPU works. With other ways you are not teaching programming, but bloating.



If you write device drivers or embedded software, you need that knowledge. You also need a very strong background in electronics. In such situations, using anything else than assembly language, C or ADA is not helpful because it creates too much distance between the concepts of the programming language and those of the problem domain.

Technology is like a medicine: when using one, you must weigh its benefits and risks, just like with a chemical drug. Depending on the problem domain (= the disease + patient combination), you will choose different technologies (= medicines). There is no "one size fits all".


----------



## hruodr (Mar 23, 2020)

shkhln said:


> Dijkstra would like to have a word with you.



That was about the discussion structured vs. goto programming. A product of the emerging structured paradigm at that time. Today a non sense discussion.

My point is something different: everything you program ends as a goto machine program. Some languages translate more direct than other. I think C is a good compromise between higher level language and machine language, you can more easily imagine how the compiler treats your code.


----------



## mark_j (Mar 23, 2020)

shkhln said:


> Dijkstra would like to have a word with you.
> 
> 
> Spoiler
> ...


Dijkstra is a 



Spoiler



dick


.
I work with many excellent programmers who grew up on some form of BASIC; it's generally what piqued their interest in programming.


----------

