Code process development

B

BSDAppentic3

Guest
This time I'm asking how to create, well, basically, code. I'm not mean a "hello world", I'm mean something alike the drivers, the programs, etc.
All the things that conform the system.
Just curiosity.
Edit: Sorry, my english is reasonably good, but I hadn't repaired in that the title should be "code development process". I try to write the best that I can at this moment.
 
Why don't you start with reading the source code for any of simpler FreeBSD utilities, say pwd(1) (/usr/src/bin/pwd/)? Then move forward to something bigger.
 
This time I'm asking how to create, well, basically, code. I'm not mean a "hello world",
First you need to learn to code, that means learning and understanding how to write a "hello world" application. You have to learn how to walk before you're able to run.

I'm mean something alike the drivers, the programs, etc.
All the things that conform the system.
As I said, learn to walk first. Then buy a book like The Design and Implementation of the FreeBSD Operating System.
 
SirDice
I disagree.
Some people first learn to walk, after that they can learn to run.
Some are different. Do you remember Iron Man? When Jarvis speaks to Tony Stark? Sorry, I can't remember what movie was.
But I remember what Tony said to Jarvis: "Jarvis, sometimes you have to run before you walk" or so.
I'm not learning this from the beginning. I don't want that.
That's why I study this by myself: yes, maybe there's no teacher to ask, but at least I have something that I haven't in any other place: freedom of choice.
First, I learned about this OS in a old book. Then I fought to get it in a media which I can install.
Again, I apologize if I offend you. But I have my own rhythm. My own way of understand everything.
Anyways, thank you for your interest.
I'm not meaning that I'll despise your contribution. Of course, when I have time, I'll try to learn to code. After read some book. This last is really curious, because some admin told me that the things that you read in a book can work for a few time. Sorry, I won't tell you who was told that. But as you can see, there are different point of view of the same thing.
I'm just saying that I don't want to understand this like all the people should do.
Sorry if my method isn't the appropiate. But sometimes, you know, there's no rules. Then you can do whatever you want. Then you learn how to write your own rules, since there aren't.
Thanks for your help.
 
SirDice
I heard that whatever you do, it'll be the right thing.
Maybe you learn from a book. Good for you.
Maybe you learn from another site. Fine for you.
Not all the persons have the same way of study and understand something. Or shouldn't.
That's the beauty of the diversity: we all are different.
Again, thanks for your attention and your reply. I won't despise it.
 
I'm just going by my own experiences which, mostly, didn't quite work out. I'm like you, I take things apart to see how they work. But this resulted in a hodgepodge of information without any real structure. Now I'm struggling when I need to develop something because I never learned the basics. Don't make the same mistakes I made ;)
 
I'm just going by my own experiences which, mostly, didn't quite work out. I'm like you, I take things apart to see how they work. But this resulted in a hodgepodge of information without any real structure. Now I'm struggling when I need to develop something because I never learned the basics. Don't make the same mistakes I made ;)
So, you aren't a specialist.
How did you get then to here?
I see that you figure as "staff member", "administrator", and "moderator".
 
SirDice
Sorry, I'm in a bad moment.

I have to choose between do something, or do nothing. Between learn a very quantity of things, or learn absolutely nothing.

I haven't the will and capacity that others genius have.

I only have my will and my hands.

It's easy when you know how to do it or if you can learn it easily, but if you don't, you'll really suffer.

That's why, in the deep of mine, I really hate that the people try to apparent like if they were genius, when they aren't. And the truly genius, the most of they, well... they have their own misery, so I don't want to and don't consider myself as one of they.

I really hate when someone thinks that just because can simply do something better than you, have reasons to consider you as an inferior, and idiot.
 
So, you aren't a specialist.
I'm an experienced generalist. I know about lots of things

How did you get then to here?
35 years of playing with computers (I started when I was 12) and now I have nearly 25 years experience working in IT doing all sorts of jobs.

I see that you figure as "staff member", "administrator", and "moderator".
I never asked or aspired to be one. It was offered to me and I took the opportunity.
I haven't the will and capacity that others genius have.
Neither do I, but that never stopped me. It just takes a little longer to get there.
I really hate when someone thinks that just because can simply do something better than you, have reasons to consider you as an inferior, and idiot.
Eleanor Roosevelt once said; No one can make you feel inferior without your consent.
 
Let me drop my two cents, although in the end I would probably be sorry. I apologise in advance, if I sound patronising.

I write code for more than 30 years, and even tho I started with BASIC (on Apple ][), the damage made is mostly healed by now. Having laid my cards, I tend to side with SirDice here:
  • Foundations are important. If you want to go ahead with C -- please do. Learn C and get acquainted with its standard library (per today's standards it is tiny). Then learn what POSIX APIs are. Then see how pwd(1) and ls(1) works. Then jump to Firefox, kernel drivers or whatever.
  • Bad habits are easy to make and painful to put aside.
  • Be patient.
  • Focus. Try not to jump on any new tech everyone is speaking about; most die as fast, as they arrive. I tend to be very picky nowadays with what I spent my time learning.
Good luck! I envy you :) It is like I know you'll be start reading a really good book I've just finished.
 
God...so many years...so, you must be programmers of "the old school", as I see...well, Bill Gates is not precisely the better for making an OS, despite of it, he as a lot of experience and work. He has trajectory. I consider it very respectable. Even when they make other kind of software, even when he has his own fails, even if he didn't make Windows.
Well, maybe this guy isn't the better example. But he has came to me right now.
So, what I mean, and I think you try to meaning, it's speak about experience. Obviously you both have it. In that case, you fell less the things like don't know how to do something. Even if some of the languages that you had learned today doesn't exist or is not used as in its beginnings, you have at least the logic necessary.
Thanks for your replies. I think I'll reconsider it.
 
Sorry if I speak about something that bother you, but I want to ask: I have committed a mistake starting using this OS? I mean, it is very complex for a noob, or I still can fight and learn to understand it?
I'll explain: I'm not static. Since I reinstalled the whole OS, I have one .iso file of other system, and in process of getting another. I'm jumping from one to another.
Now that I see it, I haven't specialized in an specific OS, nor a language of programming specific.
Do you recommend to me to do that?
 
So reading this thread I can only wonder what your goal actually is. First you ask for advice on how to accomplish something only to immediately dismiss it once it has been given to you. So why ask for help in the first place if you already think to know how to approach all this? I find that a bit awkward.

Is this really about asking for help or merely about discussing various topics? You may disagree with the given advice but at the same time you yourself demonstrate that those are actually true. Words are just that, it's actions which count. Heck. I taught myself Java over the past 20 years and I'm still learning new things from time to time (note: I'm not a fulltime developer).

And if there's one thing I've learned over time its that languages don't matter at all. It's not about the language, but about the practice of programming. In the end programming is basically puzzle solving. You have a goal you want to accomplish (aka a problem), then you're going to solve it. The best way to do that - in my opinion - is to break the whole thing down into smaller parts and then taking on those parts one by one.

For example... I want an option to archive ("backup") my PostgreSQL database (datafiles) on a remote server. So I type in a command on my server, it contacts the remote server and then performs the tasks. Well... What would my program need to do?
  • It needs to be able and react to a command given through a network connection.
    • In addition it would also need to verify this command.
    • This also means it would need to be run in the background as a service.
  • It needs to archive my PostgreSQL data directory.
  • Maybe (optionally) it would sent back a result of the operation.
Point 2 can be split into even more smaller parts. Because how would we do this? Just archive the directory using an archiver and hope for the best? Or maybe make a backup using existing tools such as pg_dump, or perhaps use an API of some sort and allow our software to instruct the existing environment to do the backup for us. Or maybe we'll stop or pause the server, archive the files, and then start the whole process again.

This would give you all the small bits you need. You can now focus on several things. Either check how you could access or control PostgreSQL, check how you could open a network connection, check how you could respond to an incoming network connection, check how you could run a program in the background (maybe decide if you want to rely on the OS to do this for you, or make your software initiate this).

So you start by identifying your problem. Then breaking it down and then look into solve all the small parts. And all those smaller parts would eventually make for the bigger picture: the end product.

It doesn't really matter what programming language you'd want to use either. The programming language is in the end but a mere tool, the actual goal is to solve the problem at hand.

But you definitely need to start somewhere. If that wasn't the case then why ask in the first place?

I mean.. back when I started with Java all I used was the Java tutorial, studied it and kept trying to see how the things I learned about actually worked in the real world. I took my sweet time but the result is decently enough.
 
ShelLuser
Yes. I don't know if I am ambiguous or contradictory. Or both.
But if I can stand in one position, I won't move of it. Do you know that, right? Do you know that when you stand in a position for a long time, then will be more difficult to you to move from that place?
Second: I said that I won't dismiss what they told me. I'm a little "hardheaded" (thus means that I'm stubborn). That doesn't mean that I will not consider the help that they provide to me. Of course I know I must study and learn a lot of things. Of course I know that it takes time. That's why I'll take my time. And because of it, I'll do following my own rhythm. Since I have free of choice, I decide how and when study something related with this area.
Thanks for remind me that I need to stay in a fix topic, and don't move of it. And I'll try to follow the line to continue with the topic which I wrote and decided to know. Even when it is a lineal way of think.
But, as I wrote previously: when you haven't rules, you have your owns. To prevent another misunderstood, I'll explain this: I didn't follow the topic. My bad. But even from the mistakes, one can learn. For example, I learned that this two persons have experience. Yes, I didn't learned much, but at least it's something.
Thanks for told me a little of your history.
Thanks for remind to me that I was moving away from the main topic.
Thanks for your reply.
This won't occur again.
 
I can't tell if this topic is becoming quite heated or if I am just getting confused ;)

Have a read of the K&R C Programming Language book. (https://www.amazon.co.uk/C-Programming-Language-2nd/dp/0131103628)

Not only is this book enjoyable and will give you a great intro to programming but it is also *very* UNIX-centric. For example if will show you how to use low level memory functions such as sbrk, access UNIX file descriptors, struct dirent and other UNIX-like structures in a portable manner (BSD, SYSV, etc).

After this you can even start to read some of the POSIX headers on FreeBSD and get a feel for how they work and what they do. Not quite up to the driver level yet. But after this you can start having a look at documentation such as: https://www.freebsd.org/doc/en/books/arch-handbook/index.html and start to relate some of the code that they hook into or rely upon to what you have already covered.

This whole process will probably take over a year to really achieve, but is pretty satisfying :)

Oh and at this point there is no choice of language. C and C++ are the only ones available for this kind of development. Any other language is simply unsuitable or will need to call into C/C++ code anyway.
 
Oh and at this point there is no choice of language. C and C++ are the only ones available for this kind of development. Any other language is simply unsuitable or will need to call into C/C++ code anyway.
Not true. You can implement pwd, ls, and Firefox in lots of other languages. For example, both perl and python have perfectly good C-library and system call bindings, and could do all of these things. And implementing these things in higher-level languages is considerably easier (and therefore more appropriate for beginners) in languages where you don't need to worry about malloc and free, the difference between malloc/free and new/delete, and the subtle distinction between pointers and arrays.

There is nothing wrong with reading K&R (second edition). For a professional programmer, it is actually a must-read, to understand the history of where C (and therefore C++) came from. Just like a professional physicist should have read Newton's Principia in the original (actually, in an English translation, since few people today can read latin), and a professional psychologist should read some Freud (again, in translation if they don't read German). But for a beginning programmer, K&R is not the best introduction to programming, nor the best introduction to C. Matter-of-fact, for a beginning programmer today, C is probably not the best language to learn. There is a good reason that most academic computer science and software engineering programs do teach other languages first, with common examples being java and python. Personally, I think that teaching C as a first language, and using K&R as the first programming textbook is a very bad idea, since it teaches the new programmer details that they will have to eventually master, but that just obfuscate the big picture that the novice needs.

C still has a place today. It is a necessary basis to understand C++, and the languages (such as Go, C#, Java, Swift) that have been derived from it. It is also (together with C++) still the only pair of languages used in Linux and *BSD kernels, and for historical reasons the implementation language of quite a few major pieces of software. But a professional programmer will eventually know 3 or 4 languages well, and a dozen so-so, with C and C++ only one arrow in their quiver.

It's a lot like teaching music. You don't take a 7-year old and put a copy of Scriabin etudes in front of them, and say "play this": You start them with "Mary had a little lamb" in the right hand, with simple chords in the left hand. Eventually, they'll have to learn that F-flat is the same button as E, and how to play double octaves with the melody in the middle, and super-fast broken chords with trills underneath, but they first need the basic skills to orient themselves on the keyboard and be able to get a coherent melody.

The other thing that people forget is: learning programming in and of itself is a necessary skill, but by no means sufficient. To be actually functional in the real world today, you also need to know good software engineering skills (how to analyze requirements, how to write design documents, how to write maintainable and clear code, how to structure longer programs into readable, writable and maintainable modules, how to perform code reviews, how to use source control systems, and how to function in a group of people). You also need to have at least a superficial knowledge of the tools that are out there, things like databases (SQL), parsers (lex and yacc), debugging and development tools (gdb, eclipse), and so on: nobody today can be productive, if they have to create all their tools from scratch. And given the scale of today's real software problems, good skills in object-oriented analysis and design are also vitally necessary. C++ is not only a different programming language from C, it is a completely different way of thinking about problems and structuring your program. Instead of spending 90% of the time worrying about algorithm and code details, you end up spending 2/3 of the time thinking through the data that describes the problem, and the relationships between the entities, which causes the code to become much easier to write.

Teaching just programming skills in a complex language, without the common sense of software engineering, and the thinking skills of OO A&D, creates idiot savants. Which nobody wants to hire or work with.
 
Before Unix (in ~1970), operating systems were typically written in a mixture of assembly and higher-level languages. The largest ones of those were:
  • PL/1 and PL/S (used at IBM and all plug compatibles) plus used for Multics,
  • a variety of Pascal flavors at Cyber and Cray,
  • and the CPL / BCPL / B family of languages (used at Cambridge, at MIT, in its descendant Bliss at DEC, and eventually on the Xerox Alto and the Amiga). The C language is a direct descendent of this chain;
  • finally, the use of Fortran for an operating system was a wild exception, but very amusing.
The first relational database was written in PL/S. How do I know? When the computer history museum found a mainframe backup tape that contained the source code of System R (a predecessor of Oracle and IBM DB2), they didn't know how to decode the backup, so through friends they asked me. I happened to have old source code for reading MVS and VM backups from Unix sitting around (from my old days), so I extracted the source code for them. If you know a little bit of PL/1, the code is actually pretty easy to read.

There is still a market for non-Unix systems; mainframe operating systems continue to be written today in a modern dialect of PL/1, and VMS continues to be developed in Bliss (yes, there is still VMS development going on, as we speak they're porting it from Titanium to x86-64).

People who work on Unix systems tend to think that C (and it's descendent C++) are the be-all of languages, and they are completely wrong. I think it is still true that single language with the largest installed base measured in investment in code that is still running is COBOL, because for about 40 years virtually all commercial source was written in COBOL. I also think that the language that uses most CPU cycles in the world remains Fortran, because most supercomputers run scientific codes, which tend to be written in Fortran. The largest use of software is (and has been for decades) in embedded systems. About 15 years ago I saw a study done by either the Stanford or CMU software engineering departments, which tried to measure which company was the greatest software company in terms of how many software engineers they employ, and how much software they write. Places 1 and 2 of the list were a virtual tie between GM and GE, with Boing in place 3. The only "computer" company that made the top 10 list of 15 years ago was IBM, because it creates so much application software for its commercial customers under contract. You can not imagine how much software a modern car or aircraft contains. Rumor has it that the 767 was the first airplane that was not capable of lifting a copy of its own software documentation, it contained so much software (and that was 30 years ago). In many industries, software development costs are the largest component of engineering. While a lot of embedded software development (for example the stuff that controls a dishwasher or thermostat) is done in straight C, the bulk of commercial software development is not done in C.

In the web-based industry (web serving e-commerce, business logic, Hadoop and MapReduce, all that stuff), C and C++ are small components. Most of that stuff is done in much more modern languages, with Java being the main competitor. You have to remember that a lot of that business runs on Windows (which still has a very significant market share in the server market) the dominant modern language is C#, which is more of a dialect of Java than a dialect of C.

Learning C is important, but it really is only a small fraction of the language knowledge that a professional programmer needs to know.
 
Bonus points for the CDC Cyber references. In a prior life I did tape backups on a baby Cyber 170/825. Yes, that means 6250 bpi 9 track tape ... I'll stop before getting further off topic.
 
I can only point at the oberon station for a good learning system. You have a graphical system with almost all tools running in one MB of memory. The compiler has about 4000 lines of source code. You can actually understand all parts of that system and try your hand at improving it.
 
Learning C is important, but it really is only a small fraction of the language knowledge that a professional programmer needs to know.

Normally, I would agree but for the OPs original aim (though I may have misread his text):
This time I'm asking how to create, well, basically, code. I'm not mean a "hello world", I'm mean something alike the drivers, the programs, etc.
All the things that conform the system.

You will not be able to write adequate drivers with things like Java and C#. You need a systems language. These days we are severely lacking in systems languages which do leave only C and C++ (with rust one day in the distant future if it survives). Fortran is a systems language but cannot be used to call directly into the kernel which is now mostly C. This will make it an awkward language choice (C++ has a similar issue to a much lesser extent).

Yes I agree prior to C's popularity BCPL would have been a choice but I don't think for the OP he should invest time in tracking down a modern compiler for that language!

As for *learning* to program. My answer would have been quite different ;)
 
Indeed, if you want to write kernel code and device drivers on Unix-derived systems (Linux, *BSD), you will have to use C (and to some extent C++, which can today be used in the kernel, although I only have done it in Linux and proprietary commercial Unix variants, not on *BSD).

For user-space programs, even though that directly call the kernel (using system calls, those are typically the things in section 2 of the man pages), you can use pretty much any language; most of them have bindings to system calls and the run time library.

But the OP wants to learn to program. Doing so in kernel development and device drivers is too hard. It would be like trying to learn to operate a fighter jet before practicing on a bicycle. He needs to pick an easy programming language, get a good book (or the modern equivalent of a book), and start with easier and safer userspace tasks. Once he can reliably and quickly write 100- and 500-line programs in an easy language (like python, oberon, pascal, ...), he should move on to harder languages (like C or Javascript), and once he has mastered that on medium sized projects, he could go on to drivers.
 
Okay, maybe I was a little stubborn, contradictory, ambiguous. Maybe I started with the wrong foot.
I apologize if I offended someone, because I'm not here for start discussions. I'm here for learn.
Sorry. Sometimes, the stress, mixed with my terrible humor choleric and temperamental, and some aspects of me (like be contradictory or don't have a lineal nor logical way of think)...well, it's the perfect cocktail for start an discussion with anybody. Sometimes I hurt or offend people that I don't want to. I really try to make big efforts to prevent this, despite of it, I am still being aggressive and offensive, and stubborn and hardheaded sometimes.
 
Thanks you all for your replies. I really appreciate any help that someone can give me.
I promise that I'll read all your replies, and try to understand what they're about.
Thanks for your attention and comprehension.
 
Back
Top