Post #101,438
5/12/03 10:41:17 AM
5/14/03 9:55:29 AM
|

Re: The awakening begins
Hi, this post may seem too long, or offtopic at first but I mostly want to use this typing debate to elaborate on my problems with learning how to program. You should know I don't consider myself a programmer yet,I almost did not write any programs (but I of course tested, played with code and example from books I read)
What's really creating the crisis/delay/problem/barrier for me is that I usually try to figure out the big picture of things before I bother with details, in creating a progam this is not always possible, sometimes you have to start from creating the details, until you have large enough concepts that you can use to figure out the big picture or how a program will finally look like. Plus creating any significant program require lots of library studying, trial and error work, wich compared to learning a new language ,is very boring and feels like labor!
Anyway, since I decided to learn how to program, I went to the issue/thing of choosing a language to learn, my first attempt was Java why? The java sdk was free, several free IDEs (Netbeans, eclipse, etc...) plus j2ee looked like an impressive framework ...
I bought learning-java in 21 days (3 weeks) I read the first week few chapters from thinking in Java by bruce eeckel and gave up on java !!! the books does an extremely poor job on keeping you exited about the wonderful skill/ability to create a functional program
I decided to look for another language ... by that time I have gottin into linux, got a clear view of the GNU, FSF and the whole thing
Most of the programmer communities seem to have forgotin how it was before they knew this world existed
I decided to learn about the cult, vim vs emacs, kde vs gnome, python vs perl.. I do believe that those debates are as serious as it gets
Comapring software is serious we are supposed to learn how to make software we should know a good program when we see it, and one way or another some programs should be "by design" better then others plus we are talking free software here, we dont just get to see what the program do, we also get to see how it was built, i dont recall ever seeing an article comparing the source code and source code design choices of 2 programs that do the same thing, what is good code? how do i know it when i see it !!!!
Some people call these comparisions religious or flame wars ... Of course if we are gonna settle for vim sux, emacs rules then yes this is shallow, but if we start discussing whats the best UI interface or human interface as some like to call it we might really get somewhere.. Plus maybe they have a point, preferring kde or gnome can be purely a matter of taste (unless one offer a basic need/function that the other doesnt) but on the source code level, which have better code, and why?
Anyway, I after reading a dozen lang-x vs lang-x vs .... I picked python Perl had a nasty and scary reputation of being write only Python had more free books online (at the time I didnt know how big the perldocs were, probably since I mainly started to favor python since my win98 days) And python also had Zope, which looked impressive.( till today I haven't learned what zope really do, on how it do it, yet it was mostly the determining factor for me to choose to learn python over other langs )
I downloaded several books, read some, got bored again !!!
C followed python, I already took 2 programming course in uni in which we used C, is low level compared to Java and Python And it was not object oriented. It was fun and challenging until I finished learning the semantics
By that time I had already heard of Ocaml and Objective-C
So i started considereing picking up one of them! For different reasons I picked Ocaml, mainly because it was a functional lang, and I thought that I need to be introduced to that paradigm.
Aahh, the programming paradigm, I was introduced to that topic by a post made by ben tilly on perlmonks, and I kind of find out about this forum from his home node @ perlmonks. (Thank you)
Beside traditional functional programming ocaml also introduced me to types and to the notion of comparing classes to modules not just to types!
All the time I was learning I was always tried to philosophy programming, and OOP, what are objects? what a program should be like? (first I design my objects, then I design possible scenarios where those objects will send message to each other or what? And those scenario they will be objects themselves, right? I don't know, but the stuff i read make it seem that way to me!)
There is a strong barrier for people who want to learn how to program that many books ignore, and that is how do I really create a program, divide it into modules, create the main function/loop After I learn how to create functions and classes, now what, how should they play togethe maybe I am stupid or avoiding the obvious.
Anyway, I do believe that the CS literature (the sum of books writen on the topic) is full of irresponsible writer and very poorly writen books!
Static typing, good or bad ( why is that even an issues today in 2003 ) Shoudnt the CS literature be mature enough to objectively answer this question!!!
==Types== lets move to my attempt to understand and philosophy types
why do many ppl insist on ignoring the fact that interger as a group of acceptable values that have a useful meaning! are fundamentaly different then ... let say structures(or lists or hashtables) ! they are both so very different I dont think we should call em the same thing! (types)
==c== int a = 1; // a can only hold a value in a certain range
int a = 'a';
this would pass, but is 'a' an acceptable value for an integer no but the c compiler dont mind it cause 'a' is actually a binary value that can in turn be meaningful as an integer!
but'a', is not an integer type, not in this world, only in the computer world for sure!!
==ocaml== Ocaml (which is strictly typed) allow you to do this type day = Mon | Tue | Wed | Thu | Fri | Sat | Sun ;;
Now any variable known to be of type day can only have one of those values!
==c== you can emulate this in c by doing typedef enum { Mon , Tue , Wed , Thu , Fri ,Sat , Sun } weekdays_t;
but we know that weekdays_t is actually a collection of intergers, in ocaml we don't it's another type, and we can never treat Mon as 1 in ocaml!!!
==Objects== Now Objects are a sturcture (that is of special value to us, so in that sense it is a value)!
{ Number = 1 ; Character = 'A' ; String = "something"; }
But of course, we always had stuctures in C so what's the fuzz ??
==Objective-C== the free book from apple, does a great job at explaining oop concepts , dynamic typing, binding and more ... especially messaging!
Objective-C, says that ( or so far it does, I am at page 92 in that book ) data are hidden inside an object, an object have methods and you can send an object a message to request a value (function) or perform a task (procedure), if the object encapsulate a value that you would like to know, you must create a method that retrieve it represent it to you! I think this goes inline with Ocaml when it compared classes to modules and when the objective-c books said that Classes are a true logical piece of the program (unlike module)
<!--- on side note: you can use objects to emulate closures!!! very interesting, i wonder doesnt that mean, that a language with objects would be making redundant efforts by adding closures! ---!>
==Back to the main topic==
so where does static typing fit in all that how can we discuss it, in a way better then static typind suxxxxx dynamism ruuuulllllllleeeeeeeesssssssssssss or cause it makes right shorter code, or that it makes me right code easier! (what can the average person who want to be a descent programmer one day, learn from that?)
I really don't think I know, I don't think I got the big picutre yet, but i will give it a shot anyway: C is said to be a static and weakly typed language! Ocaml is static, strict, polymorphic, compiled Objective-c is OO, dynamic, compiled Python it's interpreted, dynanmic OO
They all work So It's like <!--- BLANK, WHITE, VOID ---!> for me Does strict typing allow for less testing ? (if so isn't that good) wouldn't that mean shorter test session, less time to make software which can be seen as a benefit!
I read this in the objective-c books NSobject, is an abstract class, that is not usefull by it self cause it does nothing in particular!
And I think that's what type checking can do for a new programming student it's help him construct programs that does something specific and useful, rather that chasing shadows!
Most of those top notch programmers who say I dont need static type checking are probably skilled enough not to do the mistakes that static typing highlight! And they enjoy the flexibility of the "all structural types are generic!" a list in python can hold a combination of arbitary types (I want to ask experienced programmers when is that useful)
so if i may i see that the current popular terminology defines that: (...)type checking done at compile time is called static (...)type checking done at run time is called dynamic
and if i may, i would like to create my own terminology which i think describe the situatio better: (...)type checking done by the compiler, is called automated type checking (...)type checking done at runtime, is called manual type checking
so maybe we have a problem, because manual type checking performed by human usually lead, to better (as in more flexible) results then that done by the machine! this is sad, the solution should not be to recommend manual type checking but rather create better software type checkers if the process of verifying which objects are accept by a method and which objects are rejected is structured enough, we can theoratically create a software that identify them and report them (as they are) to the programmer I think this should, be part of the compiler job
this already exist, and is known as type inference (check ocaml)
if the certian aspects of the type are irrelevant then the compiler report just just (in ocaml we 'a list type, which is a list of anything, that is any one kind of things ) it's good the compiler points that to you, right!
===Conclusion===
I dont think the problem is static typing i think the problem is how we do static typing and more importantly how we seem to fail to identify types
If a function call, on specific attributes of a type for example: obj.walk() the type here should be partially defined obj should be typed any objects that have attribute method walk()
and this should be make clear in the method or function signature of course many statically typed langs wont let you do this and the solution there is as ToddBlanchard said, to refactor ( I assume this means, redesign) your class hierarchy, to have an abstract type that have just enough attributes to path this method sucessfully
the dynanmic manual solution wont have this problem since it allow a JIT kind of type checking but if an object have to pass this method, but unfortunatly generate a run-time type error, the solution here would be to read the method implemenation to see which attribute is missing, and add to the object that must use this method which still seem more akward to me then successful (partial) static typing and this mean that here you have to completly reveil the implementation detail whereas in automated type checking, the implementation is partially reveiled
of course the key issue here is good type inference
we are programmers, our job, is to find ways to let to machine do as much of the work as possible. if the machine can do it, the machine should do it TDD+dynamic typing shouldn't be the solution, to partial types working on type inference techniques, and automated (static) type checking is!
Of course, until we have that, and maybe we do ( i still dont know all that much about ocaml) TDD + a dynamic language could be the best we have now!
but of course a descent advice that stresses the importance of testing will always be good!(and it actually do more then type checking)
Anyway, I dont know how to continue any furthur in this debate But I just wanted to say how I think so that maybe others can highlight to me, where I think wrong or where I gone bogus
Thanx for reading such a long post :) And I hope to read long meaningfull post from all!

Edited by systems
May 12, 2003, 10:43:42 AM EDT
Re: The awakening begins
Hi, this post may seem too long, trollish or irrelevan, but I mostly was to use this typing debate to elaborate on my problems with learning how to program, I am trying learning how to program, I am not a programmer, I almost did not write any programs (but I of course tested, played with code and example from books I read)
What's really creating this crisis/delay/problem/barrier for me is that I usually try to figure out the big picture of things before I bother with details, in creating a progam this is not always possible, sometimes you have to start from creating the details, until you have large enough concepts to make you able to figure out the big picture or how a program will finally look like, that and of course that creating any significant program require lots of library studying, trial and error work, wich compared to learning the semantics of a new language is very boring, and feels like labor!
Anyway, since I decided to learn how to program, I went to the issue/thing or choising a language to learn, my first attempt was Java, why?
The java sdk was free, several free IDEs (Netbeans, eclipse, etc...) plus j2ee looked like an impressive framework ... I bought learning-java in 21 days (3 weeks) I read the first week few chapters from thinking in Java by bruce eeckel and gave up on java !!! the books does an extremely poor job on keeping you exited about the wonderful skill/ability to create a functional program
I decided to look for another language ... by that time I have gottin into linux, got a clear view on the GNU, fsf and the whole thing
Most of the programmer communities seem to have forgotin how it was before they knew this world existed
I decided to learn about the cult, vim vs emacs, kde vs gnome, python vs perl.. I do believe that those debates are as serious as it gets
Comapring software, we are supposed to learn how to make software we should know a good program when we see it, and in a way some programs should be by design better then others
Some people call em religious or frame wars ... Of course if we are gonna settle for vim sux, emacs rules then yes this is shallow, but if we start discussing whats the best UI interface or human interface as some like to call it we might really get somewhere..
Anyway, I tried to figure so which language to pick .... I picked python ... Perl had a nasty and scary reputation of being read only Python have more free books online (at the time I didnt know how big the perldocs were, probably since I mainly started to favor python since my win98 days)
Anyway, I downloaded several books, read some, got bored again... Went to spending time with C, I already took 2 programming course in uni in which we used C, is low level compared to Java and Python And it was not object oriented.
I was fun until I finished learning the semantics By that time I had already heard of Ocaml and Objective-C
So i started considereing picking up one of them! For differet reasons I picked Ocaml, mainly because it was a functional lang, and I thought that I need to be introduced to that paradigm.
Aahh, the programming paradigm, I was introduced to that topic by a post to ben tilly made on perlmonks, and I kind of find out about this forum from his home node @perlmonks. (Thank you)
Ocaml intorduced types to me, and the notiong of comparing classes to modules not just to types! ... all the time I was learning I always tried to philosophy programming, and OOP, what are objects what a program should be like (first design you objects, then design scenario objects or what?)
There is a strong barrier for people who want to learn how to program that any books ignore, how do I really create a program, divide it into module, creating the main function/loop , ( so I learned how to create functions and classes, now what, how should play together) maybe I am stupid or avoiding the obvious.
Anyway, I do believe that the CS literature (the sum of books writen on the topic) is full of irresponsible writer and very poorly writen books!
Static typing, good or bad ( why is that even an issues today in 2003 ) isnt the CS literature should be mature enough to objectively answer this question!!!
But first what are types, why do many ppl insist to ignoring the fact that interger as a group of acceptable values that have a useful meaning!
==c== int a = 1; // a can only hold value in a certain range
int a = 'a';
this would pass, but is 'a' an acceptable value for an integer no but th c compiler dont mind it cause 'a' is actually a binary value that can in turn be meaning full as an integer!
but'a', is not an integer type, not in this world, only in the computer world for sure!!
==ocaml== Ocaml (which is strictly tuped) allow you to do this type day = Mon | Tue | Wed | Thu | Fri | Sat | Sun ;;
Now any variable know as to be day can only have one of those values!
==c== you can emulate this in c by doing typedef enum { Mon , Tue , Wed , Thu , Fri ,Sat , Sun } weekdays_t;
but we know that weekdays_t is an interger, in ocaml we don't it's another type, and we can neber treat Mon as 1 in ocaml!!!
==Objects== Now Objects are a sturcture (that is of special value to us, so in that sense it is a value)!
{ Number = 1 ; Character = 'A' ; String = "something"; }
But of course, we always had stuctures in C so what's the fuzz ??
==Objective-C== the free book from apple, does a great job at explaining oop concepts , dynamic typing, binding and more ... especially messaging!
Objective-C, says that ( or so far it does, I am at page 68 in that book ) data are hidden in side an object, an object have methods and you can send an object a message to request a value (function) or perform a task (procedure), if the object encapsulate a value that you would like to know, you must create a method that retrieve it represent it to you! No this goes inline with when Ocaml compared classes to modules and when the objective-c books said that Classes are a true logical piece of the program (unlike module)
And you can use objects to emulate closures!!!
==Back to the main topic== so where does static typing fit in all that how can we discuss it, in a way better then static typind suxxxxx dynamism ruuuulllllllleeeeeeeesssssssssssss
I really don't think I know, I don't think I got the big picutre yet C is said to be a static and weakly typed language! Ocaml is static, strict, polymorphic, compiled Objective-c is OO, dynamic, compiled Python it's interpreted, dynanmic OO
They all work So It's like <!--- BLANK, WHITE, VOID ---!> for me Does strict typing allow for less testing (if so isn't that good)
I read this in the objective-c books NSobject, is an abstract class, that is not usefull by it self cause it does nothing in particular!
And I think that's what type checking can do for programming students it's help em construct programs that does something specific and thus useful!
Most of those top notch programmers who say I dont need static type checking are probably skilled enough not to do the mistakes that static typing highlight! And they enjoy the flexibility of the "all structures are generic!" a list in python can hold a combination of arbitary types (I want to ask experienced programmers when is that useful)
OOP, allow you to create object with the same method names thus create other object that call on these method
Create some sort of loop, send different objects to that generci object and bleh!!...receive something different with each different type of object. ( I think this is kind of possible in ocaml, even tought it's strict )
so type checking done at compile time , or run time wut's really the difference, if the type is irrelevant (ocaml way of polymorphism) then the compiler should not complain. And if there is a problem then it's good the compiler points it to you Else all you program sould be like
try : generic_method(an_object) Except TypeError: raise "Object don't compute"
And if this occure, you should look inside what messages generic_mothod call, and add them to an_object class !!! But is that a solution and what kind of program is that anyway!
I think Ocaml did successful, introduce me to a new kind of polymorphism .
Anyway, I dont know how to continue any furthur in this debate But I just wanted to say how I think so that maybe others can highlight to me, where I think wrong or where I gone bogus
Thanx for reading such a long post :) And I hope to read long meaningfull post from all!

Edited by systems
May 13, 2003, 10:27:56 PM EDT
Re: The awakening begins
Hi, this post may seem too long, or offtopic at first but I mostly want to use this typing debate to elaborate on my problems with learning how to program. I am trying learning how to program, I am not a programmer, I almost did not write any programs (but I of course tested, played with code and example from books I read)
What's really creating this crisis/delay/problem/barrier for me is that I usually try to figure out the big picture of things before I bother with details, in creating a progam this is not always possible, sometimes you have to start from creating the details, until you have large enough concepts to make you able to figure out the big picture or how a program will finally look like, that and of course that creating any significant program require lots of library studying, trial and error work, wich compared to learning the semantics of a new language is very boring, and feels like labor!
Anyway, since I decided to learn how to program, I went to the issue/thing or choising a language to learn, my first attempt was Java, why?
The java sdk was free, several free IDEs (Netbeans, eclipse, etc...) plus j2ee looked like an impressive framework ... I bought learning-java in 21 days (3 weeks) I read the first week few chapters from thinking in Java by bruce eeckel and gave up on java !!! the books does an extremely poor job on keeping you exited about the wonderful skill/ability to create a functional program
I decided to look for another language ... by that time I have gottin into linux, got a clear view on the GNU, fsf and the whole thing
Most of the programmer communities seem to have forgotin how it was before they knew this world existed
I decided to learn about the cult, vim vs emacs, kde vs gnome, python vs perl.. I do believe that those debates are as serious as it gets
Comapring software, we are supposed to learn how to make software we should know a good program when we see it, and in a way some programs should be by design better then others
Some people call em religious or frame wars ... Of course if we are gonna settle for vim sux, emacs rules then yes this is shallow, but if we start discussing whats the best UI interface or human interface as some like to call it we might really get somewhere..
Anyway, I tried to figure so which language to pick .... I picked python ... Perl had a nasty and scary reputation of being read only Python have more free books online (at the time I didnt know how big the perldocs were, probably since I mainly started to favor python since my win98 days)
Anyway, I downloaded several books, read some, got bored again... Went to spending time with C, I already took 2 programming course in uni in which we used C, is low level compared to Java and Python And it was not object oriented.
I was fun until I finished learning the semantics By that time I had already heard of Ocaml and Objective-C
So i started considereing picking up one of them! For differet reasons I picked Ocaml, mainly because it was a functional lang, and I thought that I need to be introduced to that paradigm.
Aahh, the programming paradigm, I was introduced to that topic by a post to ben tilly made on perlmonks, and I kind of find out about this forum from his home node @perlmonks. (Thank you)
Ocaml intorduced types to me, and the notiong of comparing classes to modules not just to types! ... all the time I was learning I always tried to philosophy programming, and OOP, what are objects what a program should be like (first design you objects, then design scenario objects or what?)
There is a strong barrier for people who want to learn how to program that any books ignore, how do I really create a program, divide it into module, creating the main function/loop , ( so I learned how to create functions and classes, now what, how should play together) maybe I am stupid or avoiding the obvious.
Anyway, I do believe that the CS literature (the sum of books writen on the topic) is full of irresponsible writer and very poorly writen books!
Static typing, good or bad ( why is that even an issues today in 2003 ) isnt the CS literature should be mature enough to objectively answer this question!!!
But first what are types, why do many ppl insist to ignoring the fact that interger as a group of acceptable values that have a useful meaning!
==c== int a = 1; // a can only hold value in a certain range
int a = 'a';
this would pass, but is 'a' an acceptable value for an integer no but th c compiler dont mind it cause 'a' is actually a binary value that can in turn be meaning full as an integer!
but'a', is not an integer type, not in this world, only in the computer world for sure!!
==ocaml== Ocaml (which is strictly tuped) allow you to do this type day = Mon | Tue | Wed | Thu | Fri | Sat | Sun ;;
Now any variable know as to be day can only have one of those values!
==c== you can emulate this in c by doing typedef enum { Mon , Tue , Wed , Thu , Fri ,Sat , Sun } weekdays_t;
but we know that weekdays_t is an interger, in ocaml we don't it's another type, and we can neber treat Mon as 1 in ocaml!!!
==Objects== Now Objects are a sturcture (that is of special value to us, so in that sense it is a value)!
{ Number = 1 ; Character = 'A' ; String = "something"; }
But of course, we always had stuctures in C so what's the fuzz ??
==Objective-C== the free book from apple, does a great job at explaining oop concepts , dynamic typing, binding and more ... especially messaging!
Objective-C, says that ( or so far it does, I am at page 68 in that book ) data are hidden in side an object, an object have methods and you can send an object a message to request a value (function) or perform a task (procedure), if the object encapsulate a value that you would like to know, you must create a method that retrieve it represent it to you! No this goes inline with when Ocaml compared classes to modules and when the objective-c books said that Classes are a true logical piece of the program (unlike module)
And you can use objects to emulate closures!!!
==Back to the main topic== so where does static typing fit in all that how can we discuss it, in a way better then static typind suxxxxx dynamism ruuuulllllllleeeeeeeesssssssssssss
I really don't think I know, I don't think I got the big picutre yet C is said to be a static and weakly typed language! Ocaml is static, strict, polymorphic, compiled Objective-c is OO, dynamic, compiled Python it's interpreted, dynanmic OO
They all work So It's like <!--- BLANK, WHITE, VOID ---!> for me Does strict typing allow for less testing (if so isn't that good)
I read this in the objective-c books NSobject, is an abstract class, that is not usefull by it self cause it does nothing in particular!
And I think that's what type checking can do for programming students it's help em construct programs that does something specific and thus useful!
Most of those top notch programmers who say I dont need static type checking are probably skilled enough not to do the mistakes that static typing highlight! And they enjoy the flexibility of the "all structures are generic!" a list in python can hold a combination of arbitary types (I want to ask experienced programmers when is that useful)
OOP, allow you to create object with the same method names thus create other object that call on these method
Create some sort of loop, send different objects to that generci object and bleh!!...receive something different with each different type of object. ( I think this is kind of possible in ocaml, even tought it's strict )
so type checking done at compile time , or run time wut's really the difference, if the type is irrelevant (ocaml way of polymorphism) then the compiler should not complain. And if there is a problem then it's good the compiler points it to you Else all you program sould be like
try : generic_method(an_object) Except TypeError: raise "Object don't compute"
And if this occure, you should look inside what messages generic_mothod call, and add them to an_object class !!! But is that a solution and what kind of program is that anyway!
I think Ocaml did successful, introduce me to a new kind of polymorphism .
Anyway, I dont know how to continue any furthur in this debate But I just wanted to say how I think so that maybe others can highlight to me, where I think wrong or where I gone bogus
Thanx for reading such a long post :) And I hope to read long meaningfull post from all!

Edited by systems
May 14, 2003, 09:55:29 AM EDT
Re: The awakening begins
Hi, this post may seem too long, or offtopic at first but I mostly want to use this typing debate to elaborate on my problems with learning how to program. I don't consider myself a programmer yet,I almost did not write any programs (but I of course tested, played with code and example from books I read)
What's really creating the crisis/delay/problem/barrier for me is that I usually try to figure out the big picture of things before I bother with details, in creating a progam this is not always possible, sometimes you have to start from creating the details, until you have large enough concepts that you can use to figure out the big picture or how a program will finally look like. Plus creating any significant program require lots of library studying, trial and error work, wich compared to learning a new language ,is very boring and feels like labor!
Anyway, since I decided to learn how to program, I went to the issue/thing of choosing a language to learn, my first attempt was Java why? The java sdk was free, several free IDEs (Netbeans, eclipse, etc...) plus j2ee looked like an impressive framework ...
I bought learning-java in 21 days (3 weeks) I read the first week few chapters from thinking in Java by bruce eeckel and gave up on java !!! the books does an extremely poor job on keeping you exited about the wonderful skill/ability to create a functional program
I decided to look for another language ... by that time I have gottin into linux, got a clear view on the GNU, fsf and the whole thing
Most of the programmer communities seem to have forgotin how it was before they knew this world existed
I decided to learn about the cult, vim vs emacs, kde vs gnome, python vs perl.. I do believe that those debates are as serious as it gets
Comapring software is serious we are supposed to learn how to make software we should know a good program when we see it, and in a way some programs should be by design better then others
Some people call these comparisions religious or flame wars ... Of course if we are gonna settle for vim sux, emacs rules then yes this is shallow, but if we start discussing whats the best UI interface or human interface as some like to call it we might really get somewhere.. Plus maybe they have a point, preferring kde or gnome can be purely a matter of taste (unless one offer a basic need/function that the other doesnt)
Anyway, I after reading a dozen lang-x vs lang-x vs .... I picked python Perl had a nasty and scary reputation of being read only Python have more free books online (at the time I didnt know how big the perldocs were, probably since I mainly started to favor python since my win98 days) And again Zope, looked impressive.( till today I haven't learned what zope really do, on how it do it, yet it was mostly the determining factor for me to choose to learn python over other langs )
I downloaded several books, read some, got bored again !!!
C followed python, I already took 2 programming course in uni in which we used C, is low level compared to Java and Python And it was not object oriented. It was fun until I finished learning the semantics
By that time I had already heard of Ocaml and Objective-C
So i started considereing picking up one of them! For different reasons I picked Ocaml, mainly because it was a functional lang, and I thought that I need to be introduced to that paradigm.
Aahh, the programming paradigm, I was introduced to that topic by a post to ben tilly made on perlmonks, and I kind of find out about this forum from his home node @perlmonks. (Thank you)
Beside traditional functional programming ocaml also introduce types to me and the notiong of comparing classes to modules not just to types! All the time I was learning I always tried to philosophy programming, and OOP, what are objects? what a program should be like? (first I design my objects, then I design possible scenarios where those objects will send message or what? And those scenario they will be objects themselves, right? I don't know, maybe! the stuff i read make it seem that way)
There is a strong barrier for people who want to learn how to program that many books ignore, how do I really create a program, divide it into modules, create the main function/loop After I learn how to create functions and classes, now what, how should play togethe maybe I am stupid or avoiding the obvious.
Anyway, I do believe that the CS literature (the sum of books writen on the topic) is full of irresponsible writer and very poorly writen books!
Static typing, good or bad ( why is that even an issues today in 2003 ) Shoudnt the CS literature be mature enough to objectively answer this question!!!
lets move to my attempt to understand and philosophy types
why do many ppl insist to ignoring the fact that interger as a group of acceptable values that have a useful meaning! And are fundamentaly different then ... let say structures ! they are both so very different I dont think we should call em the same thing! (types)
==c== int a = 1; // a can only hold value in a certain range
int a = 'a';
this would pass, but is 'a' an acceptable value for an integer no but th c compiler dont mind it cause 'a' is actually a binary value that can in turn be meaning full as an integer!
but'a', is not an integer type, not in this world, only in the computer world for sure!!
==ocaml== Ocaml (which is strictly tuped) allow you to do this type day = Mon | Tue | Wed | Thu | Fri | Sat | Sun ;;
Now any variable know as to be day can only have one of those values!
==c== you can emulate this in c by doing typedef enum { Mon , Tue , Wed , Thu , Fri ,Sat , Sun } weekdays_t;
but we know that weekdays_t is an interger, in ocaml we don't it's another type, and we can neber treat Mon as 1 in ocaml!!!
==Objects== Now Objects are a sturcture (that is of special value to us, so in that sense it is a value)!
{ Number = 1 ; Character = 'A' ; String = "something"; }
But of course, we always had stuctures in C so what's the fuzz ??
==Objective-C== the free book from apple, does a great job at explaining oop concepts , dynamic typing, binding and more ... especially messaging!
Objective-C, says that ( or so far it does, I am at page 68 in that book ) data are hidden in side an object, an object have methods and you can send an object a message to request a value (function) or perform a task (procedure), if the object encapsulate a value that you would like to know, you must create a method that retrieve it represent it to you! No this goes inline with when Ocaml compared classes to modules and when the objective-c books said that Classes are a true logical piece of the program (unlike module)
<!--- on side note: you can use objects to emulate closures!!! very interesting, i wonder doesnt that mean, that a language with objects would be make redundant efforts by adding closures! ---!>
==Back to the main topic==
so where does static typing fit in all thathow can we discuss it, in a way better then static typind suxxxxx dynamism ruuuulllllllleeeeeeeesssssssssssss cause it makes right shorter code, or that it makes me right code easier! (whats can a new person who want to be a descent programmer one day, learn from that?)
I really don't think I know, I don't think I got the big picutre yet, but i will give it a shot anyway: C is said to be a static and weakly typed language! Ocaml is static, strict, polymorphic, compiled Objective-c is OO, dynamic, compiled Python it's interpreted, dynanmic OO
They all work So It's like <!--- BLANK, WHITE, VOID ---!> for me Does strict typing allow for less testing (if so isn't that good) wouldn't that mean shorter test session, less time to make software which can translate to this is better!
I read this in the objective-c books NSobject, is an abstract class, that is not usefull by it self cause it does nothing in particular!
And I think that's what type checking can do for programming students it's help em construct programs that does something specific and thus useful!
Most of those top notch programmers who say I dont need static type checking are probably skilled enough not to do the mistakes that static typing highlight! And they enjoy the flexibility of the "all structures are generic!" a list in python can hold a combination of arbitary types (I want to ask experienced programmers when is that useful)
so type checking done at compile time , or run time wut's really the difference, rationally (as in by common sens), if you can type check your program before it runs, this is only better! if the type is irrelevant (ocaml way of polymorphism) then the compiler should not complain. And if there is a problem then it's good the compiler points it to you
===Conclusion===
I dont think the problem is static typing i think the problem is how we do static typing and more importantly how we seem to fail to identify types
If a function call, on specific attributes of a type for example: obj.walk() the type here should be partially defined obj should be typed any objects that have attribute methos walk() and this should be make clear in the method or function signature else the other solution would be to read the method implemenation to see which attribute is missing, and add to the object that must use this method which seem more akward to me then successful (partial) static typing
Of course this kind of typing, can be better achieve with type inference
Test Driven Developement : isnt this obvious propaganda to sell some books or something, how is that different that a descent advice to stress the importance of testing!
Anyway, I dont know how to continue any furthur in this debate But I just wanted to say how I think so that maybe others can highlight to me, where I think wrong or where I gone bogus
Thanx for reading such a long post :) And I hope to read long meaningfull post from all!
|