Page 1 of 1

Language Discussion (High Level And Low Level) [C, ASM]

Posted: Tue May 20, 2014 11:33 pm
by alexfru
metallevel wrote: In fact, if you don't know C, you probably shouldn't be writing an OS at all! Even if you were writing an OS 100% in assembly, just about every low-level programmer knows C...
I tend to disagree with these two statements. I had quite some low-level, assembly (multiple architectures) and Pascal knowledge and experience prior to learning C and I must tell that that was already enough for me to write basic device drivers, schedulers, FAT-like file systems and other common OS parts, but nevertheless I struggled with C for quite some time because, simply put, it comes with a plethora of oddities, inconsistencies, non-intuitive syntax and behavior, especially unspecified, implementation-defined, and undefined behavior. Assembly looked much more defined and intuitive than C. And it still does. At the time I also lacked good books on C and the internet wasn't as accessible and rich as it is nowadays. Only now, having used C for about 15 years and having written a simple C compiler, can I say that I get it (mostly, not 100% of it, of course, as there still are a few dark corners, but I'm aware of them). Further, before C there was no C, but there was assembly and low-level programming alright and programmers made OSes without a single line of C! :)

Re: Printing strings display smileys

Posted: Tue May 20, 2014 11:58 pm
by bwat
alexfru wrote: Further, before C there was no C, but there was assembly and low-level programming alright and programmers made OSes without a single line of C! :)
Assembly language was being seen as too low-level for the bulk of OS development about a decade before the first OS was written in C. I wrote about it in this post. The OS being written exclusively in assembly is a 1950s idea.

Re: Printing strings display smileys

Posted: Wed May 21, 2014 8:20 am
by metallevel
alexfru wrote:
metallevel wrote: In fact, if you don't know C, you probably shouldn't be writing an OS at all! Even if you were writing an OS 100% in assembly, just about every low-level programmer knows C...
I tend to disagree with these two statements. I had quite some low-level, assembly (multiple architectures) and Pascal knowledge and experience prior to learning C and I must tell that that was already enough for me to write basic device drivers, schedulers, FAT-like file systems and other common OS parts, but nevertheless I struggled with C for quite some time because, simply put, it comes with a plethora of oddities, inconsistencies, non-intuitive syntax and behavior, especially unspecified, implementation-defined, and undefined behavior. Assembly looked much more defined and intuitive than C. And it still does. At the time I also lacked good books on C and the internet wasn't as accessible and rich as it is nowadays. Only now, having used C for about 15 years and having written a simple C compiler, can I say that I get it (mostly, not 100% of it, of course, as there still are a few dark corners, but I'm aware of them). Further, before C there was no C, but there was assembly and low-level programming alright and programmers made OSes without a single line of C! :)
Sorry, perhaps I wasn't general enough with that post. What I meant was that if you're not fluent in a common lower level language, which could be C, Forth, Pascal, etc, you probably don't know much about low level programming. C was just the example I gave because it seems C is the most common of these today. Also many people today learn higher level languages before lower level ones (at least at first), so if you don't know C (or Forth, or Pascal...) well, you probably know even less about assembly. That isn't to say that your first programming language can't be assembly, and in earlier days it often was, but nowadays this is quite rare.

Re: Printing strings display smileys

Posted: Wed May 21, 2014 9:21 pm
by alexfru
bwat wrote:Assembly language was being seen as too low-level for the bulk of OS development about a decade before the first OS was written in C. I wrote about it in this post. The OS being written exclusively in assembly is a 1950s idea.
But look how far we've gotten with Windows, growing out of DOS whose "kernel" was written entirely in assembly. :)

Don't also forget that there have been and still are small/embedded systems with little memory (similar to 1950s, just a tad more) and writing the kernel (not a terribly complex or big one) in assembly may not be such a bad idea.

Not every old idea is bad. It depends on context. Looks like we're having a resurgence of old ideas from the times when LISP was born, if not earlier. New functional languages appear, older languages (e.g. C++) get more functional with new features, and this stuff finds more and more uses and users.

Re: Printing strings display smileys

Posted: Wed May 21, 2014 11:20 pm
by bwat
alexfru wrote:Not every old idea is bad.
Just want to point out that I'm not claiming the age of an idea is necessarily a indicator of its quality.

Re: Printing strings display smileys

Posted: Wed May 21, 2014 11:32 pm
by hometue
One good example will be assembly. I don't care how hard it seems like, its much easier than writing a bunch of numbers that no one understands. And I am pretty sure it can be considered quite old compared to other languages.

Language Discussion (High Level And Low Level)

Posted: Thu May 22, 2014 12:13 am
by bwat
hometue wrote:One good example will be assembly. I don't care how hard it seems like, its much easier than writing a bunch of numbers that no one understands.

But there are people who do understand. I did a lot of hand assembly yesterday for a homebrew processor; you get the hang of the machine code quite quickly. Assembly isn't really anything other than names for opcodes. I don't really see it as an idea any different from the idea of a programmable computer. As a designer, you can't create a processor without creating mnemonics for the opcodes - it's a human thing, we name things.
hometue wrote:And I am pretty sure it can be considered quite old compared to other languages.
As far as languages are concerned, people were expressing thoughts in terms of what could be considered functional programming back in the 1930s and 40s [Alonzo Church and his lambda calculus], and the foundations of the mechanics of logic programming were invented back in the 1920s [Herbrand's PhD thesis of 1929 - but it took until the 1970s before logic was given a computational interpretation].

With regards to hardware implementation, Charles Babbage used the carry select adder in his analytical engine (1834-1871) which is long before students of digital design were taught it as an improvement on the ripple carry adder.

Finally, in the introduction to The pi-calculus. A Theory of Mobile Processes by Sangiorgi and Walker, the late Robin Milner wrote:
The notion of calculational process, or algorithm, is a lot older than computing technology; so, oddly enough, a lot of computer science existed before modern computers.