Standard ML

Status
Not open for further replies.
Hey guys. I'm currently a hard working :D student working toward a BS in computer science. Anyway, in this computer science class I'm taking (Coms 312), we use Standard ML for our projects. I've studied several different languages before SML (BASIC, pascal, C++, and java mainly), but I gotta say - I think SML is a pretty cool language.

Well, so I thought I might ask what you guys think about SML. Just a general question about what you do with SML (that is, if you use SML), what you think about the language, and whatever-else you want to say about the language.

Oh yea, the softwares I use for this class are SML/NJ compiler v110.0.7 (09.28.2000) and Emacs editor using sml-mode v3.3.

Well, thanks for all your replies!

-Huh
 
Well, this is a third semester computer science class at my school. The way we go is like this. In Coms 100, we use MATLAB/Java; in Coms 211, we use Java; and then in Coms 312, we use SML.

According to our website (if you're interested, the URL is http://cs312.cs.cornell.edu):
CS312 is the third programming course in the Computer Science curriculum, following CS100 and CS211. The primary goal of the course is to give students a firm foundation in the fundamental principles of programming and computer science. Consequently, CS312 covers a broad set of topics including (1) alternative programming paradigms (beyond imperative and object-oriented programming), (2) key data structures and algorithms, (3) reasoning about program behavior and complexity, (4) type systems and data abstraction, and (5) the design and implementation of programming languages.

A major goal in CS312 is to teach you how to program well. Just about anyone can learn how to program, but it takes a deep understanding of the principles of computer science to write truly elegant and efficient programs.

We use the Standard ML (SML) programming language throughout the course. SML is a modern functional programming language with an advanced type and module system. The course is not about programming in SML. Rather, SML provides a convenient framework in which we can achieve the objectives of the course. Like the object-oriented model of Java, the functional paradigm of SML is an important programming model with which all students should be familiar, as it underlies the core of almost any high-level programming language. In addition the SML type and module systems provide frameworks for ensuring code is modular, correct, re-usable, and elegant. Other languages, such as Java, also provide facilities to achieve these goals, but the mechanisms of SML are largely orthogonal to those of object-oriented languages. By studying alternatives, students will be better equipped to use, implement or even design future programming environments that combine the best features of both worlds.

Another important reason we use SML is that it has a relatively clean and simple model that makes it easier to reason about the correctness of programs. Indeed, SML was one of the first major programming languages to have a formal semantic definition. In our studies, we will reason not only about the functional correctness of code, but also the space, time, and other resources used in a computation. The relatively simple evaluation model for SML makes it easy to do this.

-Huh
 

Pont

Ars Legatus Legionis
26,160
Subscriptor
Broadening horizons. You're in a real college, not some "CLC got me a programming job in just 6 months!" piece of crap.

ML can be mathematically proven correct (so I've heard), which makes grading easier. Also, with ML (from what little I remember of it), if you don't know what you're doing, you won't get any results at all. In C and even Java, there are many times where you spew out some code to do something or add a few extra keywords and suddenly your program works (usually because a friend told you somthing like "Oh, you need to make that a public static const" or some junk). With ML, you either know it or you don't.

ML is interpreted, which means it can be used from any platform.
There is no compiling to worry about.
There is no ML IDE (AFAIK), which means students won't bitch about "But professor! It compiled just fine on my home computer under Visual C++!".

Since the students probably don't know ML yet, they are taking a fresh perspective. This is HUGE, because this class seems to be focusing on *good* programming, not just programming. If someone has learned bad habits in C++, teaching them to be good C++ programmers using C++ is going to be an uphill battle. Teach them good practices in ML, then when they go back to C++ they'll automagically apply what they learned.
 

Victim12

Ars Tribunus Militum
1,978
I have to admit I'm a little biased against SML because of all the other students in college learning it in class and becoming programming language snobs because of it. I ended up taking a long look at other languages in my free time. What I think in general is that it's good to learn more languages. There's all kinds of things that are easy to write in SML or another language, and harder with BASIC, Pascal, C++, or Java.
 
D

Deleted member 5324

Guest
ML rocks. I'm a huge fan of O'Caml, which is a lot like SML, but a bit more practical in a few parts: it has a faster, better optimizing implementation and several additions such as a fully typesafe object model.

SML, on the other hand, has first-class continuations, which I've not had the oppurtunity to play with, but seem very interesting.

Don't understimate the amazing tool that a strictly typed language is. It really helps me (a fairly undisciplined programmer) write correct programs.

If you take a look at O'Caml, I've written an IRC bot in it. You can see it on the arstechnica irc server in channel #linux.

Jeremy
 
Originally posted by jemfinch:
SML, on the other hand, has first-class continuations, which I've not had the oppurtunity to play with, but seem very interesting.

My God man, why? Continuations are certainly useful, and neat to play with, but they're really icky on one level; a continuation is essentially a goto, only the point which you go to is not set, but variable. I just hate the things.

But ML in general does rock; it gives you (like most functional languages) a direct correspondence between your code and the lambda calculus, which means that it's relatively simple to prove program correctness. The language itself has been proven to be correct; i.e. no silent errors, memory corruption, etc. And the type system, while it feels incredibly restrictive at first, does catch about 90% of most programmer errors. The type system can even indicate programs which don't halt, which is really spiffy. (Certainly not all such programs, but it does catch some of them.)

There are a few issues with it, but overall it's definitely my favorite language.

floccinau
 
D

Deleted member 5324

Guest
Originally posted by floccinau:
My God man, why? Continuations are certainly useful, and neat to play with, but they're really icky on one level; a continuation is essentially a goto, only the point which you go to is not set, but variable. I just hate the things.

Continuations are a primitive that's amazingly useful to implement higher level abstractions easily.

Functions, green (user-level) threads, coroutines, generators, iterators, and numerous other higher level concepts are implementable easily (or at least clearly :)) with first-class continuations. I'm drawn to what's unique in programming languages -- the type system in ML drew me, and I realized how great it is. I'm drawn to the LISP macro system, but ML is keeping me for awhile, and doesn't show any sign of letting up :) First-class continuations are only in two mainstream languages that I know of: Scheme, and Standard ML. I'm looking forward to trying them out at some point.

And the type system, while it feels incredibly restrictive at first, does catch about 90% of most programmer errors.

Yes, it does feel restrictive at first, but I became used to it, I found the concepts in my head are so much more easily tranferred to code than in other languages I've used.

Exhaustiveness analysis is an excellent feature, too.

O'Caml is certainly my favorite language too :)

Jeremy
 
Originally posted by floccinau:
My God man, why?
Because having call-with-current-continuation (or whatever SML names it) gives you access to all kinds of groovy language features. How else to properly implement threads, for instance? I come to this from a Lisp/Scheme background, but I can't imagine that the SML call/cc is any less useful.

Why use a language without them?

(jfb)
 
[intro...]I don't know whether I should post this or not...[/intro]

Well, the semester's over, and I gotta say that SML is one of the better languages I've ever studied (not that I've studied that many languages in the past). It's a whole new approach to programming, and I clearly hate Java now. :D Well, that's a lie, I guess - I still like Java (I'll be using that in graphics next semester), but SML is really cool - it really does help you to write correct code.

As for first class continuations go... I kind of missed that lecture, so I'm still quite clueless in that area. ;) Well, I'll check out the lecture notes, and hope for the best. :D

hey, I was actually waiting for a mod to move this to Programmer's Symposium, but that hasn't happened yet, so I'll post this here and maybe it'll get locked/moved to the Programmer's Symposium (hopefully it'll get moved to there instead of getting locked, as it has a bit of content in it already).

-Huh
 
D

Deleted member 5324

Guest
Originally posted by Joon H. Huh:
Anyway, does anybody actually use SML as their primary programming language?

I use O'Caml whenever I can (which, given my currently-unemployed-and-just-programming-as-a-hobbie status, is all the time :)) At this point, I don't know how well I'd do using a language that didn't include the system-wide static typechecking, implementation hiding, and tight syntax checking of O'Caml.

Jeremy
 

BobTheFourth

Ars Praefectus
5,478
Subscriptor
I have mixed feeling about ML. On one hand, I think its the spawn of satan himself. I never thought I could spend hours debugging a 10 line program. On the other hand, it really is an interesting language, especially since EVERYTHING is recursive. If you want to understand how to do things recursively, this is the langauge to learn.

I never really put in the effort to really learn it though, I just learned enough to do the assignments. I don't think I'll ever use it for anything outside of school, but I'm probably an all around better computer engineer from having used it.

c|i
 
D

Deleted member 5324

Guest
Originally posted by connection|interrupted:
I have mixed feeling about ML. On one hand, I think its the spawn of satan himself. I never thought I could spend hours debugging a 10 line program.

Ah, you see, that's the thing. You didn't spend hours debugging a program, you spent hours taking bugs out of a code listing. That's the awesome part about ML -- in general, if it compiles, it runs. The problems you had with your code listing would've been bugs if the program had compiled, but at that point they would've been much harder to debug. Better to catch the bugs before the code compiles than after you've run it for hours, or after you've shipped it.

Jeremy
 

McMillan Y-4

Ars Scholae Palatinae
836
Ah, you see, that's the thing. You didn't spend hours debugging a program, you spent hours taking bugs out of a code listing. That's the awesome part about ML -- in general, if it compiles, it runs. The problems you had with your code listing would've been bugs if the program had compiled, but at that point they would've been much harder to debug. Better to catch the bugs before the code compiles than after you've run it for hours, or after you've shipped it.
Unfortunately I'm capable of writing SML that compile just fine, and still have bugs in it. I think SMLNJ really needs a symbolic debugger. Far more than it needs a new Compilation Manager.
 
D

Deleted member 5324

Guest
Originally posted by McMillan Y-4:
Unfortunately I'm capable of writing SML that compile just fine, and still have bugs in it. I think SMLNJ really needs a symbolic debugger. Far more than it needs a new Compilation Manager.

I'm fairly phobic of symbolic debuggers in *nix (much to my detriment) but I know O'Caml has a fairly powerful one, you might look into it.

Jeremy
 
Status
Not open for further replies.