2 ms·
I would say that if you're interested, go for it. My complaints about Janet are not too big. I feel like there are many ways to do some things, and they are al
by matvore 5y ago
I would say that if you're interested, go for it.
My complaints about Janet are not too big. I feel like there are many ways to do some things, and they are all basically the same. Most of this excessive flexibility is inherited from Clojure.
1. It's never clear whether I need `cond` or can get by with `case` until I've waffled around a bit
2. I don't know whether to choose `if`, `and`, or `when`, for conditionals, because there are many times when all three would work. Also, if the condition expression is trivially negated (e.g. change '=' to '!=') then even `or` would work, making 4 choices.
3. It's hard to choose between `->` vs. manually-nested expressions.
EDIT: formatting
- actuallyalys 5y agoI'm pretty experienced with Clojure and here are my takes on those: 1. The Janet docs suggest `cond` as a replacement for if-if-else-else chains in other languages and `case` for `switch`-`case` blocks. That's a pretty good rule, although maybe you've already encountered that explanation? My main rule of thumb is that if the important value is "enum-y", representing a particular kind of thing or state, try `case`. If not, use `cond`. Neither Janet nor Clojure have enums (although you might be able to hack them in through macros or interop), so keywords usually serve that role. 2. I would prefer `when` to `if` because it's usually clearer what's going on. I usually don't use `and` in place of `if`. The trivial negation problem is an issue in basically any programming language that has `and`, `or`, and `not`, but it does add more options. Whether to use `and` or the equivalent `or`, I think your first instinct is often best. 3. I tend to favor threading macros (`->` and `->>`) when something is three or more functions nested and manually nested expressions for the rest. For a total beginner, I would actually suggest forgetting about the more specialized options until you're comfortable. In other words, just use `cond`, `if`, and manual nesting. (Obviously still use `and` within the branches of `cond` or `if`.)
- matvore 5y agoThanks for the tips. I will try to keep these in mind so I can stop thinking so much about trivialities. When I was using Java in my day job, I toyed with Clojure a bit and it was a pleasure. My favorite features were protocols and multi-arity functions.
- saikyun 5y agoThis is solid advice. :)