Author Topic: If I wanted to learn code?  (Read 14989 times)

ROBOKiTTY

  • Boss
  • ****
  • Posts: 183
  • KiTTYRiffic
    • KiTTYLand
Re: If I wanted to learn code?
« Reply #20 on: December 26, 2013, 02:43:07 AM »
yeah, putting just the function name there is valid. The standard guarantees that it's converted to the address of the function.

The conversion problem I'm referring to is casting between data pointers and function pointers, which the standard doesn't allow because the sizes of data pointers and function pointers differ on some platforms. Occasionally though, it's necessary to do such a cast where there is no difference, hence the circuitous/union hack.
Have you played with a KiTTY today?

GuyPerfect

  • Mary Poppins
  • Titan Staff
  • Elite Boss
  • ****
  • Posts: 1,740
Re: If I wanted to learn code?
« Reply #21 on: December 26, 2013, 02:56:17 AM »
The conversion problem I'm referring to is casting between data pointers and function pointers, which the standard doesn't allow because the sizes of data pointers and function pointers differ on some platforms.

So my example of doing just that doesn't exist? (-:

I can't speak for the C spec, which uses the word "undefined" nearly as frequently as the letter E, but every pointer I've ever seen in the history of ever has been the same size as the memory bus width on the target architecture (by definition, based on how pointers are processed by machine code). And since functions and variables alike come in through the same nozzle--to the point where you can build and run program code in RAM--I'm going to have to say that it's universally the case that function pointers and data pointers are always the same size.

A bold assertion, perhaps, but I welcome a contradicting example. (-:
« Last Edit: December 26, 2013, 03:02:21 AM by GuyPerfect »

Blondeshell

  • Elite Boss
  • *****
  • Posts: 808
Re: If I wanted to learn code?
« Reply #22 on: December 26, 2013, 03:38:47 AM »
It has been about 8 years since I did any programming (at college) in C. Forgive me if my eye glaze over...  :o

I'm in the same boat. The last real programming I did was in high school using COBOL in the late 80s.

Carnildo

  • Lieutenant
  • ***
  • Posts: 72
Re: If I wanted to learn code?
« Reply #23 on: December 26, 2013, 06:19:50 AM »
I can't speak for the C spec, which uses the word "undefined" nearly as frequently as the letter E, but every pointer I've ever seen in the history of ever has been the same size as the memory bus width on the target architecture (by definition, based on how pointers are processed by machine code).

That's because you've never programmed on a pure Harvard Architecture machine, and have probably never programmed an x86 running in real mode using the "medium" or "compact" memory models.  Yes, modern systems almost universally use a unified flat memory setup, but back when C was being standardized, handling these systems was a real concern.

Twisted Toon

  • New Efforts # 13,000!
  • Elite Boss
  • *****
  • Posts: 830
Re: If I wanted to learn code?
« Reply #24 on: December 26, 2013, 06:53:04 AM »
I'm in the same boat. The last real programming I did was in high school using COBOL in the late 80s.
I took Basic A and Pascal in high school (late 80s). Then Qbasic in Community college a few years later. Then when I went to "university" (University of Pheonix) in early 2002, I took C, and Java. I understand all the basics to programming, I just don't really have the creativity to do what the game programmers do. I can do simple stuff though.
Hope never abandons you, you abandon it. - George Weinberg

Hope ... is not a feeling; it is something you do. - Katherine Paterson

Nobody really cares if you're miserable, so you might as well be happy. - Cynthia Nelms

GuyPerfect

  • Mary Poppins
  • Titan Staff
  • Elite Boss
  • ****
  • Posts: 1,740
Re: If I wanted to learn code?
« Reply #25 on: December 26, 2013, 03:20:52 PM »
Yes, modern systems almost universally use a unified flat memory setup, but back when C was being standardized, handling these systems was a real concern.

What impact did that have on the relative sizes of function pointers and non-function pointers?

ROBOKiTTY

  • Boss
  • ****
  • Posts: 183
  • KiTTYRiffic
    • KiTTYLand
Re: If I wanted to learn code?
« Reply #26 on: December 26, 2013, 04:08:57 PM »
issa Carnildo~
Have you played with a KiTTY today?

Zombie Man

  • Elite Boss
  • *****
  • Posts: 296
Re: If I wanted to learn code?
« Reply #27 on: December 29, 2013, 06:24:30 AM »
As a result of this thread, I've reclassified coding language as a religion along side Enterprise Captain and OS.

 :P

Carnildo

  • Lieutenant
  • ***
  • Posts: 72
Re: If I wanted to learn code?
« Reply #28 on: December 29, 2013, 09:29:08 AM »
What impact did that have on the relative sizes of function pointers and non-function pointers?
On a Harvard architecture system, there's no relation between function pointers and data pointers -- they don't even refer to the same hardware.  With x86 real mode, the memory models in question would have function pointers of 16 bits and data pointers of 32 (sort of -- 16-bit pointers use the default segment for their type, while 32-bit pointers contain both a segment and offset; both types of pointer access memory using a 20-bit address bus), or vice-versa.

GuyPerfect

  • Mary Poppins
  • Titan Staff
  • Elite Boss
  • ****
  • Posts: 1,740
Re: If I wanted to learn code?
« Reply #29 on: December 29, 2013, 03:03:39 PM »
As a result of this thread, I've reclassified coding language as a religion along side Enterprise Captain and OS.

C the way. C the future.


ROBOKiTTY

  • Boss
  • ****
  • Posts: 183
  • KiTTYRiffic
    • KiTTYLand
Re: If I wanted to learn code?
« Reply #30 on: December 29, 2013, 05:26:02 PM »
My favourite programming languages, objectively speaking, are C# and Xtend. C# would be near perfect if it weren't owned by Microsoft, and Xtend if it weren't constrained by the limits of Java.

Subjectively, LOLCODE KiTTYDialect and Lisp are the best languages evar.
Have you played with a KiTTY today?

thunderforce

  • Elite Boss
  • *****
  • Posts: 264
Re: If I wanted to learn code?
« Reply #31 on: January 07, 2014, 11:20:50 AM »
Which could be a great benefit to not only the community but to myself as well (something to do when I get bored. LOL). So I was wondering, If I wanted to learn code which would be the best one to learn? C++, java, HTML ect...?

Learn a programming language that is suitable for scratching an itch that you want to scratch.

Unless you are astonishingly disciplined, you won't learn much without a motivation or project in mind.

For example, if you are enough of a fan of some existing free software project to want to improve it, learn the language that one is written in. I once had a need to slurp in a lot of automatically generated text and process it, so I became a Perl programmer. And so forth.

Heroette

  • Elite Boss
  • *****
  • Posts: 319
  • Penelope Pistol lives forever in my heart.
Re: If I wanted to learn code?
« Reply #32 on: January 07, 2014, 08:39:21 PM »
Hmmm, about 1/3 page down on the first page, I knew that I did not want to learn code at all.  I will let all those who like that stuff to do it.  I just want my computer to work when I turn it on.

Arcana

  • Sultaness of Stats
  • Elite Boss
  • *****
  • Posts: 3,672
Re: If I wanted to learn code?
« Reply #33 on: January 11, 2014, 01:50:43 AM »
On a Harvard architecture system, there's no relation between function pointers and data pointers -- they don't even refer to the same hardware.  With x86 real mode, the memory models in question would have function pointers of 16 bits and data pointers of 32 (sort of -- 16-bit pointers use the default segment for their type, while 32-bit pointers contain both a segment and offset; both types of pointer access memory using a 20-bit address bus), or vice-versa.
Boy, get hit by a car, miss an entire C gospel.

Just to stick my own two thousandths of a Bitcoin in, the "medium" model used near pointers for data and far pointers for code, while the "compact" model used far pointers for data and near pointers for code.  So in the medium model function pointers were larger than data pointers (more precisely, function pointers had a larger range) while in the compact model it was vice versa.

By standard, C allows you to attempt to cast between them but doesn't guarantee they have the same range, because of things like Harvard or x86-style segment/offset memory (mis)management.  But POSIX implicitly requires function and data pointers have the same size because of its casting rules, so any C program on a POSIX-compliant platform will never see different sized function and data pointers.

As to learning to code, for me it depends on why you're learning.  Learning for fun?  Learn a scripting language like python.  Learning because you're thinking of making programming a significant component of your profession?  Learn C.  Step one: buy a really thick C reference book and whenever someone tells you to switch to Java strike them in the head with it.

As to the notion that the right language teaches good programming habits?  In my experience I've found that to be about as true as the statement that buying the right goldfish teaches people to be Aquaman.

GuyPerfect

  • Mary Poppins
  • Titan Staff
  • Elite Boss
  • ****
  • Posts: 1,740
Re: If I wanted to learn code?
« Reply #34 on: January 12, 2014, 01:31:29 AM »
Sounds like someone never bought the right goldfish.

Drauger9

  • Elite Boss
  • *****
  • Posts: 344
    • My gaming blog
Re: If I wanted to learn code?
« Reply #35 on: January 12, 2014, 01:57:56 AM »
Quote
Hmmm, about 1/3 page down on the first page, I knew that I did not want to learn code at all.  I will let all those who like that stuff to do it.  I just want my computer to work when I turn it on

Agreed, lol. I looked at some of the material and my head started spinning. For the ones that are good at it, your awesome. LOL! Cause I don't think I could and if I did it'd take more free time. Than I have at the moment.

Thanks again and take care. :)

dwturducken

  • Elite Boss
  • *****
  • Posts: 2,152
  • Now available in stereo
Re: If I wanted to learn code?
« Reply #36 on: January 13, 2014, 02:10:05 AM »
Having "learned programming" in two different generations, I'm of the mind that the right "starter language" is entirely subjective to the instructor or the person designing the curriculum. Where I am, it's Java, but the guy teaching that class was fortunate enough to be at the Oracle conference in 1995 (or whatever) when it was introduced. I'm not doing very well with it on my own, but my trouble mostly stems from not "getting" object oriented concepts. I did stumble across a really helpful book for standards and technique, though. There are a few, so I'll leave you to check those out for yourself, but think of them as an informal code version of a style book, like MLA or ASA. There are formal standards for each language, but, according to that instructor, they're about as rigidly followed "in the real world" as print writers adhere to their style guides.

But that's just a fellow student's perspective.

Oh, and:

    Our Program who are in Memory.
    Hello by thy Name.
    Thy Operating System come.
    Thy Commands be done at the Printer as it is on the Screen.
    Give us this day our daily Data,
    And forgive us our I/O errors
    As we forgive those whose logic circuits are faulty.
    Lead us not into frustration, and deliver us from Power Surges.
    For Thine is the Algorithm,
    The Application,
    And the Solution
    Looping forever and ever.
    Return.
I wouldn't use the word "replace," but there's no word for "take over for you and make everything better almost immediately," so we just say "replace."

ROBOKiTTY

  • Boss
  • ****
  • Posts: 183
  • KiTTYRiffic
    • KiTTYLand
Re: If I wanted to learn code?
« Reply #37 on: January 13, 2014, 07:22:03 AM »
As to the notion that the right language teaches good programming habits?  In my experience I've found that to be about as true as the statement that buying the right goldfish teaches people to be Aquaman.

You misunderstand me. My supposition is that the right curricula teach good habits. My favoured curriculum could be rewritten to use C. It would be very clunky to teach functional programming with, but it could be done with GCC.
Have you played with a KiTTY today?

GuyPerfect

  • Mary Poppins
  • Titan Staff
  • Elite Boss
  • ****
  • Posts: 1,740
Re: If I wanted to learn code?
« Reply #38 on: January 14, 2014, 03:51:38 AM »
C provides ways to do object-oriented programming. I've seen a lot of people make the assumption that some languages are "procedural languages" while others are "object-oriented languages", but that's a misrepresentation of what a paradigm is. (-:

Although C doesn't implement the popular "class" approach, you can still create and manipulate objects in memory.

Arcana

  • Sultaness of Stats
  • Elite Boss
  • *****
  • Posts: 3,672
Re: If I wanted to learn code?
« Reply #39 on: January 14, 2014, 05:41:14 AM »
You misunderstand me. My supposition is that the right curricula teach good habits. My favoured curriculum could be rewritten to use C. It would be very clunky to teach functional programming with, but it could be done with GCC.
Well, you mentioned that you'd avoid C because it promotes bad habits, which is a statement about the language itself.  Its also a statement I would disagree with.

Separately, How to Design Programs appears to me, to be honest, to be Data Structures and Algorithms, Scheme edition.  It talks about how Scheme specifically implements specific data processing algorithms, and while it would be possible to convert it into C its honestly very strongly bent towards functional programming style: a conversion would effectively be a rewrite.  Its also not really genuinely a guide to designing programs per se: it focuses on the how of basic algorithms but not the why, and the why is the critical bit to turning coding into designing.

Also, not to get too deep into the delarative/imperative debate and why Lisp is the greatest language in the world, but anyone who thinks this is the perfectly normal way to create a list:

Quote
We can also make lists of numbers. As before, empty is the list without any items. Here is a list with 10 numbers:

(cons 0
  (cons 1
    (cons 2
      (cons 3
        (cons 4
          (cons 5
            (cons 6
              (cons 7
                (cons 8
                  (cons 9 empty))))))))))

Is batsh*t insane.  My final project in advanced programming in college was an expert reasoner in LISP, and today I would sooner set my own feet on fire than write anything more sophisticated than Hello World in that lunatic language or any of its offspring.  Inflicting that on beginners is a crime against humanity.