Computer Science Canada Things I miss since learning O'Caml |
Author: | wtd [ Tue Aug 22, 2006 7:35 pm ] | ||||||||||||
Post subject: | Things I miss since learning O'Caml | ||||||||||||
I learned O'Caml, but I miss some things about Java/C++...
|
Author: | [Gandalf] [ Tue Aug 22, 2006 8:16 pm ] |
Post subject: | |
Lies, I say! No, but it's an interesting comparison. If only O'Caml wasn't so brain melting. |
Author: | wtd [ Tue Aug 22, 2006 9:22 pm ] |
Post subject: | |
[Gandalf] wrote: Lies, I say!
No, but it's an interesting comparison. If only O'Caml wasn't so brain melting. How so? |
Author: | OneOffDriveByPoster [ Wed Aug 23, 2006 8:30 pm ] | ||||
Post subject: | Re: Things I miss since learning O'Caml | ||||
wtd wrote: I miss control statements.
I liked having to create a variable, then assign to it within a control structure. Having control structures that return values just messes with my mind, and I don't like my programming languages trying to outsmart me. I should be the one in control.
Let's have something else...
|
Author: | md [ Wed Aug 23, 2006 9:42 pm ] |
Post subject: | |
Methinks people are missing the point... this was sarcastic... Though I do like the idea of return. Explicitly returning something is nice... what if I want to add one to bar, and do nothing else, but not return bar+1? This could be the case where code is commented out to test something else... |
Author: | [Gandalf] [ Wed Aug 23, 2006 11:17 pm ] |
Post subject: | |
Cornflake wrote: this was sarcastic...
Yes... wtd wrote: How so?
Mostly because my brain is frozen in imperative programming mode. It's a slow process to change. |
Author: | wtd [ Thu Aug 24, 2006 12:44 am ] |
Post subject: | |
Cornflake wrote: what if I want to add one to bar, and do nothing else, but not return bar+1? This could be the case where code is commented out to test something else...
You have two problems there. In one case, you're returning void. In another, you're returning int. O'Caml is statically-typed, so this is no good. The other problem is that you're counting on bar being mutable. Values in O'Caml are by default immutable. This leads to more optimization, and not less, by the way. |
Author: | wtd [ Thu Aug 24, 2006 12:46 am ] | ||
Post subject: | Re: Things I miss since learning O'Caml | ||
OneOffDriveByPoster wrote: Let's have something else...
There's that, but it doesn't scale well. And why have two different constructs for the same concept? Java is supposed to be about not reinventing the wheel, right? |
Author: | Cervantes [ Thu Aug 24, 2006 7:50 am ] |
Post subject: | |
It seems odd that if the ternary operator can return a value, why can't an if-construct? |
Author: | OneOffDriveByPoster [ Fri Aug 25, 2006 9:10 am ] | ||||
Post subject: | Re: Things I miss since learning O'Caml | ||||
wtd wrote: I miss getting away with incomplete conditionals.
O'Caml actually refuses to compile my code if I've not handled some possibility in my conditionals. It's incredibly frustrating. I just want my code to compile. I don't care if I've missed an obvious source of error. I'll find out about it when my code produces weird runtime errors. They make for interesting challenges.
|
Author: | wtd [ Fri Aug 25, 2006 10:14 am ] |
Post subject: | |
Thanks for pointing that out. |
Author: | rizzix [ Fri Aug 25, 2006 3:31 pm ] |
Post subject: | |
Cervantes wrote: It seems odd that if the ternary operator can return a value, why can't an if-construct?
If constructs are statements in Java, whereas the ternary operator is an expression. Unlike ruby blocks/statements in Java can not return values, unless they are defined to do so (and if they are, you must explictly return a value). |
Author: | wtd [ Fri Aug 25, 2006 3:39 pm ] |
Post subject: | |
rizzix wrote: Cervantes wrote: It seems odd that if the ternary operator can return a value, why can't an if-construct?
If constructs are statements in Java, whereas the ternary operator is an expression. Unlike ruby blocks/statements in Java can not return values, unless they are defined to do so (and if they are, you must explictly return a value). Oh, I think we're all pretty well aware that is how Java works. Cervantes' question was not "how" but rather "why?" |
Author: | Cervantes [ Fri Aug 25, 2006 3:43 pm ] |
Post subject: | |
Indeed. I understand that Java's if constructs are statements and not expressions. I'm just saying, y'know, it sucks. |
Author: | rizzix [ Fri Aug 25, 2006 3:43 pm ] |
Post subject: | |
Java likes to make a clear distinction between expressions and statements? gee.. |
Author: | wtd [ Fri Aug 25, 2006 3:46 pm ] |
Post subject: | |
An unnecessary dichotomy. Why is there a need for "statements" at all? Certainly expressions that return "unit" or something comparable provide all the same functionality. |
Author: | rizzix [ Fri Aug 25, 2006 3:52 pm ] |
Post subject: | |
It's more intuitive. In a natural language, you have words which compose clauses/phrases which compose statements which compose paragraphs, which finally composes an article. Similarly, in a strucured language (like C/Java) we have expressions which compose statements which compose blocks, which finally composes a program. |
Author: | Cervantes [ Fri Aug 25, 2006 4:04 pm ] |
Post subject: | |
Granted, statements might be a little more intuitive. But I think it's a pretty poor argument when you consider the power and flexibility that comes with embracing expressions over statements. |