4 ms·
While I like Janet, and find it to be a lovely little language; I think it's important to note that it lacks lists and cons cells, and so as a result some peopl
by dleslie 3y ago
While I like Janet, and find it to be a lovely little language; I think it's important to note that it lacks lists and cons cells, and so as a result some people don't label it a lisp, and programming in it is unlike other lisp languages. It's similar, because the syntax is similar and the macros and various forms are lifted straight from lisps; but the feel of programming in it is very much like programming in C, and I find it's less like Scheme or Common Lisp.
Because it's not built around linked lists, the core type most encountered for lists of data is arrays and tuples. Neither is conducive to efficiently removing elements mid-set, or composing two sets, or interleaving two sets, or other operations that require reordering, replacing, adding or removing elements in the set. When I'm writing code in lisp I don't think about that overhead much, because for linked lists it's not an issue.
- cnity 3y ago> Neither is conducive to efficiently removing elements mid-set, or composing two sets, or interleaving two sets, or other operations that require reordering, replacing, adding or removing elements in the set Read this: https://isocpp.org/blog/2014/06/stroustrup-lists https://isocpp.org/blog/2014/06/stroustrup-lists
- dleslie 3y agoThat's based around a contrived problem that was posed to him: > Insert a sequence of random integers into a sorted sequence, then remove those elements one by one as determined by a random sequece of positions: Do you use a vector (a contiguously allocated sequence of elements) or a linked list? The key is that the sequence is sorted; and is kept sorted throughout the insertion process.
- TylerE 3y agoFeature not a big in my book. A linked list is almost never the right answer. Certainly shouldn't be the default.
- hajile 3y ago> A linked list is almost never the right answer. And yet a subset of the linked list called a tree is usually the right answer to problems.
- TylerE 3y agobecause it avoids all the pathological worse case performance unless you get insanely unlucky with the order the data is inserted... and even then you can do a rebalance if you're that concerned about it.
- dleslie 3y agoIt depends on how you approach solving problems, and what the problem is. In the contrived example, a linked list is clearly a terrible option for manipulating a sorted set of integers. Modern computers can slice and dice contiguous integers with vectorized routines, and those benefits are lost with linked lists that are storing their data haphazardly across the heap. If your problem space is best defined with contiguously-stored numbers, then for sure, don't use linked lists. Most lisps will happily provide you with vectors and arrays for these use cases.