
Clojure-turtle – Logo programming language in a Clojure context - tosh
https://github.com/google/clojure-turtle
======
elnygren
Using Clojure as the first language is interesting. Being one of the most
expressive and efficient (I am not talking about clock cycles here) languages
I've used, I think it will set a great mindset for programming.

Clojure is declarative, you tell what you want, not how you want it. It uses
immutable data structures and functional programming. It teaches you a sane,
safe and beautiful way of working on the problems rather than working
against/around/because of your language (e.g building OOP design patterns
rather than just solving the problem at hand).

Some people might disagree, but Clojure is a very hands-on and practical
language. There's not much syntax or quirks to learn; just a big standard
library of very useful functions for processing and transforming data.

~~~
chickenfries
> There's not much syntax or quirks to learn

Except if you don't know Java.

~~~
hellofunk
This is a common misconception. I've never written a line of Java in my life,
but have been a professional Clojure dev for several years. I never need to
interact directly with Java, because most of the libraries you want to use do
that for you anyway, and the language itself is self-supporting and
comprehensive to not require interop for nearly everything.

~~~
chickenfries
I don't know why you assume that I haven't tried Clojure and found the
requisite Java knowledge to be a barrier. How did you get into developing
Clojure professionally? Personally, learning on my own through resources like
Clojure for the Brave and True, I found it difficult.

~~~
agumonkey
I'd love to hear things you disliked or found confusing. Just for the sake of
seeing through others eyes.

~~~
chickenfries
It's been a while since I tried to get into Clojure/Cljs but when I did I
remember errors like the one in this article being cryptic:

[https://8thlight.com/blog/connor-
mendenhall/2014/09/12/cloju...](https://8thlight.com/blog/connor-
mendenhall/2014/09/12/clojure-stacktraces.html)

> Caused by: java.lang.IllegalArgumentException: Don't know how to create ISeq
> from: clojure.lang.Keyword

What's an ISeq? I can guess that' it's part of clojure's implementation from
java.lang.IllegalArgumentException, but that's what I'm talking about when
saying that clojure isn't a great first language because of how you have to
both understand a little bit about clojure and a little bit about java, when
it comes to errors and namespaces.

~~~
hellofunk
Clojure doesn't have the most obvious errors in the world to a newcomer, that
is true. A good book on Clojure will quickly remove any confusion about what
ISeq means, but a bit of practice makes those low-level understandings not
required.

The article you mentioned accurately says this:

> Although Clojure's errors are notoriously unfriendly, they're easy to read
> with a bit of practice

Once you realize that much of what happens in Clojure is based on data
sequences, it becomes clear that an individual keyword is _not_ a sequence, so
it was probably used incorrectly somewhere.

That's an interesting article comparing the errors from Ruby with Clojure.
They are about the same, the only difference is that Clojure gives you a lot
more information in the form of an ugly stack trace. Fortunately, many editors
in Clojure automatically hide the stack trace and only show the error.

After you've seen errors a few times in your first week using the language,
fixing them becomes second nature. This is one of the tradeoffs using a
dynamically typed language: there will be more debugging of runtime problems.
In return for that, you spend less time on other things. The fact that there
are very successful languages in both the dynamic and static typed camps shows
that benefits can be found everywhere.

~~~
agumonkey
I wonder what would happen if vanilla clojure came with a commonlisp style
debugger on error. CL errors can be intimidating but the interactive debugger
makes things almost fun.

~~~
hellofunk
Figwheel has time-travel debugging, which is nifty. To be honest, my debugging
is quite basic and quick, I've been doing it long enough that when I see an
error it's clear what the fix is almost immediately. I suspect this is what
happens in most languages regardless of their error handling mechanisms.

------
brudgers
Turtles in #lang typed/racket:

[http://docs.racket-
lang.org/furtle/index.html?q=turtle#%28de...](http://docs.racket-
lang.org/furtle/index.html?q=turtle#%28def._%28%28lib._furtle%2Fmain..rkt%29._turtle%29%29)

------
linkmotif
Was I the only person who did not understand the draw of Logo as a kid? Having
to use it in school made me feel like the world viewed me as a lobotomy
victim.

And today, whenever one of these teaching-kids-to-program
language/environments comes out, I always wonder, "is a real language really
beyond the 8-10 year old's grasp?" More importantly, wouldn't using something
real be more interesting to kids? The excitement of computers was, for me,
about what you could do with them, and if that meant having to learn some
scary looking "computer language" then—By God—I would! And it would be
exciting!

The turtle did nothing for me except count the minutes before I could go and
do something else. Thankfully we had a public library that had computer books.
They weren't the best, but they were about real computer things.

I wish someone had introduced me to Lisp as a child. It's so fundamental. I
remember thinking in similar terms, and would have had my mind blown on so
many different levels if someone had introduced me to Lisp when I was 8-10, or
even younger.

~~~
kbp
> Was I the only person who did not understand the draw of Logo as a kid?
> Having to use it in school made me feel like the world viewed me as a
> lobotomy victim.

> And today, whenever one of these teaching-kids-to-program
> language/environments comes out, I always wonder, "is a real language really
> beyond the 8-10 year old's grasp?"

> I wish someone had introduced me to Lisp as a child. It's so fundamental. I
> remember thinking in similar terms, and would have had my mind blown on so
> many different levels if someone had introduced me to Lisp when I was 8-10,
> or even younger.

Logo is a real language, and it is _extremely_ similar to Lisp; a lot of
people even just refer to it as a Lisp dialect. There's a lot more to Logo
than turtle graphics, the same way there's a lot more to Racket or Python or
any other language that has a turtle graphics package.

Basically, you were more or less introduced to Lisp when you were a kid, and
having to use it in school made you feel like the world viewed you as a
lobotomy victim.

The problem you encountered probably stems less from Logo and more from being
taught Logo by teachers who barely knew it themselves, and who didn't care
about or understand anything beyond turtle graphics, so that's all they're
able to teach to students.

Here's a good introduction to Logo by Brian Harvey with an emphasis on
symbolic computation: [https://mitpress.mit.edu/books/computer-science-logo-
style](https://mitpress.mit.edu/books/computer-science-logo-style)

~~~
linkmotif
Thank you! What you describe regarding my experience might very well be
possible. And I will look at Logo again. I am sure you are right regarding its
design and foundation.

You quoted my question about teaching-kids-to-program languages, but didn't
really address it. Are they necessary? Might they not be detrimental? A kid
who's interested in programming: wouldn't they be a lot more excited by, say,
HTML and JavaScript—which brings the ability to make websites (!!) —than say,
moving a robot, virtual or real.

Then again, it is inherently hugely fun to interact with computers in a REPL-
style manner, too. I just never felt inspired by the turtle and only kind of
resented it. I wanted to learn about bits and bytes and to understand
computers.

------
thesmallestcat
This is great, very small code. The choice of Clojure would make it a bit
difficult for a beginner, but hey, then you know a real language.

> This is not an official Google product (experimental or otherwise), it is
> just code that happens to be owned by Google.

#1 reason for a hacker to not work for Google, you could program "Hello,
World" and they wouldn't sign off on it.

~~~
arjie
The fact that they open-source their code is enough. Imposing the requirement
that they must support everything they open-source will mean they will open-
source less.

Why should everyone support everything they open-source as an official
product? I contest everything you say. This is not the #1 reason. It's not
even _a_ reason.

~~~
thesmallestcat
You've misunderstood my comment. I'm saying that Google has a reputation for
claiming rights to just about anything you present to them. It's that petty IP
policy that has this fun little project under their ownership. For many
people, particularly those involved in open source, Google's reluctance to let
go of employees' side projects is a strong reason to not work there.

~~~
kronos29296
It is part of the fine print in the job contract for developers and is pretty
common in most companies. You don't create a side project while being employed
there without the company claiming ownership of it. It is part of a safety net
for the companies so that they don't take a loss by an employee claiming
copyright of code they wrote for the company during work hours.

According to law if there is no such clause the developer may claim ownership
of code he wrote even if he was employed. The contract protects the company
from that but also applies to any code written by employees generally (not a
nice thing but prevalent).

~~~
vertex-four
It's very, very common that if you send an email to the relevant people,
they'll sign off on whatever so long as it's not relevant to the business.
They don't _really_ want to retain control over your random side-projects.

Google, on the other hand, seems to believe that absolutely everything its
employees ever do is relevant to its business.

~~~
orangecat
Google has IARC
([https://opensource.google.com/docs/iarc/](https://opensource.google.com/docs/iarc/)),
which is a formal process of sending email to the relevant people, and results
in a much better legal position than "Bob said it was ok".

~~~
vertex-four
Indeed they do - the issue being that according to a handful of Googlers I
know, it's surprisingly difficult to get anything through that process.

~~~
DannyBee
That's really strange, since we've approved >96% of requests, and except for
when someone is on vacation, it's usually within 3 days now.

Given how many reply to the approval emails that they found it fast and happy,
i definitely find this surprising.

In any case, you are welcome to have those employees reach out to me, i'd love
to understand their experience what went wrong.

------
tosh
Anyone knows why the ClojureScript code has the same macros (repeat and all)
in seperate files? Why can't everything be in the core.cljc file?

[https://github.com/google/clojure-
turtle/blob/master/src/clj...](https://github.com/google/clojure-
turtle/blob/master/src/cljs/clojure_turtle/macros.cljc)

[https://github.com/google/clojure-
turtle/blob/master/src/clj...](https://github.com/google/clojure-
turtle/blob/master/src/cljc/clojure_turtle/core.cljc)

~~~
elangoc
It was in order to get the CLJS REPL to feel more like the regular Clojure
REPL: [https://github.com/google/clojure-
turtle/issues/15](https://github.com/google/clojure-turtle/issues/15)

The CLJS-macro story is still a little tricky -- CLJS targets the JS runtime,
but you can't easily define macros in a self-hosted CLJS REPL (ex: one that
you'd embed in a webpage). Lmk if there is a cleaner way now.

~~~
tosh
Awesome enhancement. I'll keep that in mind. Thanks for the clarification.

------
tosh
related: 20 things to do with a computer (1971) from MIT AI Lab

[https://dspace.mit.edu/bitstream/handle/1721.1/5836/AIM-248....](https://dspace.mit.edu/bitstream/handle/1721.1/5836/AIM-248.pdf?sequence=2)

------
flavio81
It is exciting that people inside Google is using Clojure. The more Clojure
gets popular, the better for the programming community as a whole, even if its
usage means indirectly giving more fuel to Oracle.

<smug-mode> On the other hand it also means we will thus be able to one-up
Google by using Common Lisp... </smug-mode>

~~~
fiddlerwoaroof
Google already uses Common Lisp for flight search (acquired from ITA
Software). They even have a fairly good style guide written by one of the
maintainers of ASDF (amongst others):

[https://google.github.io/styleguide/lispguide.xml](https://google.github.io/styleguide/lispguide.xml)

------
iamalchemist
Logo was my first programming language. #Nostalgic Thanks Google and thanks
for Clojure implementation.

~~~
elangoc
BASIC was my first programming language. Starting with the days of the
Commodore 64, Apple IIe, and MS GWBASIC, but I never understood it well enough
beyond a number guessing game or so. Then I had a class on Logo, and I was
doing cool stuff on my own, and it was so fun! Yeah, I love Logo.

During the time of that Logo class, I tried writing a BASIC program for a
programming competition with my new-found confidence. But it was such a
spectacular fail that my 11-year old self was literally crying.

I find both Logo and Clojure are profound, simple, and powerful in their own
ways. A friend and I are working to take the next step with this project and
make this a little more accessible/usable. ;)

~~~
cr0sh
BASIC was my first language too, but LOGO was the first language I attempted
to make an interpretor for (also, incidentally, LOGO was the first language I
took a class for, just for fun - something Radio Shack offered for the Color
Computer, which was the machine I owned).

------
tosh
related (via /r/Clojure): [https://docs.racket-
lang.org/turtles/Value_Turtles.html](https://docs.racket-
lang.org/turtles/Value_Turtles.html)

------
iLemming
But, but... Clojure is dying language. Someone been crying about that all over
the internet just a few weeks ago. Why Google using a dying language?

~~~
iLemming
I've been sarcastic of course. I'm one of those lucky bastards who's got
luxury of writing Clojure(script) all day long and get paid for it.

------
dimitar9
my first programming language was logo. nice job dude!

------
lngnmn
Yet another example of how interfaces and ADTs (together with layered DSLs)
are _the_ central concerts in classic CS.

~~~
thanatropism
Honest question: what is nonclassic CS?

~~~
lngnmn
systemd

More seriously, everything which made MIT to switch from Scheme to Python in
the fundamental CS courses.

------
systems
is is significant because it shows google is testing clojure, or is it
something else?

~~~
elangoc
If you try the interactive examples on the main Readme page all the way to the
end, you'll see there's a gradual, subtle shift from cutesy Logo to Clojure-
style functional programming. But I owe more doc-writing along those lines,
and they that would make that fuller & clearer.

