×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Verbiage: Assembly before C.

Chacham (981) writes | more than 8 years ago

User Journal 22

Someone asked me about learning C++. I told him to start with Assembly, not to learn it for use, but to learn everything it does and then move onto C. Someone had told me to do that, and i agreed. Just truly understanding CS/DS and how control structures actually work with loop and the compare flag, or near calls, far calls, and the interrupt table, gives a true appreciation for what is actually going on.

Someone asked me about learning C++. I told him to start with Assembly, not to learn it for use, but to learn everything it does and then move onto C. Someone had told me to do that, and i agreed. Just truly understanding CS/DS and how control structures actually work with loop and the compare flag, or near calls, far calls, and the interrupt table, gives a true appreciation for what is actually going on.

What also amazes me is that C is only some tens of instructions. Everything else are just functions made from those keywords.

I still like VB though. I want to know Assembly and C possibly much more than i want to use it.

22 comments

I thought you were an idiot (0)

Anonymous Coward | more than 8 years ago | (#13168003)

... and my thoughts were confirmed when I got to the end of your post and saw that shit about VB. You don't belong on Slashdot.

Hey C r0x0rs! (1)

Com2Kid (142006) | more than 8 years ago | (#13169426)

So much nicer than OO for actually doing stuff. The API is amazingly well designed, it is obvious that a lot of thought went into making an API that flexible and expandable.

Besides, finding a reason to nest snprintfs inside of each other is just too cool. :)

Re:Hey C r0x0rs! (0)

Anonymous Coward | more than 8 years ago | (#13170959)

And you, you are almost as stupid as Chacham.

Re:Hey C r0x0rs! (1)

Com2Kid (142006) | more than 8 years ago | (#13171840)

So you don't like C, you don't like Assembly, and you don't like .Net.

If you don't like .Net I am going to assume you don't like Java, since .Net basically rips of Java anyways.

So what DO you program in? Binary? Algol?

Re:Hey C r0x0rs! (0)

Anonymous Coward | more than 8 years ago | (#13175288)

Well I never said that I disliked any of that stuff, I just said that Chacham was an idiot and that you were almost as stupid as he is.

As for my statement about you, consider these:
      Hey C r0x0rs!
      Moments of Assfuckery in OSS
      What I wouldn't give for a proper case statement in C!
      WHAT KIND OF A FUCKING IDIOT MAKE THE FUCKING C++ COMPILATIO
      Why don't people just add some syntatic sugar to C++?
      C++ won't let me conditionally declare variables
      Bored with Ada or braindead with Scheme

and much more hilarious stuff if you were not serious posts. You don't have a good history.

As for what I program in and like, well I lately it has been mostly Common Lisp or Scheme but there is nothing wrong with C or C++. Depending on the situation, there is nothing wrong with assembly- I mean Knuth's The Art of Computer Programming makes use of it. You were right that I don't care for Java, much prefer C++ over Java- templates and the STL work a lot better together than that thing that Java calls a standard library. Haven't tried .Net and hopefully never will.

Re:Hey C r0x0rs! (1)

Com2Kid (142006) | more than 8 years ago | (#13176933)

  • Hey C r0x0rs!

  •             Moments of Assfuckery in OSS
                What I wouldn't give for a proper case statement in C!
                WHAT KIND OF A FUCKING IDIOT MAKE THE FUCKING C++ COMPILATIO
                Why don't people just add some syntatic sugar to C++?
                C++ won't let me conditionally declare variables
                Bored with Ada or braindead with Scheme


You stay up 16 hours trying to get some poorly documented feature of some language you are learning without any dead tree reference guide, and see how many nice things you have to say about it!

Scheme rocks, Ada IS boring but nicely designed, and C++ is way too strict for me. :-D

Actually I guess people DID add syntactic sugar to C++, they called it Java, just it got stuck with this cruddy run-time based BS system instead of a proper compiler! (By default)

STL is nice for doing data structure stuff, and nice for taking care of types, but for actual logic, I like C or Scheme or some such. Actually Scheme rocks in numerous ways, one more reason I want to jump into Python (functional, but it seems to look better, as I said, need to go and learn it before I can make up my mind.)

Re:Hey C r0x0rs! (1)

Chacham (981) | more than 8 years ago | (#13178260)

Hey Com2Kid, pls do not repeat certain things from replies. I never saw the earlier reply. No reason to propogate the earlier potty mouth.

I do enjoy your comments though.

Re:Hey C r0x0rs! (0)

Anonymous Coward | more than 8 years ago | (#13179334)

LOL, my potty mouth? That was actually work from com2kid in the past. I enjoyed the laugh though.

Re:Hey C r0x0rs! (0)

Anonymous Coward | more than 8 years ago | (#13179772)

If you try to learn anything without real documentation then it is your fault for any mis-understanding. Just pass the buck along for your ignorance? I like to understand things before I sound off on them.

Actually I guess people DID add syntactic sugar to C++, they called it Java, just it got stuck with this cruddy run-time based BS system instead of a proper compiler! (By default)

If you read good books then you would understand that syntactic sugar causes cancer of the semicolon. Funny thing is that C++ a lot of people consider C++ to have too much syntatic sugar because of things like operator overloading- but according to people with more of a clue. Other syntatic features you desire can usually be had by some creative thinking and templates- like something very similar to C# delegates.

You obviously do not understand C++ and it seems your understanding of Java is probably lacking too but a lot of people are in line with you when it comes to Java.

As for functional programming in Python, I don't think that is why people tend to learn Python. Python is probably dropping support for map, lambda, and reduce-- the more functional functions of Python. Python closures are a little difficult since one can only re-bind global and local variables but not closed variables- so one ends up boxing data. The litmus test for a language today is probably whether or not it is perceived as being better than Java and Python gets my vote there, but so does just about everything, and Google also likes the it pretty much requiring all their coders to know it (even the Java programmers!).

Re:Hey C r0x0rs! (1)

Com2Kid (142006) | more than 8 years ago | (#13180769)

  • If you read good books then you would understand that syntactic sugar causes cancer of the semicolon.


C++'s lack of sugar leads to longer code though.

Actually getting SIMPLE things to work in C++ is a pain. For instance, when I have multiple constructors, determining which constructor gets called by default by the inherited class's constructors. (Something text books seemingly ignore, Java textbooks are so bleeming pedantic about those types of details, it becomes rather nice after awhile to have things laid out nice and clear!)

I have had situations where I called a parent class's constructor, and NOTHING HAPPENED to the variables, very irritating. Now I am certain that there is some inane little rule describing exactly when and why this happened, but it is so inconsistent to have me call something and then nothing happen!

Anyways, yah, it is half the fault of having cruddy books, but hey, some languages are so nice that they don't NEED books, they are rather obvious in of themselves! C falls into that category. :)

  • Funny thing is that C++ a lot of people consider C++ to have too much syntatic sugar because of things like operator overloading-


Operator Overloading rocks, some people can't handle it, it just requires responsibility. You can never ask "is this convenient?" but rather you must always ask "is this blatantly obvious and something that anyone reading this code would want to have happen?"

Lots of things are convenient at the moment, but stuff that is blatantly obvious (hopefully, not just one of those "obvious for the moment" style things) will be appreciated down the line when reading over the code later.

  • You obviously do not understand C++ and it seems your understanding of Java is probably lacking too but a lot of people are in line with you when it comes to Java.


My Java may be rusty, but I do know the essential basics of it: data integrity centric, keep functions short and simple, doesn't have tight coupling, and take advantage of design patterns when ever possible.

One instance, when making a game for a C++ programming class, I tried to apply "proper" OO principles to the task, namely I had a room that I wanted to light up when the player stepped into it and turn off when the player left it. I figured the PROPER way to go about this was to have a listener object on the entrance tile to the room. I had already went about and made every tile in the game an object, and each room itself was a container object, and for that matter each game tile was also a container object using an STL stack to keep track of what in-game items were on it so far (potions, gold, monsters, etc), and all object had a bool "isSolid" that determined if they could be passed through or not. Simple matter to check the value of the top most object of the stack to do hit detection and ensure the player didn't walk through walls (this was better than some students approach of doing a complete map scan each time the player moved!)

Now under Java putting in the listener objects would have been a 15 or 20 minute implementation, maybe a bit more since my OO was a bit rusty at that point as well, but in C++, mostly do to the lack of a good Action/Listener API inside of the language (not allowed to drag in outside APIs here), I was not able to complete the project as planned!

Oh and actually getting message passing working was also a pain, I wanted players to yell at snakes "Yo, I am moving there now" and the snake to yell back "No your not, I'm attacking you now!", but, while a thousand ideas pop into my head for how to implement it now (gee why does that always happen?) it was a seemingly large pain in the rear at the time.

It also doesn't help that C++ is ugly; the entire "declare the functions in a separate file outside of the class" thing is annoying, as is the multiple classes per file aspect of it.

  • Python is probably dropping support for map, lambda, and reduce-- the more functional functions of Python.


Map rocks when used properly, unfortunately my instructors in school covered in on the board and never made us actually use it! To bad, I do remember that while learning it I thought that it'd be really cool in numerous situations.

Lambda is awesome, I still am going to need another quarter of Scheme to really get used to it though, and I still cannot understand closure. (once again my Professor's attitude towards Scheme is "Google it", which is NOT a good way to learn an entire programming paradigm!)

I personally think that aspects like multiple return values are awesome.

Of course functional programming really only comes into play if you have a cultural built up around the language that discourages side effects, and I do not see that with Python so much. One aspect I really loved about learning Scheme is that it made me emphasize so much on AVOIDING side effects that I had to think about my program logic really carefully and not just waste CPU resources or RAM on pointless variable assignments and duplications. It made me keep iterating through plans on how to solve a problem until I came down to the one true solution that I should have thought up of from the very beginning. As with any other skill, with more practice I get better and better at it, until (at least the idea is in theory) I am able to come up with that One True Solution(tm, patent pending) in a very short amount of time.

On the flip side, this also leads to C code that has function calls nested five layers deep, and since I am so used to thinking in terms of Side Effects now (if just for the sake of avoiding them!) I am horrifically abusing those as well.

Two words: Nested snprintf's[1]. :-D

(Yes, you can do it! And yes, it working is definitely compiler dependent!)

Actually that particular code was way to machine dependent so I ended up dropping it from my project, I believe it is archived somewheres in my /. journal though. :)

Re:Hey C r0x0rs! (0)

Anonymous Coward | more than 8 years ago | (#13181801)

C++'s lack of sugar leads to longer code though.

You are missing the point, oh well. The worst parts of C++'s syntax is usually from its compatibility with C. The C++ syntax is probably more malleable than what you think but it can involve templates and a lot of creativity.

I have had situations where I called a parent class's constructor, and NOTHING HAPPENED to the variables, very irritating. Now I am certain that there is some inane little rule describing exactly when and why this happened, but it is so inconsistent to have me call something and then nothing happen!

I much suspect you are calling the constructor in the wrong place. To initialize variables in a constructor you do it before the body of the constructor. Don't get me wrong, variables can be set/re-assigned in the body of a constructor but that is different from initializing them. Constructor calls go in that initialization part before the body.

Here is an example:
class class1{
...
};
 
class class2:class1{
public:
  class2(...): class1(...) {} //right way
  class2(...) {class1(...);} //wrong way does not "stick"
...
};
Here the point the main point I have been trying to get at with you, you just come off as an ignorant loud-mouth. You don't know/understand what you are talking about and sound too willing to place blame than to learn. Yes, C++ is hard and complex but it does not make it bad. I think it is a lot better to just say "I don't know/understand this" than to run one's mouth.

Funny thing is that C++ a lot of people consider C++ to have too much syntatic sugar because of things like operator overloading-

http://www.paulgraham.com/ilc03.html [slashdot.org]">This might be interesting. Heck, I would suggest that whole site, www.paulgraham.com. There is a really good Common Lisp book available there named On Lisp which is probably too advanced for you right now (it seems you don't know Common Lisp for starters :) and a lots of great essays.

It also doesn't help that C++ is ugly; the entire "declare the functions in a separate file outside of the class" thing is annoying, as is the multiple classes per file aspect of it.

You can declare class functions within the class declaration- it might not be the right stylistic thing to do but it is 100% legal. Of course, the most common place to find a class declaration is in a header file and is not "right" to do so there unless it is either a templated function or templated class- goes back to C there.

Lambda is awesome, I still am going to need another quarter of Scheme to really get used to it though, and I still cannot understand closure. (once again my Professor's attitude towards Scheme is "Google it", which is NOT a good way to learn an entire programming paradigm!)

The great thing about closures are you can use them without really understanding what they are. Here is a quick and dirty example of closures:
(define (make-fn)
  (let ((n 0))
    (lambda ()
      (let ((old-n n))
    (set! n (+ n 1))
    old-n))))
 
(define fn1 (make-fn))
(define fn2 (make-fn))
 
(fn1) ;;return 0
(fn1) ;;return 1
(fn2) ;;return 0
(fn1) ;;return 2
(fn2) ;;return 1
Functions fn1 and fn2 are two distinct, meaning different, objects and both objects use a closure to have state. Both functions close over an instance of n- two different n's of course.

A really super Scheme book is Structure and Intepretation of Computer Programs which is also available online for free. You will understand closures and how Scheme works if you read that book.

Re:Hey C r0x0rs! (1)

Com2Kid (142006) | more than 8 years ago | (#13186038)

  • class2(...): class1(...) {} //right way

  •     class2(...) {class1(...);} //wrong way does not "stick"


That first way is valid? Weird. I have never seen that before.

  • You don't know/understand what you are talking about and sound too willing to place blame than to learn.


I am not saying that I do not have a lot to learn, I am just saying that it is irritating that C++ is not more apparent / obvious TO learn. I can read though .NET, C, or Python code and it makes sense what is going on.

Scheme code, as long as I know the theory behind the usage of any complex operations being done, also makes sense as to what is going on.

C++, you can understand the theory, but the language itself is not as transparent in terms of "Oh yah that operation there just makes sense." A lot of things seemed to have been defined arbitrarily.

Its like a Unix program that decides to drop its config files in /usr/lib/ Sure once you FIND them they may make sense, but darnit, finding them is a pain!

Re:Hey C r0x0rs! (0)

Anonymous Coward | more than 8 years ago | (#13186521)

That first way is valid? Weird. I have never seen that before.

Now you know how to call parent constructors!

I am not saying that I do not have a lot to learn, I am just saying that it is irritating that C++ is not more apparent / obvious TO learn.

I never said it was true but just probably how others perceive your comments.

C++, you can understand the theory, but the language itself is not as transparent in terms of "Oh yah that operation there just makes sense." A lot of things seemed to have been defined arbitrarily.

Well nothing in C++ was defined arbitrarily, C++ is probably one of the most deliberated standard languages ever. Yes, somethings might seem a little funky or not quite right but it really is due to its first goal of supporting the C syntax/semantics.

Re:Hey C r0x0rs! (1)

Com2Kid (142006) | more than 8 years ago | (#13187249)

but it really is due to its first goal of supporting the C syntax/semantics.


*note I really must remember to use blockquote now that /. has fixed its ul tags*

But C's semantics are so obvious and easy to get used to. Programming in C I feel so empowered, programming in C++ I feel like "Great, what is the compiler going to complain about next?"

I believe that the compiler should be my friend, and the C++ compiler is NOT my friend!

Scheme's compiler is my friend, it handles all of the boring crud that is blatantly obvious and can be done away with, C's compiler is my friend, it lays off me and lets me do my own thang, the Java compiler is my friend (gee this is starting to sound really lame), when I do something wrong it tells me what I did wrong, C++'s compiler is just annoying. It is picky, demanding, and inflexible.

The constructors thing, why shouldn't the way I was doing it work? Why do I have to use some funky special syntax that has minimal relationship to anything else at all in the language, when calling the parent constructor first thing in the child constructors seems like the obvious solution to take? The parent constructor sets the variables, I am viewing it like a giant fancy setter for things I cannot get access to directly (or for that matter that I just want set to a valid state), so why not have it work?

It also makes sense from a code readability standpoint, you have your constructor looking something like this:

{ // Initialize variables in parent class // Initialize variables in this class // Do other maintenance tasks

}

Rather than

: // Initialize variables in parent class
{ // Initialize variables in this class // Do other maintenance tasks
}

If I was programming in C and I had some structure I wanted initialized, I would call an initialize structure function first, and then proceed with the rest of my code.

Re:Hey C r0x0rs! (0)

Anonymous Coward | more than 8 years ago | (#13188841)

As for the compiler stuff, I find the C++ compiler very informative and useful- but it seems I know C++ better. Personally, I find the Java compiler annoying because it is always complaining about code that *might* be unsafe but it is not really sure and decides to stop compiling.

As for the constructor stuff, it goes back to C semantics. A constructor is just a fancy function that returns an object. You are asking for constructors to have a different meaning when you call them within other constructors- bad.

If I was programming in C and I had some structure I wanted initialized, I would call an initialize structure function first, and then proceed with the rest of my code.

You can do this with C++ classes also but it would require liberal use of typename and/or typedef and operator overloading.

Re:Hey C r0x0rs! (1)

Com2Kid (142006) | more than 8 years ago | (#13189491)

  • A constructor is just a fancy function that returns an object.


I never bothered to think of it as returning an object before, just initializing the variables. I thought that new or malloc are the functions that actually return the pointer to a chunk of memory that has been arranged for my object?

Re:Hey C r0x0rs! (0)

Anonymous Coward | more than 8 years ago | (#13190057)

Well a constructor is essentially a fancy function that returns an object.

Consider the following:
vector<int> v=vector<int>(0);
or maybe a more convincing example:
vector<int> v(0);
for (int i=0; i<00; i++)
  v.push_back(i);
 
v=vector<int>(0);
cout<<v.siz e()<<"\n"; //print 0!
I think you are missing what new or malloc really does- which is return a pointer from the heap. You can use constructors on the stack.

Re:Hey C r0x0rs! (1)

Com2Kid (142006) | more than 8 years ago | (#13190634)

Actually I just keep forgetting that C++ Objects can be stored on the stack at all! I still keep popping into the Java frame of mind that all objects have to be NEWed. (One thing Java instructors pound into your head, and Java was my first language).

Though IIRC Ada95 (Pascal derived) has the same rule, but I may be mistaken, especially since I couldn't stand using objects in that language at all. (Although after I learned C I finally understood Ada95!)

Actually learning C and CPU architecture makes a lot of things make sense, (or at least allows for me to understand a lot of things when explained to me!) Chacham has a point. :)

Thank you for the rather enlightening discussion.

things to know (1)

huckda (398277) | more than 8 years ago | (#13177923)

LISP from an academic point of view to make you a better programmer...

Assembly for the same reason...

C...to code on any platform

VB...to code for windows platform only

Ruby/Python/Perl...

for script'n like a hoochie mama on the server
might throw in Tk or the like if you are into GUI stuff..

then there are things I know... (1)

huckda (398277) | more than 8 years ago | (#13177962)

C..enough to crash machines
Assembly (forgot it ALL after the final exam)
ruby, enough to make cutesy things...
python enough to mangle text files
perl scares the crap outta me
tk.enough to make some cute gui with ruby

lisp..I tried to wrangle...failed miserably
(can I blame it on my parents? both technologically challenged.)

Re:things to know (0)

Anonymous Coward | more than 8 years ago | (#13179966)

Well I would probably argue either for Scheme or Python initially.

The problem with Scheme, really any Lisp with the predominate parenthesis syntax, is that its syntax is off-putting and alien at first. With a little experience though the parenthesis pretty much disappear and no other language really feels "right." The sooner one is exposed to the "right" thing the less likely they are to resist it:) MIT uses Scheme in their introductory classes.

Python might seem off-putting at first because of its block-indentation style but it might also be its best strength for a beginner. If you are having a problem with the indentations then use a real editor and not notepad. Python forces the programmer to write in a structured way which is great because it is not matter a of style but a matter of right and wrong.

Whatever you do, just do not start out with an assembly language. It is more important that a person learns how to think like a programmer. It would be so off-putting to start with assembly.
Check for New Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Sign up for Slashdot Newsletters
Create a Slashdot Account

Loading...