Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Janet language is seriously good for scripting.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
crocket
Guru
Guru


Joined: 29 Apr 2017
Posts: 558

PostPosted: Sun Jan 05, 2020 3:18 pm    Post subject: Janet language is seriously good for scripting. Reply with quote

Making an ebuild for janet language was easy, It is small. It takes very little time to compile it. It launches super fast.
Creating an eclass for janet modules was super easy.
I already uploaded dev-janet/process::crocket-overlay and dev-janet/sh::crocket-overlay.

Deployment is seriously easy with janet. I don't know much about the langauge, but its runtime characteristics and the ease of deployment make it a serious consideration for scripting.

Give dev-lang/janet::crocket-overlay a try. I'm serious.
Back to top
View user's profile Send private message
lefsha
Veteran
Veteran


Joined: 30 Aug 2004
Posts: 1234
Location: Burgas, Bulgaria

PostPosted: Tue Jan 07, 2020 9:40 pm    Post subject: Reply with quote

Yet another LISP (brackets) style language?

Do you know why none of them survived ?
Because the source code of ANY program is here for a human reader,
not compiler/CPU. And it's quite hard to read programs with brackets
and decrypt the context of each unit.

That is exact the reason, why shitty python has survived, but perl didn't.

I wonder why any author of yet another C killer is not aware of such a simple
bit of information.

P.S. I miss a proper console scripting language to replace bash/sh.
Bash is quite terrible already because one can't use spaces as much as one wants.
Despite all CPUs are made for math, bash is most terrible language in that area.

Still Janet has no place to replace anything we use or have to.

I'll be glad to see either python and/or bash killer.
Unfortunately that won't happen any time soon.
_________________
Lefsha
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Tue Jan 07, 2020 11:18 pm    Post subject: Reply with quote

lefsha wrote:
P.S. I miss a proper console scripting language to replace bash/sh.
Bash is quite terrible already because one can't use spaces as much as one wants.
Despite all CPUs are made for math, bash is most terrible language in that area.

Try Perl. You'll find version 30 is already installed on your machine and, unlike Python 2.7, quite indispensible.
Back to top
View user's profile Send private message
crocket
Guru
Guru


Joined: 29 Apr 2017
Posts: 558

PostPosted: Tue Jan 07, 2020 11:35 pm    Post subject: Reply with quote

Clojure survived and established its niche. I think janet and babashka(a clojure interpreter) can establish their own niches.

With syntax highlighting, reading lisp is okay. And, proper indentation conveys context in lisp.
If you have some familiarity with lisp, proper indentation is second-nature to you. There is no need to decrypt a properly indented lisp code. After a day or two, parentheses disappear in your mind.

It's easy to hate lisp when you have no familiarity with it. If you ever tried one seriously for a while, you might change your mind.
I know how to write clojure, janet, python, POSIX shell, some bash, and haskell. Parentheses are not bad once you get familiar with any lisp language, and they can be sometimes helpful in aiding human comprehension.
Once you get past your feelings about parentheses, the language itself is good. Unlike other lisp languages, clojure and janet use brackets which aid reading even further.

But, it ultimately comes down to subjective feelings. Some people like parentheses. Some people hate them.

And, it's not going to replace shell or python. Each language has its own niche. No language is going to fill the entire use cases.
Back to top
View user's profile Send private message
lefsha
Veteran
Veteran


Joined: 30 Aug 2004
Posts: 1234
Location: Burgas, Bulgaria

PostPosted: Wed Jan 08, 2020 12:01 am    Post subject: Reply with quote

Ant P. wrote:
Try Perl.


I totally agree. The only minor issue - it's dead.

In a community it doesn't matter what you use at home when you shut off the light.
As mentioned is the message above - some languages we have to use.
Whether we like it or not. If you use a special language there won't be upate,
bug fix for your program, because there is no audience. No one interested.

I would be happy if portage has been written in perl, but we all know it's not the case.

Long ago perl was at the same place where python is today. That time is gone.
Why people walked away? - Exactly because what has been said above.
_________________
Lefsha
Back to top
View user's profile Send private message
lefsha
Veteran
Veteran


Joined: 30 Aug 2004
Posts: 1234
Location: Burgas, Bulgaria

PostPosted: Wed Jan 08, 2020 1:07 am    Post subject: Reply with quote

crocket wrote:
Clojure survived and established its niche.


As I said there are things in life we do, because we have to and there are things we do because we love to.
People use Clojure, because they have to learn programming at school.

From practical point of view there is no place for such languages in the industry.

There are 2 groups of languages - very fast to run and very fast to write.
People ready to pay for speed with complexity and they are ready to pay for simplicity
with performance. C is the first, python is the second. Of course there are more
languages in each group. PHP is like python for web.

Clojure is nice to learn math abstracts and to train the brain, but not to work on anything.
There are no use cases for Clojure.

The program will be slow and will take long time to be written.
After all there will be no one who will agree to maintain it over time.
There are NO people who know that language. You can't hire them.

crocket wrote:
With syntax highlighting, reading lisp is okay. And, proper indentation conveys context in lisp.
If you have some familiarity with lisp, proper indentation is second-nature to you. There is no need to decrypt a properly indented lisp code. After a day or two, parentheses disappear in your mind.

It's easy to hate lisp when you have no familiarity with it. If you ever tried one seriously for a while, you might change your mind.


It's a common observation, that parentheses are the problem, but frankly not only them.
The most difficult part is absence of any other symbols which tell me what it's all about.

Take a look at the simple snippet from examples:

Code:
(defn sum3
  "Solve the 3SUM problem in O(n^2) time."
  [s]
  (def tab @{})
  (def solutions @{})
  (def len (length s))
  (for k 0 len
    (put tab (s k) k))
  (for i 0 len
    (for j 0 len
      (def k (get tab (- 0 (s i) (s j))))
      (when (and k (not= k i) (not= k j) (not= i j))
        (put solutions {i true j true k true} true))))
(map keys (keys solutions)))


It's exactly like with python enough to forget to add a single parenthesis
and no one can understand what the code is about and where is a mistake.

Every single human has a problem to say exactly how many 1111111111
or 0000000000 or )))))))))))) is written in one line. You have to count them pointing
your finger to each symbol. More than 3 of the same characters in a row is a problem.

That is why smart people came to the idea to represent numbers
in that way: 1,000,000.02

If I think about my program I don't wish to count parentheses at the same time.

LISP make it worse. I need to check that those 15 brackets are matching
another 15 spread in the code above. Why the heck I should care about it???

A use case? - Try randomly remove a single parenthesis from your program
and then count how much time you need to find and fix the mistake.
It will take longer, than you think it will.

First 15 min it works well. But every day 8 hours 5-6 days a week...

Why the hell I have 10 kernels under hood to count brackets myself?

PC cannot make it. It's the program logic behind it.
It's like python cannot count idents. It's only up to the author to put one.

It is significantly easier to count idents vertically, than parentheses horizontally.
Putting each parenthesis on a single line will make a code even worse.

Therefore the idea with tabs was not quite stupid, but still bad.
C,C++ is better off with ; and multiple other symbols.

A good language has to be brief, but explicit!

What is: "for k 0 len" how to interpret it???
Is that one of:

for(int k=0; k<len; k++)
for(int k=0; k>len; k--)
for(int k=0; k<=len; k++)
for(; k<=0; k+=len)
for(; k>0; k-=len)

or many other options?

Why should I spent my time trying to understand whether the written code is doing what I think or something else?
Where is exactly the benefit to write "for k 0 len" instead of "for(int k=0; k<len; k++)"
I see none! The second one is explicit and crystal clear. There is no doubt what is going on.
And... it does use the parentheses, wow!


Being too brief is a very bad idea in programming!

It is as bad as dynamic assignment in python.


a = 1
a = "string"

is it a mistake or was it on purpose???
Think you aren't the original author.
Think it's your code 10 years back.


In any piece of code there should be no double interpretation possible.
That is why Rust, which is too verbose some time.
That is why variable/const in not mutable by default.
Everything has to be explicit!

Making mistakes is the normality and the language has to accommodate that.

crocket wrote:
But, it ultimately comes down to subjective feelings. Some people like parentheses. Some people hate them.


Every one or earth hate ))))))))))) and no one has or should have a problem with z = f(x,y)

It's not about brackets. It's about what they are for.

crocket wrote:
No language is going to fill the entire use cases.


It depends on acceptance of explicity level of a language you ready to tolerate.

in some circumstances a=1 is a just literal and therefore a string or a char
in others it is an int or may be even a float or a complex number...
In physics it can be a 1 m, 1 s, 1K or 1 kg and there is a huge difference
between 1m and 1kg for a physicist. making 1+1 is no error, but making
1m + 1kg is a error.

Each time the same text should be interpreted differently and the example above is most simple
problem description of such an issue.

People tend to be brief and use slang if not leaving a certain area and if every one is on the same page.

Ask 10 people with different background what is CVD and all of them tell you something different.

Theoretically one can create different flavors for the same language.
Let say web, shell, system, business app etc.
Then the same statement like a=1 will be understood differently.
To get out of those frames one need to be more explicit
like for a shell a=1.00 if one means a number etc.
_________________
Lefsha
Back to top
View user's profile Send private message
crocket
Guru
Guru


Joined: 29 Apr 2017
Posts: 558

PostPosted: Wed Jan 08, 2020 6:53 am    Post subject: Reply with quote

You have quite an absolutistic and moralistic view on programming. Although you say clojure has no place in the industry, it is still being used in some niches. So, what you are saying is not absolute truth.

If you use emacs paredit mode, you don't have to count parentheses. paredit mode automatically adds and removes parentheses although you can make a mistake from time to time.
It's not so difficult to spot missing parentheses because emacs shows matching parentheses. Fixing missing parentheses is aided by emacs.

I get that you don't like clojure. But, that doesn't mean everyone hates it. Perhaps, someone else forced you to use clojure. I wasn't forced to use it. I learned it on my volition.

That said, if you knew any scripting language better than a lisp, perl, and python, I would be interested.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Wed Jan 08, 2020 10:11 am    Post subject: Reply with quote

lefsha wrote:
I would be happy if portage has been written in perl, but we all know it's not the case.

Given that portage is an unmaintainable trash fire to the point where people find it easier to rewrite a package manager from scratch than add sorely needed features to it, maybe it's for the best Perl's name isn't associated with it. So much for Python being maintainable.
Back to top
View user's profile Send private message
crocket
Guru
Guru


Joined: 29 Apr 2017
Posts: 558

PostPosted: Wed Jan 08, 2020 11:36 am    Post subject: Reply with quote

Ok, with a talk about portage, this thread is about to get derailed. I recommend that you have a look at janet language. It's small and simple. It's even simpler and smaller than python.

I don't know whether it will be supported in the long term, but it is definitely a fun language to consider.
Back to top
View user's profile Send private message
lefsha
Veteran
Veteran


Joined: 30 Aug 2004
Posts: 1234
Location: Burgas, Bulgaria

PostPosted: Wed Jan 08, 2020 8:06 pm    Post subject: Reply with quote

Ant P. wrote:
Given that portage is an unmaintainable trash fire


Wow. You have blown up my mind. May I ask you a question? - Is it only you are thinking that way
or there are others gentoo users around with a similar attitude?

Well, don't get me wrong. I personally don't mind such a harsh critics, but if I try to express my
own concern about the certain Gentoo's... features... I am always getting a high pressure
critics on the level - "you don't understand a thing". No one seems to be ready even to discuss
the reasoning of such a thinking. And now I see you with your statement...

Btw. That post looks like off-topic for me an belongs to Chat or Other things of Gentoo.
But I see no Mod is moving it away...

It looks like there are people, who are allowed to do anything without consequences...
If you talk to them, nobody touches you either... :D
_________________
Lefsha
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Wed Jan 08, 2020 9:38 pm    Post subject: Reply with quote

Moved from Portage & Programming to Gentoo Chat. More of a general discussion topic, so this seems like a better location.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
lefsha
Veteran
Veteran


Joined: 30 Aug 2004
Posts: 1234
Location: Burgas, Bulgaria

PostPosted: Wed Jan 08, 2020 10:38 pm    Post subject: Reply with quote

crocket wrote:
You have quite an absolutistic and moralistic view on programming.


Nope. I do have quite pragmatic view on programming. If writing a program for personal use
or for free any langauge you know will do. If there are strict technical or biz requirements
the language choice is pretty motivated. You won't write OS in Basic. If you will try, then people
around will understand very soon, that you aren't qualified.

crocket wrote:
Although you say clojure has no place in the industry, it is still being used in


Just a simple question. What makes Clojure better, than any other language which is commonly
used for a given purpose?

We all know, that Linux is written in C. Would be a Clojure version of it any better?
Would it be written faster with less errors?

If you can't find anything where a given language beats other languages, then I see no point to use it.

Another example. Do C or C++ have disadvantages? - Yes they do.
I would even say, from today perspective both are quite terrible languages with too many
problems to the level NOGO.

Are there newer languages which could replace those 2 for any purpose they have been used?
Nope. They aren't. To my taste only Rust is getting close. May be some day it will replace them.

But here we face the same issue once again. User base. You have a company and you wish
to use for your project Clojure. The reason is not important now, because we don't know
what has to be written. We can assume Clojure is quite good for that very special unknown task.

Where would you find 3,5 or 10+ programmers? In Europe in some countries it is hard to find
a programmer for commonly used languages, not only for Clojure.

We go one step forward. There is a candidate with Clojure experience. That guy if you need him,
will ask you double salary. So you not only need to justify the use of Clojure, but also answer
the question why it is 2 times better, than anything else?

OK. Your company name starts with 'G' and ends with 'e'. You have a deep pocket.
But that guy you hired left your company for another one which starts with F.

Where would you find a replacement? Or if you need to expand, where would you find
10+ people you need?

It's a simple business approach - continuity. You can't each time rewrite your product
from scratch with new language, because of people you hired.

The language itself has no direct impact on that issue.


crocket wrote:
So, what you are saying is not absolute truth.


What I am saying IS absolute truth. There is no one among humans who is able argue on what has been said.
It's based on pure logic and life experience. Any contradiction will violate either the logic or the life experience
or both.

There is always a purpose, for which ANY language is suitable. A learning purpose.

The only problem with humans is that they get biased due to their experience and social environment.

Kids grown in Muslim countries normally becoming Muslims too. The same is valid for any country and religion.
It is not 100% rule, but very high probability.

Those who learned Clojure at school will believe it's a great language and is best suited for anything.

Few people around pretty well aware about such a bias. They don't believe in anything. They do the measurements.

Any program can be benchmarked from very different perspective. Time to write, time to execute, number of bugs,
number of lines. etc etc.

As soon as you provide any reference, that language A is better, than language B in terms of what ever measure
I will believe you and agree, that if that measure is most important, then lang. A is better suited, than lang B
for the purpose C.

Unfortunately we all know, that won't happen and no one will provide me such information.




crocket wrote:
If you use emacs paredit mode, you don't have to count parentheses. paredit mode automatically adds and removes parentheses although you can make a mistake from time to time.


Not everyone here is using emacs. If you insist using emacs for Clojure, then you will reduce the potential number of users.
Not sure, if that should be your intention.

No one is able predict what editor will be used for finding bugs in old Clojure code 10+ years later after it has been written.

crocket wrote:
It's not so difficult to spot missing parentheses because emacs shows matching parentheses. Fixing missing parentheses is aided by emacs.


In a simple case - yes. In a complex case - no. I am not an expert in Clojure, but I am pretty sure one can create a valid
code where parentheses arrangement is slightly different. Examples should be available on internet. People are smart for such things.

Python is very well know for that. It's terribly simple to play with tabs and create each time valid code with totally different result.
That is the reason why python is a bad language. So bad, that it would be better we had no such a language at all.

And again the parentheses are not the real issue of any language. But the context depended statements are.
If I read a program I should not guess anything. Neither there should be some magic. Python uses magic a lot.


At the end if we consider the language beauty as a important component or the reason to use it, then Haskell
looks even more beautiful. And even less people know it and use it.

It's totally irrelevant whether I personally like or dislike any particular language.
The relevant things are
- huge user base,
- well developed instruments portfolio,
- as many as possible libraries for each purpose
- and high number of useful programs

If that is given, then a language can be considered for any purpose.



crocket wrote:
I get that you don't like clojure. But, that doesn't mean everyone hates it. Perhaps, someone else forced you to use clojure. I wasn't forced to use it. I learned it on my volition.


There is only 1 language or the book about that language I did hate.
At school I had to learn it. It was at times, where we haven't seen any computer by eyes and used a piece of paper instead.
The whole concept - a program was totally absent in our minds. The similar feelings get those who start to study quantum physics.
The best and totally irrational concept there was the Schroedinger Equation.
Anyone who is reading about that for the first time is getting a clueless feeling.
A programming comparing to quantum physics looks like a toy for kids.


What actually does make a language a language?
1. The syntax
2. The compiler
3. Toolchain.

I am saying, that 2 and 3 aren't better than with any other language and therefore people won't learn 1, because it's not
intuitive. Any one can accommodate to it. But if the resulting program is slower and there are no other benefits, then
what is the point?


crocket wrote:
That said, if you knew any scripting language better than a lisp, perl, and python, I would be interested.


Frankly, I do not like scripting languages at all. The CPU should run the binary code as fast as possible using as less
resources as possible. I am not able to understand why something which should take ms takes minutes.
I can not understand, why the program in 90x which was about 40-60kb in size did something what today is done by 1Gb program.
I can not understand, why QNX on 2 diskettes each 1.4Mb of size could start OS, DE, Browser and had a lot of tools.
And to achieve the same now I need at least 5-10Gb disk space.

The transistor size is getting smaller along the exponent and number of transistors reached few billions, but the smart
software is capable to kill the performance and bring it back to the level we had in 90x...

Obviously some day where nothing will help people will start to use Clojure to compensate what had been achieved by Intel and Co...
_________________
Lefsha
Back to top
View user's profile Send private message
CasperVector
Apprentice
Apprentice


Joined: 03 Apr 2012
Posts: 156

PostPosted: Thu Jan 09, 2020 1:38 am    Post subject: Reply with quote

lefsha wrote:
There are 2 groups of languages - very fast to run and very fast to write.

Paul Graham has a hypothesis similar to this, and yet reaches a conclusion completely different from yours.
It may also be instructive to know that the Chez Scheme compiler often produces executables that are even faster than workalikes written in C.
(And yet it has a codebase more than one order of magnitude smaller than that of GCC, and self-compiles in seconds while GCC requires thousands of seconds.)
_________________
My current OpenPGP key:
RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C
Back to top
View user's profile Send private message
crocket
Guru
Guru


Joined: 29 Apr 2017
Posts: 558

PostPosted: Fri Jan 17, 2020 2:12 pm    Post subject: Reply with quote

In my crocket-overlay, I have set up a complete janet system. Come have a look at dev-lang/janet and dev-janet/*.

After using janet for a while, I have decided that it is better than joker and babashka.
Back to top
View user's profile Send private message
babuska_rider
n00b
n00b


Joined: 04 Jan 2021
Posts: 1

PostPosted: Mon Jan 04, 2021 10:26 pm    Post subject: Reply with quote

lefsha wrote:
crocket wrote:
Clojure survived and established its niche.


As I said there are things in life we do, because we have to and there are things we do because we love to.
People use Clojure, because they have to learn programming at school.

From practical point of view there is no place for such languages in the industry.

There are 2 groups of languages - very fast to run and very fast to write.
People ready to pay for speed with complexity and they are ready to pay for simplicity
with performance. C is the first, python is the second. Of course there are more
languages in each group. PHP is like python for web.

Clojure is nice to learn math abstracts and to train the brain, but not to work on anything.
There are no use cases for Clojure.

The program will be slow and will take long time to be written.
After all there will be no one who will agree to maintain it over time.
There are NO people who know that language. You can't hire them.

crocket wrote:
With syntax highlighting, reading lisp is okay. And, proper indentation conveys context in lisp.
If you have some familiarity with lisp, proper indentation is second-nature to you. There is no need to decrypt a properly indented lisp code. After a day or two, parentheses disappear in your mind.

It's easy to hate lisp when you have no familiarity with it. If you ever tried one seriously for a while, you might change your mind.


It's a common observation, that parentheses are the problem, but frankly not only them.
The most difficult part is absence of any other symbols which tell me what it's all about.

Take a look at the simple snippet from examples:

Code:
(defn sum3
  "Solve the 3SUM problem in O(n^2) time."
  [s]
  (def tab @{})
  (def solutions @{})
  (def len (length s))
  (for k 0 len
    (put tab (s k) k))
  (for i 0 len
    (for j 0 len
      (def k (get tab (- 0 (s i) (s j))))
      (when (and k (not= k i) (not= k j) (not= i j))
        (put solutions {i true j true k true} true))))
(map keys (keys solutions)))


It's exactly like with python enough to forget to add a single parenthesis
and no one can understand what the code is about and where is a mistake.

Every single human has a problem to say exactly how many 1111111111
or 0000000000 or )))))))))))) is written in one line. You have to count them pointing
your finger to each symbol. More than 3 of the same characters in a row is a problem.

That is why smart people came to the idea to represent numbers
in that way: 1,000,000.02

If I think about my program I don't wish to count parentheses at the same time.

LISP make it worse. I need to check that those 15 brackets are matching
another 15 spread in the code above. Why the heck I should care about it???

A use case? - Try randomly remove a single parenthesis from your program
and then count how much time you need to find and fix the mistake.
It will take longer, than you think it will.

First 15 min it works well. But every day 8 hours 5-6 days a week...

Why the hell I have 10 kernels under hood to count brackets myself?

PC cannot make it. It's the program logic behind it.
It's like python cannot count idents. It's only up to the author to put one.

It is significantly easier to count idents vertically, than parentheses horizontally.
Putting each parenthesis on a single line will make a code even worse.

Therefore the idea with tabs was not quite stupid, but still bad.
C,C++ is better off with ; and multiple other symbols.

A good language has to be brief, but explicit!

What is: "for k 0 len" how to interpret it???
Is that one of:

for(int k=0; k<len; k++)
for(int k=0; k>len; k--)
for(int k=0; k<=len; k++)
for(; k<=0; k+=len)
for(; k>0; k-=len)

or many other options?

Why should I spent my time trying to understand whether the written code is doing what I think or something else?
Where is exactly the benefit to write "for k 0 len" instead of "for(int k=0; k<len; k++)"
I see none! The second one is explicit and crystal clear. There is no doubt what is going on.
And... it does use the parentheses, wow!


Being too brief is a very bad idea in programming!

It is as bad as dynamic assignment in python.


a = 1
a = "string"

is it a mistake or was it on purpose???
Think you aren't the original author.
Think it's your code 10 years back.


In any piece of code there should be no double interpretation possible.
That is why Rust, which is too verbose some time.
That is why variable/const in not mutable by default.
Everything has to be explicit!

Making mistakes is the normality and the language has to accommodate that.

crocket wrote:
But, it ultimately comes down to subjective feelings. Some people like parentheses. Some people hate them.


Every one or earth hate ))))))))))) and no one has or should have a problem with z = f(x,y)

It's not about brackets. It's about what they are for.

crocket wrote:
No language is going to fill the entire use cases.


It depends on acceptance of explicity level of a language you ready to tolerate.

in some circumstances a=1 is a just literal and therefore a string or a char
in others it is an int or may be even a float or a complex number...
In physics it can be a 1 m, 1 s, 1K or 1 kg and there is a huge difference
between 1m and 1kg for a physicist. making 1+1 is no error, but making
1m + 1kg is a error.

Each time the same text should be interpreted differently and the example above is most simple
problem description of such an issue.

People tend to be brief and use slang if not leaving a certain area and if every one is on the same page.

Ask 10 people with different background what is CVD and all of them tell you something different.

Theoretically one can create different flavors for the same language.
Let say web, shell, system, business app etc.
Then the same statement like a=1 will be understood differently.
To get out of those frames one need to be more explicit
like for a shell a=1.00 if one means a number etc.



I think you were never introduced to the point of Clojure. So i advise you take 30 min of your time and listen to this talk by Stu Halloway https://www.youtube.com/watch?v=noiGVQoyYHw

Also your 3SUM solution in Clojure is completely unidiomatic, we don't use for loops (for in clojure is not like a normal for loop in other languages), we don't modify values in place etc, we generate new values etc..

Here is a more idiomatic way to solve the 3-sum problem in Clojure:

Code:


(defn tails [s]
  (take-while seq (iterate rest s)))


(defn tri-num [s]
  (for [[a & ar] (tails s)
        [b & br] (tails ar)
        [c] (tails br)
        :when (zero? (+ a b c))]
    [a b c]))


Also, when you start using a lisp like Clojure, you see that a) the number of parens is less than or equal to any other C like programing language and b) there is absolutely no issue with it, actually the ergonomics of programming is much better if you use tools like smart-parens, parinfer and colored parens. It's like the best thing next to the REPL driven development. I never have to close any parens manually. I use parinfer, because I am lazy to learn paredit, but it's like so easy to edit code, much much easier than it was editing Java or any other non lisp code. People that complain about parens have never ever invested 5 min into learning the most simple tools. A beginner Clojure programmer, never complains about parens after 1 hour of coding.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum