7 ms·
I'm not sure about the "learn it as a first language" bit. x:=(1|2); y:=(7|8); (x,y) This stuff just doesn't seem intuitive to me. It's not verbose enough
by davidw 4y ago
I'm not sure about the "learn it as a first language" bit.
x:=(1|2); y:=(7|8); (x,y)
This stuff just doesn't seem intuitive to me. It's not verbose enough to be obvious to someone who doesn't know what's going on.
Looks interesting though; that's a really bright group of people. Be curious to see where their project ends up.
- tinco 4y agoI'll be the first to hate on C++, but the only reason C++ might be considered a "don't learn it as a first language" language, is because it's huge. It's got 40 years worth of baggage, and it's "standard" libraries are an absolute mess. Javascript has a super simple syntax, and it's standard libraries though sometimes a bit idiosyncratic are comparatively clean and pragmatic. If you just removed like 90% of C++'s useless standard library, and restricted the syntax to purely what's in Strousup's "Tour of C++" book, then I'm pretty sure that would be a pretty acceptable "learn it as a first language" language. Of course in that imaginary world C++ would also not have been deprecated by Rust.
- sicp-enjoyer 4y ago> 90% of C++'s useless standard library, The Python library is even larger and doesn't seem to be a barrier. If you know `std::vector`, `<<`, and `std::sort` it seems you're set to contribute to most code bases. > C++ would also not have been deprecated by Rust. That's an overstatement, to say the least.
- tinco 4y agoIn Python the standard library is fairly easily traversed and understood and if there's a better way of doing something it's usually linked I think. In C++ we have.. this.. https://en.cppreference.com/w/cpp/algorithm/transform_reduce https://en.cppreference.com/w/cpp/algorithm/transform_reduce
- Silhouette 4y agoPython's standard library includes many modules for specialised applications and yet it's surprisingly lacking in fundamental data structures and algorithms. Personally I think that's the wrong way round. Simple things like building dicts from different data structures or working with optional values that can be something or None just aren't there and you always seem to end up with some kind of utils.py full of hand-written functions to do these things that everyone writes again every time when they would have been either built into the syntax or a one-liner using the standard library in some other languages. I agree that the C++ example is (one reason) why modern C++ has jumped the shark.
- moloch-hai 4y agoThat example is not how C++ is used. It would not pass code review.
- xigoi 4y agoWhy is code that wouldn't pass code review part of the language documentation?
- moloch-hai 4y agoWhy are there falsehoods in Wikipedia?
- xigoi 4y agoBecause it's written by random people who may or may not know the topic well. How does that apply?
- bmitc 4y agoI know supposedly "harder to learn" languages (i.e., functional languages), but my god does that example and C++ look impenetrable.
- GuB-42 4y agoI don't think it is an overstatement to say that that imaginary world C++ would have been deprecated by Rust. C++ complexity is also its strength. Highly backward compatible, even with C, and multiparadigm. It has classes, but you don't have to use them, it has exceptions, but you don't have to use them, it has templates, lambdas, smart pointers,... and again, you don't have to use them, but they are here if you need them. Even the "deprecated" features of C++ (like most things related to raw pointers) are heavily used today, even in new projects, because they are useful. Strip 90% of "deprecated" C++ and what you get is essentially Rust, but worse because it still has its C baggage without the advantage of being mostly compatible with C.
- adastra22 4y agoI read the exact opposite. He's implying that real C++ has been depreciated by Rust, but that wouldn't be the case with imaginary-world C++. (Rust has not replaced C++ in the real world. Not even close.)
- sicp-enjoyer 4y agoHow much of that can be attributed to it not having as much time to attract cruft? See Haskell, a very minimal and carefully designed language with a heap of complex and contrary extensions.
- dagmx 4y agoPython as a language is smaller even if the library is larger. You can do many many things in Python without needing to know much other than working with dictionaries. In C++, doing a sort or a string search is an ordeal. So much of common programming requires so much cognitive overload. C++ is not an easy language. Not by a long shot.
- sicp-enjoyer 4y agoI absolutely agree, but this comment referred to the library size as a major burden.
- dagmx 4y agoAh fair. Though I do think the issue they meant is perhaps the C++‘s STL is not fleshed out enough to be as ergonomic and useful as Python. Python’s standard library is not without its faults but I’m always so frustrated that the C++ STL stops just short of providing many things, and when it does, it requires writing out so much verbiage.
- bibanez 4y agoIn my uni they still teach C++ as a first language, that's why the "don't learn it as a first language" got me confused. The core language is very useful for learning programming, it is actually very clean.
- Throwaway23459 4y agoMy lecturer in second year, > 20 years ago mind, said we are learning C, because C++ is C with an ugly object oriented graft on top.
- moloch-hai 4y agoYour lecturer did you a disservice; clearly he only knew C, and didn't want to learn any more. The more your C++ code resembles C, the worse it is.
- Throwaway23459 4y agoMaybe he only knew C as you say. I did C++ professionally for a while. Not properly, just updating models in derivatives trading systems. I remember reading 3 Scott Meyer books, the Effective Programming series, at the time, they were a tour de force. Loved that guy. I've lost track of everything since 11 or whenever they introduced move semantics. One day I might go back to it.
- moloch-hai 4y agoNowadays it's "rule of zero": compiler-generated constructors, destructor, assignments, compare. The members are of types smart enough on their own. Lambdas are generic now, and variadics work most places. Velocity has shot up. Fun, too.
- adastra22 4y agoI mean, C++ was my first language and I turned out fine (I think).
- tinco 4y agoIt was my first proper language too, if you discount what I did on my graphical calculator. Now I'm a Rubyist, heart and soul, make of that what you will.
- qayxc 4y ago> I'm not sure about the "learn it as a first language" bit. I think this is very subjective. Our minds have been "poisoned" - or rather trained over years - into a very specific way of thinking about expressions like in the example. A first programming language, however, assumes that the learner hasn't been preconditioned in any way into a certain paradigm. So just keeping the two rules in mind that 1) evaluation is strictly from left to right and 2) an expression evaluates to a sequence of zero or more values immediately makes sense of the example. Unfortunately it's incredibly hard to "reset" your mind into a state that doesn't know about variable assignments and thinking of variables as singular slots as is the case in Haskell and most other programming languages. That's why "intuition" is a very subjective thing - your intuition changes with knowledge and experience and both are hard to suppress.
- davidw 4y agoI get that to some degree, but that code doesn't look like something most people are exposed to, whereas 'x = 10' or something that says 'foreach' seems like it'd make sense with a minimum of explanation to a lot of people. x:=(1|2); y:=(7|8); (x,y) Doesn't look like any math I'm familiar with.
- jbritton 4y agoYou can think of the choice ( | ) as a generator function. X generates 1 then 2. Y generates 7 then 8. For x in [1,2]: For y in [7,8]: yield (x, y)
- deleted 4y ago[deleted]
- psyklic 4y agoYou could also write the example as a list comprehension, which essentially mimics set-builder notation in math, i.e. "The set of all pairs such that ..." [(x, y) for x in [1, 2] for y in [7, 8]] // Python (list comprehension) {(x, y) | x \in {1, 2}, y \in {7, 8}} // math (set-builder notation)
- jfengel 4y agoNo programming language is obvious to someone who doesn't know any programming. This particular example is even less clear because it's purely abstract; it literally doesn't do anything. If it were suit := (clubs | diamonds| hearts | spades); value:= (2..10 | J | Q | K | A); deck := card(suit, value) You would recognize it instantly.
- imtringued 4y agoYour objection does not make sense. The code is simply bad and you replaced it with better more verbose code.
- ww520 4y agoIt's the cartesian product. Think of it as a table with x labeling the top (x-axis) and y labeling the left side (y-axis). The cells of the table are the result of the product. x 1 2 y |-------------- 7 | (1,7) (2,7) 8 | (1,8) (2,8)
- bvxyigt 4y agoExcept, as the slides indicate, sequences of values are not sets. They are ordered. You can also, as they mention, refer to "y" in the definition of "x". This is like set union, but it is, again, sensitive to ordering of elements.
- cma 4y agoC++ versions for comparison, much less intuitive: https://stackoverflow.com/questions/29451291/cartesian-product-in-c https://stackoverflow.com/questions/29451291/cartesian-produ...
- Throwaway23459 4y agoHas it got currying? Partially applied functions passed around in folds and traverses are horribly difficult to read for beginners. Example: an Advent of Code solution posted in r/haskell for Day 10 this year, tell me how long it takes you to understand the function cycleStrengths. signalStrength cycle x = cycle \* x cycleGaps = [19, 40, 40, 40, 40, 40] cycleStrengths = foldr a (const []) cycleGaps . (\x -> (1, x)) where a n r (i, xs) = signalStrength m y : r (m, ys) where m = i + n ys@(y : _) = drop n xs From: https://www.reddit.com/r/haskell/comments/zhjg8m/advent_of_code_2022_day_10/ https://www.reddit.com/r/haskell/comments/zhjg8m/advent_of_c... Personally I love this headscratching stuff, but I would not ever dream of subjecting it upon a beginner programmer.
- justinhj 4y agoThat kind of code is sometimes easier to write than read… you build it up incrementally. On the other hand it’s easy to refactor this to make it readable. Is Haskell supposed to be an easy language for beginners? Is Verse? Not every language should be.
- Throwaway23459 4y ago> [Paraphrasing] Is Verse supposed to be an easy language for beginners ? Yes! Well that was the point of my comment. Maybe you have a different interpretation of 'Learnable as a first language' from the article, which is fine, not interested in arguing about that.
- justinhj 4y agoI guess that part of my comment could have benefited from reading the article, which I have done now. Oops.
- nurettin 4y agoI might be totally off, as I don't know any vercel. But the declarations look like "x can be 1 or 2, y can be 7 or 8, and let's declare a superposed tuple of these which could be any combination of the values". I don't see the point, but that's what I understand by reading raw syntax.
- TuringTest 4y agoThat's the usual way to read it, yes. The point is that you can then ask it e.g. to "find a tuple where x > y", and later expressions will be evaluated only for tuples that meet this condition. In logic programming it's known as the "generate and test" pattern, where you declare the tuple and the program logically generates all its possible values, and then tests each value for compliance. The runtime usually will ensure to make this in an efficient way. P.S. See the definition of the "amb" operator in typical logic programming languages: https://rosettacode.org/wiki/Amb https://rosettacode.org/wiki/Amb
- titzer 4y agoThat's a hard road to hoe if they're going to just do new syntax for no reason. It's just more explaining, boring and driving people away.
- dagw 4y agoI'm not sure about the "learn it as a first language" bit. My university taught Haskell as its intro language to math and science students, and the people who had the most problems where those who already knew a bit of programming. People for whom Haskell genuinely was their first introduction to a programming language on the whole had no problem getting it. I imagine this might be the same. The main downside with the approach was that when these people who had just learnt Haskell moved on to the next programming course, that was taught using Java, they had a really hard time understanding what was going on.