4 ms·
Pretty compelling, especially "Janet does not adhere to the ancient customs. CAR is called first. PROGN is called do. LAMBDA is fn, and SETQ is def." - a sign o
by IshKebab 5mo ago
Pretty compelling, especially "Janet does not adhere to the ancient customs. CAR is called first. PROGN is called do. LAMBDA is fn, and SETQ is def." - a sign of good sense for sure!
How fast is it?
Also my main objection to Lisps is still the horrible bracket syntax. Yes it's unambiguous and easy to parse, but it's HORRIBLE to read and edit. I wish this project had been a success (or something similar to it): https://readable.sourceforge.io/ https://readable.sourceforge.io/
Also I don't think static typing is really optional for me at this point.
- setopt 5mo ago> Pretty compelling, especially "Janet does not adhere to the ancient customs. CAR is called first. PROGN is called do. LAMBDA is fn, and SETQ is def." - a sign of good sense for sure! Just FYI, many of these are also done in Scheme and its derivative Racket. They kept lambda (but even Python did that), but progn -> begin, setq -> set!, car -> first, and so on. > Also my main objection to Lisps is still the horrible bracket syntax. Yes it's unambiguous and easy to parse, but it's HORRIBLE to read and edit. I have pretty mixed feelings at this point. I don’t mind it for normal programming, but when I do numerical programming (physics models, etc.) you often get extremely long and verbose expressions that are IMO difficult to parse compared to the math-like infix operator notation used in other languages.
- aeonik 5mo agoI'm starting to prefer the s expression syntax when dealing with tree structures like json. I wonder if we were raised on tree based algebra if math would be easier to do, or harder. Like, solve for x. (= (+ (* 2 x) 3) 11) (= (* 2 x) (- 11 3)) (= (* 2 x) 8) (= x (/ 8 2)) (= x 4) Though this isn't too bad. (= (+ (pow x 2) (pow y 2)) (pow r 2))
- setopt 5mo agoI definitely prefer s-exps over both xml and json myself too! Interesting question. Much of the difficulty does stem from mentally translating back and forth between conventional notation and s-exps too, since you can’t really avoid the standard notation when reading and writing math and physics papers. And current-day math and physics notation has been optimized to some extent for the infix notation; perhaps one would have invented more expressive higher-order functions or macros to denote s-exp math if that was what everyone used for centuries.
- veqq 5mo ago> perhaps one would have invented more expressive higher-order functions or macros to denote s-exp math if that was what everyone used for centuries. Have you ever looked into APL? It was made as a better notation for math over a decade before computers emerged.
- setopt 5mo agoI think also a lot of my objections could be worked around if one simply had a "math" macro that evaluates infix math notation as a DSL, similarly to how the CL "loop" macro does a DSL for iteration. Perhaps this exists already somewhere?
- veqq 5mo ago> exists already The helloworld of macros lets you do `(infix 1 + 2)`: (defmacro infix [a op b] ~(,op ,a ,b)) A useful one with precedence letting you to `(infix 2 + 4 * 5)`: (defmacro infix [& toks] (def prec {'+ 1 '- 1 '* 2 '/ 2 '% 2}) (var pos 0) (defn climb [min-p] (var left (toks pos)) (++ pos) (while (>= (get prec (get toks pos) -1) min-p) # nil/operand -> -1, stops the loop (def op (toks pos)) (++ pos) (set left ~(,op ,left ,(climb (inc (prec op)))))) # inc => left-associative left) (climb 0)) But ultimately, APL notation is best: https://git.sr.ht/~subsetpark/jnj https://git.sr.ht/~subsetpark/jnj
- xigoi 5mo ago> Perhaps this exists already somewhere? https://janet-lang.org/spork/api/infix.html https://janet-lang.org/spork/api/infix.html
- krupan 5mo agoIf you ever used an RPN calculator then this is very familiar
- deleted 5mo ago[deleted]
- graemep 5mo agoSyntax is not that important to me. I prefer Python style indentation, but its really not that important - its just something to get used to for me. Is static typing that important for a scripting language? From the intro to the book: > And to be clear, I’m not going to try to convince you to bet your next startup on Janet, or even to use it in any sort of production setting. But I think it’s an excellent language for exploratory programming, scripting, and fun side projects.
- IshKebab 5mo ago> Is static typing that important for a scripting language? Yes. Firstly, static types are useful for even tiny programs, like 100 lines. Secondly is "scripting language" really a thing? There's nothing fundamentally different about a "scripting language" to a non-scripting language. Look at Javascript - that even has "script" in the name! - but clearly Typescript is an enormous improvement on it.
- Capricorn2481 5mo ago> Look at Javascript - that even has "script" in the name! Look at Java, it has nothing to do with coffee! My understanding is a script does two things 1) It can be interpreted. Even if it has some kind of JIT or bytecode step, it can be run as soon as file changes are made. 2) It's one or several informally wired together files for small tasks. A small task meaning you could patch it live without being worried about breaking something, because you can keep it all in your head. It's a narrower definition of a "program." At that level of programming, terseness becomes an asset rather than a liability, and that's why "scripting languages" tend to be dogged on in larger programs.
- e12e 5mo agoAre you aware of: https://docs.racket-lang.org/sweet/index.html https://docs.racket-lang.org/sweet/index.html
- xigoi 5mo ago> Also my main objection to Lisps is still the horrible bracket syntax. Yes it's unambiguous and easy to parse, but it's HORRIBLE to read and edit. I use Parinfer, which allows me to edit Janet as if it was an indentation-based language.
- IshKebab 5mo agoYeah I mean I guess if you have to use that syntax, it's nice to have a better editor for it. But IMO the existence of that tool clearly demonstrates that the syntax is pretty bad.
- imtringued 5mo agoMost editors manage your indentation, parentheses and braces for you. Not sure how that is a unique marker for lisp style languages.
- adrian_b 5mo agoAll C-derived languages (e.g. Java and Rust) have a bad syntax, with tons of superfluous parentheses and many other superfluous tokens, like semicolons or commas. This normally matters very little, because a good editor will always insert a complete template whenever you type something like "if", "for", "while" etc. Most programmers are blind to the syntax defects with which they are accustomed and they notice only the syntax defects with which they are unfamiliar. I would prefer a language with a good syntax, but unfortunately which programming languages have survived in widespread use has a poor correlation with the technical qualities of a language and especially a really negligible correlation with how good its syntax was.
- adrian_b 5mo agoThere are too many HN readers who downvote the comments that state real facts about which they are not aware, instead of bothering to investigate and learn something new for them. What I have written above about the C-derived languages is a fact, not a personal opinion. Anyone who downvoted it has just demonstrated ignorance about programming languages. Too many modern programmers are familiar only with languages derived from "C", which have retained the bad syntax of C, despite criticizing C for unsafety or other such properties, and they do not know anything, or they know only incorrect myths, about the many other programming languages that have existed, and which frequently had certain features that were superior to any of the currently popular languages. In another comment in this thread I have given a couple of typical program structures of the C programming language, which require a double number of syntactic tokens in comparison with well designed older programming languages, such as ALGOL 68 (which has been the source of several C features, but even some of those have been dumbed down a lot in comparison with the original, e.g. "union").
- adrian_b 5mo agoActually not all those are ancient customs, and not all that Janet uses is newer. In the first description of the language LISP, from March 1959 (AIM-008), John McCarthy had used the names "first" and "rest", instead of what later will be called "CAR" and "CDR". The names of "CAR" and "CDR" appear to have come from the students who worked at the practical implementation of the LISP interpreter on an IBM 704, and unfortunately we have remained stuck with them, like also with other features that were intended only for a temporary use, until being replaced in the "final version" (which was abandoned).
- zelphirkalt 5mo agoOut of those renames, I agree with car->first and progn->do. setq is ugly, but I think using def is maybe questionable. lambda I would have just kept the same.
- ux266478 5mo ago> How fast is it? Roughly as fast as puc-rio Lua. It won't blow your socks off, but it's more than respectable.
- tmtvl 5mo agoAll programming languages have horrible syntax (except maybe Forth). Some examples: Statements are terminated by either a dedicated graphical character, in which case it's easy to forget the character and have a problem, or by a newline (or maybe a different white space character, but I haven't encountered that yet) in which case decent formatting of code may require a dedicated graphical character to indicate that the newline DOESN'T terminate the statement, in which case we have the same problem. Having newline-terminated statements without continuation character would be consistent, but would hamper readability because identifiers would need to be strictly limited in length to keep certain lines from exceeding available screen space (or alternatively readability would suffer from lines only being partially readable). And that's before getting into the weeds of how mathematical notation is tricky (most people have learned infix notation at maths class in school, so they mightn't appreciate how horrible it is), how different types of brackets (round, square, curly) can have inconsistent semantics, the downsides to the various ways of indicating lexical blocks (brackets, white space, keywords,...), et cetera. The ideal programming language would probably be one which allows switching between different syntaxes based on what works best for the user (for example, someone could write code in S-expressions, another person could have that code automatically translated into SRFI-119 Wisp expressions and work with it like that, a third person could then have it rendered into something more Lua-like,...). Which is something I think the Racket people are working on, but I may be mistaken.
- packetlost 5mo agoIt's a scripting language, so it's not going to compete with anything compiled or JITed, but it has a pretty efficient threaded bytecode interpreter (that is almost more interesting than the language itself!). It's certainly good enough for most situations where you would reach for a scripting language.
- IshKebab 5mo agoAoT/JIT compilation is a property of the implementation, not the language. It would be good to know order of magnitude anyway. Like, are we talking Ruby/Python level, etc.
- veqq 5mo agoIn my tests, it's 5-10x Python for long running things (about 30% slower than Fennel on LuaJit) but for small things, because you can easily shift work to compile time, it beats normal Go: https://codeberg.org/veqq/verse-reader#performance https://codeberg.org/veqq/verse-reader#performance
- packetlost 5mo agoThere’s only one implementation so there isn’t a meaningful distinction here, but sure. It’s faster than Python and Ruby, about as fast as non-JIT Lua.