4 ms·
Here's a data point... I haven't been converted yet, but I have found a series on youtube which I feel will likely get me there https://www.youtube.com/watch?v
by mikewarot 5y ago
Here's a data point... I haven't been converted yet, but I have found a series on youtube which I feel will likely get me there
https://www.youtube.com/watch?v=Vgu82wiiZ90 https://www.youtube.com/watch?v=Vgu82wiiZ90
Observations:
1> The syntax is strange, I'm not sure it needs to be, a list of parameters then the return type, with none of the usual commas and parens, it's like someone heard a critique of lisp, and went too far the other way. It's almost as bad as Forth
2> lazy evaluation as a feature? ok, I guess. Is there somewhere else that over-eager evaluation happens? (like in Metamine, where you can do a super fancy equals, and if any of the terms change, the whole thing is re-evaluated, like cells in a spreadsheet) That would balance it out
3> Everything is an expression - this is the worst part of C ever, and it's being called a feature
4> Invariants as good - this is the worst part of python, and it's being called a feature
5> procedural code is banned completely - yeah, this likely breaks a lot of brains, but I'm willing to let it slide if it works in the end
6> definitions of functions being conditional, that one is also a brain breaker... in the normal world, you define a function once, and forever... the 3 different styles of spreading out/pattern matching the inputs is a bit of a hill to climb
7> having to worry about tail recursion instead of regular recursion, it's the metaphorical equivalent of manual memory management, it ads mental complexity that the programmer really shouldn't have to deal with.
That's as far as I've gone along this phase change... I'm pretty good at keeping opposing views both straight in my head, so maybe I'll be one of the few this doesn't break? Who knows.
Aside/Tangent - Perhaps the difficulties being encountered are why John McCarthy wanted to keep S expressions hidden under the hood in his unrealized programming language.
- themulticaster 5y agoI don't want to diminish your first impressions, however I think you might have misunderstood one or two points in that video. Perhaps I can clarify: Regarding 3/"everything is an expression": C does explicitly not have this property, it has statements and expressions. The typical example to illustrate this point is the lack of a true "if expression" in C. [1] Given the following C code: int x; if (a > 5) { x = 1; } else { x = 2; } The value x is only assigned once, so it would be nice to express this using const. We can achieve this using the ternary operator, but that only works if the if statement is simple enough. In Rust on the other hand, ifs are true expressions and "return" values, allowing you to write the statement above like this: (Syntax might be slightly incorrect as I'm writing this without a compiler at hand) let x = if a < 5 { return 1 } else { return 2 }; From what I'm observing the (functional programming) idea of "everything is an expression" is well-received and also included in recent imperative languages such as Rust. Regarding 4: Do you mean immutability instead of invariants? I'm not quite sure what you are referring to in the context of Python. Regarding 7: This was mentioned somewhere else as well, but in a functional programming language you don't have to worry about the compiler recognizing and optimizing tail recursion. The only exception are pathological (extremely and obviously inefficient) function definitions, for example functions that try sum an infinite list of integers and don't terminate or functions that reverse a long list. [1] Terminology: "if" in C is a statement, and the ternary operator (a?b:c) is an expression similar to "if", but there is no true "if" expression.
- mikewarot 5y agoRe: 3 - I was referring to (a?b:c), which struck me, as a pascal programmer, with horror. ;-) Re: 4 - Immutable strings is the python oddity to which I referred Re: 7 - The video (#4) in the series seemed to indicate that it was almost a requirement that any recursion be a tail recursion.
- steveklabnik 5y ago(You don't use return there, but otherwise, you're correct about the Rust, yes. return would return from the function, not assign the value to x.)
- themulticaster 5y agoWell, this is embarrassing. I'm using a small Rust example to make a point about C oddities, and then a Rust Core team member points out a syntax error in my example! In my defense, I'd say the return keyword - combined with the different semicolon rules - is one of the more confusing and subtle syntactic differences when learning Rust from a C/C++ background. After a few weeks of programming C++ I always use return more often than necessary.
- steveklabnik 5y agoOh absolutely! If you haven’t worked with expression-based languages before, it’s a big mental shift. In my experience it’s harder to come back to one that isn’t after you’ve done things this way for a while. There’s an adjustment period for sure.