OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 8:48 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: C doesn't seem so great anymore
PostPosted: Sat Dec 28, 2013 9:17 pm 
Offline
Member
Member
User avatar

Joined: Sat Oct 15, 2011 6:52 pm
Posts: 29
Location: Land of Bald Eegels
Anyone else wanting to just work in pure assembly because you'd rather always have the control and nothing seems problematic about programming large software with it? Not only am I finding it somehow more comfortable, but it almost seems essential. I no longer appreciate C's "memory model" or whatever it may be called. It's starting to seem like there really was no need to introduce programming languages like C anyway..

Is this a normal thought? Apparently not :|

Hah. I'm not writing this to sound like "someone's a badass" but I'm just starting to genuinely wonder why programming in ASM is viewed as so bad and unproductive. Any thoughts?


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Sat Dec 28, 2013 11:08 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 15, 2008 2:37 pm
Posts: 815
Location: The Fire Nation
I remember my assembler only phase.

I then realized that C is a faster way of getting my thoughts out, without spending all of my time on the language (Which is like solving a math problem, and explaining every step in large detail, which after a while is just time consuming when you get into even larger problems). In my real mode OS projects, it was much more fun writing the core in Assembler as it just felt more challenging and exciting.

Its good for everyone to have swam in assembler for awhile, and have been grateful of the control. Eventually you'll want something that can output your ideas much faster with somewhat similar (if not, equal) complexity.


Let your phase ride out. You'll learn a lot, and come back a lot better mentally to C.


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Sun Dec 29, 2013 1:34 am 
Offline
Member
Member

Joined: Wed Mar 09, 2011 3:55 am
Posts: 509
Oranos wrote:
Hah. I'm not writing this to sound like "someone's a badass" but I'm just starting to genuinely wonder why programming in ASM is viewed as so bad and unproductive. Any thoughts?


One reason is that assembly is very unportable. Any assembly code in a program has to be completely rewritten when it's ported to a different hardware architecture, and differences in calling conventions and such may well mean that an application program written in assembly has to be fairly heavily rewritten when ported to a different OS, even if the set of function calls it makes is exactly the same.


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Sun Dec 29, 2013 1:37 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 15, 2011 6:52 pm
Posts: 29
Location: Land of Bald Eegels
@Voltek
Excellent answer. :o

I sorta anticipate that anyway; however, I also believe maybe with enough practice I'll mostly be able to capture my ideas even in assembler alone. I know exactly what you mean though. I had a similar experience when shifting down to using C, but now I find it absurd to use anything more than C. Actually, I was working with C++ and decided I wasn't happy with my style. Coincidentally, it reduced to C++ "without ++" (C99) over several years as I gradually dropped concepts such as its crazy template system, polymorphism, operator overloading and even class methods.

I feel like I made a perfect decision and I'm completely satisfied with how I've relearned how to program. If you really know how to grapple representation, most, if not all "high-level" features become inane.

@linguofreak
Definitely. I guess I've neglected that factor because I'm not too mindful about portability at the moment. I only have one machine to play on.


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Sun Dec 29, 2013 2:59 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Your remarks about "memory models" in C, and the failure to grasp that you use them just as surely in assembler as you do in C, would seem to me to indicate an incomplete appreciation of what is involved in programming a complicated operating system. Although it proves nothing, have you considered why almost every operating system since the original Unix implementation is written in a higher level language than assembler (often C)? Are all those experienced programmers and designers wrong where you are right?

They say that a little learning is a dangerous thing. I'd say that your OP is a good demonstration of that. I don't believe that you have enough experience of programming a reasonably complex system to appreciate the advantages gained from using a higher level of abstraction than assembler. The same seems to be true about the advantages of C++ over C when writing complex user programs. Keep at it and, with experience and time, you will begin to appreciate the power of abstraction.


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Sun Dec 29, 2013 5:09 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 15, 2011 6:52 pm
Posts: 29
Location: Land of Bald Eegels
Yep.


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Sun Dec 29, 2013 5:16 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 26, 2009 2:48 am
Posts: 792
In assembly you still need a memory model.


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Sun Dec 29, 2013 6:54 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
Being able to write anything in assembly is useful and something worth investing into. Actually doing it, however, is not productive. If you do real projects in assembly, you'll write worse code, slower. The only real reasons to use more than a few lines of assembly are learning or because it's fun and you're not going to use the result anyway.

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Sun Dec 29, 2013 9:36 am 
Offline
Member
Member

Joined: Mon Jul 05, 2010 4:15 pm
Posts: 595
Many low level programmers have a assembler only phase and it's nothing wrong with that for small projects. By using only assembler you actually learn a lot how a computer system work to the bare metal which helps you to understand what's going on under a high level language. For larger projects like operating systems, C or C++ is usually better not to mention how much more portable to other architectures it is.

Today it isn't unusual for kernels being written in C++ but there are more modern languages available like D and there are rumors that Microsoft is going to create their own native code language http://lambda-the-ultimate.org/node/4862. I think as times progresses, we will use more high level languages even for system programming.

We'll see if there will be a new compiled language to rule them all in the future.


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Sun Dec 29, 2013 12:27 pm 
Offline
Member
Member
User avatar

Joined: Fri Jul 03, 2009 6:21 am
Posts: 359
Some of us had an assembly only phase because the only other option was BASIC. As soon as 16-bit computers became affordable for hobby programmers we all jumped ship and wrote K&R C code instead. OK, not all of us did that, some of the hobbyist games programmers moved onto 68000 assembly. In the last two years I've only written about 500 lines of assembly code.

The older you get, the more you realise that your time is a valuable non-renewable resource. It therefore needs to be used efficiently. For 99% of the time, writing it in assembly isn't going to be efficient use of your time.

_________________
Every universe of discourse has its logical structure --- S. K. Langer.


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Wed Jan 01, 2014 11:20 pm 
Offline

Joined: Mon Dec 30, 2013 11:54 pm
Posts: 12
Oranos wrote:
Hah. I'm not writing this to sound like "someone's a badass" but I'm just starting to genuinely wonder why programming in ASM is viewed as so bad and unproductive. Any thoughts?

Someone already mentioned the portability issue. But I think the reason why you're going through this "phase" (which we all go through) is that what the C compiler is doing is rather opaque. Until you can get a good handle on it, it feels easier to say "screw it" and just write the code in assembler. Eventually you are forced to understand it and get too lazy to keep typing low-level code. That's when you'll start seeking out higher level options.

I hear you on C++, though. C++ was a mistake from the beginning, but a good learning experience for the industry. Java implemented the OOP design that was desired, but the industry zietgiest is starting to realize that we were all a bit too zealous for what OOP offered. (Which really just amounts to formalizing a number of encapsulation structures that will continue to be useful in the future.) The next generation of languages is modern functional languages which take the event-based programming model already used in OSes and promote it to The Way All Things Are Done(TM).

iansjack wrote:
Although it proves nothing, have you considered why almost every operating system since the original Unix implementation is written in a higher level language than assembler?

That's right. Real Men write operating systems in ALGOL! :lol:

(Sorry to bust your chops. I just couldn't resist. :))


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Thu Jan 02, 2014 1:53 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Real men write operating systems in PL/1. Wimps use BCPL.


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Thu Jan 02, 2014 2:22 am 
Offline

Joined: Mon Dec 30, 2013 11:54 pm
Posts: 12
iansjack wrote:
Real men write operating systems in PL/1. Wimps use BCPL.

:-k [..................................................................] =D>


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Thu Jan 02, 2014 3:32 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 15, 2011 6:52 pm
Posts: 29
Location: Land of Bald Eegels
Meh.




I just thought I'd say I'll try working with some intrinsic functions and see if anything's more convenient when using a combination of assembly and C. Though, the lightweight-ness and simplicity of an assembler is pretty great too.

I really don't think my C experiments will be any more eloquent; most likely horrid and convoluted.

One more note: My best practice is to just draft informal pseudocode and work on note paper to sketch out complex/novel ideas. I don't use C to draft code in the first place.


Top
 Profile  
 
 Post subject: Re: C doesn't seem so great anymore
PostPosted: Wed Jan 22, 2014 11:56 am 
Offline
Member
Member
User avatar

Joined: Fri Dec 15, 2006 5:26 pm
Posts: 437
Location: Church Stretton Uk
I suppose C is just a lot more pleasing on the eye than the same thing written in assembly language, with all those jumps all over the place. I used to think that interrupt handlers should be in assembler, even if everything else was in C - until I wrote my keyboard handler in C, and saw how much "nicer" the C code was.

_________________
The continuous image of a connected set is connected.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 47 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group