Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Making the case for O'Caml as an introductory language
Index -> Programming, General Programming -> Functional Programming
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Fri Dec 24, 2010 12:11 am   Post subject: Re: Making the case for O'Caml as an introductory language

bbi5291 @ Fri Dec 24, 2010 12:39 pm wrote:
Scheme:
code:

(display "Input temperature: ")
(display (format "Celsius temperature: ~a\n" (/ (- (read) 32) 1.8)))

(Scheme might have a printf function, essentially the composition of display and format. I'm too lazy to check the standard.)


code:
(define (farenheit-to-celsius farenheit-temp)
    (/ (- farenheit-temp 32) 1.8))

(display "Input temperature: ")

(let ((input-temp (read)))
    (display (format "Celsius temperature: ~a\n"
                     (farenheit-to-celsius input-temp))))
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Sun Dec 26, 2010 11:37 pm   Post subject: Re: Making the case for O'Caml as an introductory language

jcollins1991 @ Thu Dec 23, 2010 5:58 am wrote:
Interesting arguments for O'Caml, but seems a bit one sided.


To directly address this...

I have considered this issue for a long time, and have experience with numerous programming languages, as well as educating several compsci.ca members on various programming concepts. And of course, I'm self-taught. I have become quite convinced of O'Caml's merits over the years for this purpose.

It is one-sided, but largely because I think this language really is that good.
SmokeMonster




PostPosted: Sat Jan 01, 2011 6:17 am   Post subject: Re: Making the case for O'Caml as an introductory language

I see absolutely nothing wrong with teaching Java/C++ as an introductory language. So what if the students have to see more than they need to when start with the language? Java and C++ are fine languages and have a bonus of being widely accepted in the industry. I know tons of people who started off with Java as their first language and turned out to be just fine as programmers. Why not kill two birds with one stone? Teach the students basics of programming and also teach them something that is widely used. An additional advantage of knowing Java or C++ is that it makes transition to C a language that is used in most upper year courses a lot easier. I looker at the sample code for OCaml and the syntax seems cryptic, I don't know how that's easier than the equivalent Java, C++ or Python code. If one insists on teaching an alternative language Ruby might be a better choice, although it might be too easy a language and cause frustration to students learning Java or C++ after programming in Ruby.
wtd




PostPosted: Sat Jan 01, 2011 9:03 am   Post subject: RE:Making the case for O\'Caml as an introductory language

SmokeMonster: which programming languages do you know?

I ask because what we already know biases us, but I am proposing an introductory language and not an only language.
jcollins1991




PostPosted: Sat Jan 01, 2011 10:37 am   Post subject: Re: Making the case for O'Caml as an introductory language

@wtd:

A few more questions...

In Racket (PLT Scheme) there are different learning levels you can choose (subsets of scheme), and each has different error messages appropriate to someone who knows just that subset of the language, and they're all very clear on where the error occurred. Are there any versions of O'Caml that have something similar?

Does the breadth of the language really matter that much? I think it'd be useful in that students have another really useful language to work with later, but for an introductory language couldn't this then re-introduce the problem in Java and C++ where students see too much too soon? I go to UW and they eventually teach the concepts not covered in the first course (done solely with Scheme) using C and C++, which I think is useful as you get exposure to more languages. Personally, learning only a single language to get all the concepts would feel more like a college (in the Canadian sense) where you're being taught a single tool to solve problems with. O'Caml seems to have great versatility, but I'm not sure this should really be a deciding factor in the choice of an introductory language.

Last thing about O'Caml is that while it may be good, what about it is so much better than any other introductory language that anyone should SWITCH to it. New courses might be willing to adopt it, but what do you think could convince a university or highschool that already teaches Python or Scheme to switch their resources to O'Caml?

@SmokeMonster:

I can see absolutely everything wrong with trying to teach people with Java or C++. They might be appropriate when you're teaching students in highschool to make eye candy, and possibly for implementing programming concepts, but definitely not for just teaching the programming concepts. And like wtd asked, what programming languages do you know? / what ones were you taught with?
wtd




PostPosted: Sat Jan 01, 2011 2:11 pm   Post subject: Re: Making the case for O'Caml as an introductory language

jcollins1991 @ Sat Jan 01, 2011 11:37 pm wrote:
@wtd:

A few more questions...

In Racket (PLT Scheme) there are different learning levels you can choose (subsets of scheme), and each has different error messages appropriate to someone who knows just that subset of the language, and they're all very clear on where the error occurred. Are there any versions of O'Caml that have something similar?


No, and this is a nice feature. Not nice enough to win the game, in my opinion, but nice.

jcollins1991 @ Sat Jan 01, 2011 11:37 pm wrote:
Does the breadth of the language really matter that much?


If we're learning at a C++/Java speed, hindered by all of that baggage: no.

If we're learning at a "holy crap Scheme is easy!" pace, then yes, it would be nice to have a language where you can learn about things like OOP as well.

jcollins1991 @ Sat Jan 01, 2011 11:37 pm wrote:
I think it'd be useful in that students have another really useful language to work with later, but for an introductory language couldn't this then re-introduce the problem in Java and C++ where students see too much too soon?


This is one of the reasons I like O'Caml. You don't need to use namespaces or modules or header files or the like to print "Hello, world!" nor do you need to understand objects. As you wish to learn new things, they're added on.

jcollins1991 @ Sat Jan 01, 2011 11:37 pm wrote:
I go to UW and they eventually teach the concepts not covered in the first course (done solely with Scheme) using C and C++, which I think is useful as you get exposure to more languages. Personally, learning only a single language to get all the concepts would feel more like a college (in the Canadian sense) where you're being taught a single tool to solve problems with. O'Caml seems to have great versatility, but I'm not sure this should really be a deciding factor in the choice of an introductory language.


I've learned many programming languages and it's that experience that lets me pitch O'Caml with authority, so I'd be the last person to tell you not to learn other programming languages. The more the better! (Just this one first)

jcollins1991 @ Sat Jan 01, 2011 11:37 pm wrote:
Last thing about O'Caml is that while it may be good, what about it is so much better than any other introductory language that anyone should SWITCH to it. New courses might be willing to adopt it, but what do you think could convince a university or highschool that already teaches Python or Scheme to switch their resources to O'Caml?


Indeed.

I'm not asking anyone to switch at this point. I'm just making a "grass roots" appeal for it to be seriously considered.

Thanks for your continued interest in the debate!
bbi5291




PostPosted: Sat Jan 01, 2011 2:48 pm   Post subject: Re: Making the case for O'Caml as an introductory language

SmokeMonster @ Sat Jan 01, 2011 6:17 am wrote:
I know tons of people who started off with Java as their first language and turned out to be just fine as programmers.
I'm convinced that there are a lot more people who start off with Java and then don't turn out to be "just fine" as programmers. I'm not really sure why this is. It could be because Java is such a bad language to use to teach programming, or it could be because Java is really easy for people who are n00bs in the first place to understand. Functional languages do seem to do a good job of weeding out students whose motives for studying CS aren't "pure", so to speak.
wtd




PostPosted: Sat Jan 01, 2011 3:04 pm   Post subject: RE:Making the case for O\'Caml as an introductory language

Java is a great language to teach first if you want to produce Java programmers.
Sponsor
Sponsor
Sponsor
sponsor
jcollins1991




PostPosted: Sat Jan 01, 2011 7:02 pm   Post subject: Re: Making the case for O'Caml as an introductory language

Finally, are there any textbooks aimed at teaching introductory CS with examples in O'Caml? It'd be interesting to see how someone would teach programming in O'Caml but most of the intro programming stuff I've found in Google are more about coding than the concepts Sad
wtd




PostPosted: Sat Jan 01, 2011 7:37 pm   Post subject: RE:Making the case for O\'Caml as an introductory language

Give me time to write it. Smile

Or, talk to me online and I'll show you some things that'll mess up your mind if you haven't done functional programming before. I'm on Google Talk. My e-mail address is cdutton at gmail dot com.
wtd




PostPosted: Mon Jan 03, 2011 2:35 am   Post subject: Re: Making the case for O'Caml as an introductory language

The attached is a very quick draft.

Edit (1/3/2011 @ 9:34PM PST): updated file uploaded.



O'Caml Intro.txt
 Description:

Download
 Filename:  O'Caml Intro.txt
 Filesize:  11.45 KB
 Downloaded:  229 Time(s)


O'Caml Intro.txt
 Description:

Download
 Filename:  O'Caml Intro.txt
 Filesize:  8.41 KB
 Downloaded:  246 Time(s)

SmokeMonster




PostPosted: Tue Jan 04, 2011 5:32 am   Post subject: Re: RE:Making the case for O\'Caml as an introductory language

wtd @ Sat Jan 01, 2011 9:03 am wrote:
SmokeMonster: which programming languages do you know?

I ask because what we already know biases us, but I am proposing an introductory language and not an only language.


I know VB, Java, C and Ruby (learned in that order). I've done most of my programming recently in C.

bbi5291 @ Sat Jan 01, 2011 2:48 pm wrote:
SmokeMonster @ Sat Jan 01, 2011 6:17 am wrote:
I know tons of people who started off with Java as their first language and turned out to be just fine as programmers.
I'm convinced that there are a lot more people who start off with Java and then don't turn out to be "just fine" as programmers. I'm not really sure why this is. It could be because Java is such a bad language to use to teach programming, or it could be because Java is really easy for people who are n00bs in the first place to understand. Functional languages do seem to do a good job of weeding out students whose motives for studying CS aren't "pure", so to speak.


What is the basis of that remark other than what seems to be a personal hatred and distaste for Java. Do you have any statistics to back that claim up? Java is hardly a noob language, as it has been mentioned in this very thread it has a steeper learning curve due the the fact how engrained OOP is in the design of the language. Sure it's not as hard on you as something like C is but in no way is it a noob language like VB. Also, the second part of your argument does not make a lot of sense, someone doesn't become a programmer by taking that first year course in introductory java, one has to go through exponentially harder stuff like Algorithm Analysis, Compilers, Formal Languages, Operating Systems etc before they graduate and surely those classes would do a better job of weeding out students or toughning them up then any basic first year introductory course using a functional language (or any language for that matter would) ever could.
wtd




PostPosted: Tue Jan 04, 2011 12:12 pm   Post subject: RE:Making the case for O\'Caml as an introductory language

Java, VB, C and Ruby means that you've likely done all of your programming in mostly the same imperative way. I do not mean to discount your opinion, but you need to broaden your perspective before you can comment as authoritatively as you are.

I've been in your position. I benefited from diversifying.
wtd




PostPosted: Tue Jan 04, 2011 12:57 pm   Post subject: Re: Making the case for O'Caml as an introductory language

Another update. More significant this time.

Hopefully at this point, if nothing else, those with concerns about syntax feel a bit more comfortable with it.



O'Caml Intro.txt
 Description:

Download
 Filename:  O'Caml Intro.txt
 Filesize:  14.59 KB
 Downloaded:  224 Time(s)

jcollins1991




PostPosted: Tue Jan 04, 2011 3:34 pm   Post subject: Re: Making the case for O'Caml as an introductory language

With the explanation the syntax of O'Caml actually seems pretty nice.

code:

# let baz =
     (let foo = 42
      and bar = 2
      in
         (foo / bar - 5 * 2 + 1))
  and wooble = 4
  in
     (baz - wooble) ;;
- : int = 8


Being able to define local variables within function definitions is extremely nice and could add quite a bit of readability to programs, and feels a lot more intuitive than the equivalents in the Racket teaching languages.

I guess the only problem left would be indentation preference, is there any type of standard for indentation (like with Python)? (In Racket it seemed some profs liked certain indentation while others had really ugly indentation, and I ended up having to completely reformat a lot of code examples to something that my eyes could easily scan through)
Display posts from previous:   
   Index -> Programming, General Programming -> Functional Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 3  [ 35 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: