creativescala / creative-scala Goto Github PK
View Code? Open in Web Editor NEWQuick, graphical, fun introduction to programming in Scala.
Home Page: https://creativescala.org/
Quick, graphical, fun introduction to programming in Scala.
Home Page: https://creativescala.org/
Should this example (from creative-scala/src/pages/methods/semantics.md):
{ val x = 2 square(2) }
have x
as an argument to the square
method:
{
val x = 2
square(x)
}
?
Page 67 of the current draft. The boxes should be blue and should stacked using above
. The exercise solution is also wrong.
https://www.creativescala.org/creative-scala.html#values-are-objects 2.2.2 Operators says:
1 + 2
// res4: Int = 3
1.+(2)
// res5: Int = 3
This second way of calling a method is known an operator style.
I've never heard of this name before. Is this "operator style" term used somewhere else? I am not sure if I'd associate dot-and-paren style more with "operator" than the infix notation, since operator precedence etc would affect infix notation more.
Creative Scala doesn't do a very good job explaining the setup process for people who are not already fairly proficient programmers:
Include how to open the command line on Windows etc.
After about chapter 10 in the HTML version the layout goes wrong, and the final chapters are missing. Investigate the cause of this an fix it.
Feedback from teaching a course is that the chapter on Lists, which introduces more pattern matching forms, is unclear. All the students struggled with the syntax for pattern matching. Clarify this.
$ npm install
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
[email protected] node_modules/underscore-ebook-template
└── [email protected] ([email protected], [email protected])
$ grunt pdf
Running "pandoc:pdf" (pandoc) task
Running shell command: pandoc --smart --output=dist/creative-scala.pdf --template=node_modules/underscore-ebook-template/lib/templates/template.tex --from=markdown+grid_tables+multiline_tables+fenced_code_blocks+fenced_code_attributes+yaml_metadata_block+implicit_figures+header_attributes+definition_lists --latex-engine=xelatex --variable=lib-dir:node_modules/underscore-ebook-template/lib --filter=node_modules/underscore-ebook-template/lib/filters/pdf/callout.coffee --filter=node_modules/underscore-ebook-template/lib/filters/pdf/columns.coffee --filter=node_modules/underscore-ebook-template/lib/filters/pdf/solutions.coffee --filter=node_modules/underscore-ebook-template/lib/filters/pdf/vector-images.coffee --chapters --number-sections --table-of-contents --highlight-style tango --standalone --self-contained --include-before-body=node_modules/underscore-ebook-template/lib/templates/cover-notes.tex src/meta/metadata.yaml src/meta/pdf.yaml src/pages/intro/index.md src/pages/expressions/index.md src/pages/expressions/simple.md src/pages/expressions/images.md src/pages/expressions/take-home-points.md src/pages/declarations/index.md src/pages/declarations/value-declarations.md src/pages/declarations/method-declarations.md src/pages/declarations/color-palette.md src/pages/declarations/take-home-points.md src/pages/fp/index.md src/pages/fp/recursion.md src/pages/fp/functions.md src/pages/fp/take-home-points.md src/pages/collections/index.md src/pages/collections/create.md src/pages/collections/transform.md src/pages/collections/take-home-points.md src/pages/summary/index.md src/pages/quickreference/index.md src/pages/solutions.md src/pages/links.md
>> p
>> andoc: Error running filter node_modules/underscore-ebook-template/lib/filters/pdf/callout.coffee
>> fd:4: hClose: resource vanished (Broken pipe)
>> Shell command exited with code 83
Warning: Task "pandoc:pdf" failed. Use --force to continue.
Aborted due to warnings.
Some issues I ran into following the installation portion of README.md.
We use the term syntax
in Creative Scala but do not define it. We should, given it is a fairly technical term.
I have mixed feelings (leaning towards negative) about the extensive use of infix notation in the book for code like:
circle(10) beside square(20) beside square(30)
my impression is that the Scala community experimented with this style pretty heavily for a long time, but in recent years almost everyone has retreated from it and it's not really a mainstream style anymore for ordinary, alphanumerically-named methods like beside
but my concern isn't only about what the dominant style is in the community, it's also about what an appropriate style for getting started with the language is. for years now, I've seen (on Gitter and IRC, primarily) beginners tripping themselves up with what this syntax means and how it is parsed. beginners end up using a mishmash of spaces and dots and parens and not really knowing what's going on and where infix is permitted and when it isn't and when you need parens to make it work and when you don't. it seems like a distraction to me. by sticking with a.b(c)
style you bypass all these issues, freeing up mental energy to focus on more important things
would a PR changing the code to consistently use this style instead:
circle(10).beside(square(20)).beside(square(30))
be welcome...?
Hi,
I was working through the material myself to prepare for teaching it, and I found a lot of little mistakes.
I got until chapter 9, here's everything I found.
2.4.0.4
scala mdoc 1 + 2
which doesn't belong there3.1
Image.circle(10)
is shown twice.3.2
(Image.circle(10).beside(rectangle(10, 20))).draw()
does not compile. It should be (Image.circle(10).beside(Image.rectangle(10, 20))).draw()
Doodle contains several layout methods for combining images, described in tbl. ¿tbl:pictures:layout?.
That table reference is broken and so is the table shown under it doesn't render correctly. (This looks slightly different in the pdf view vs the html view but there's a problem in both)below(circle(20))
won't work, it should be below(Image.circle(20))
, unless you import Image._ first but it doesn't say anywhere to do so.3.3
3.4
3.5
3.5.3
3.6.1
4.1
4.2
5
5.2
6.2
scala mdoc
in the solution.7.1
beside
to above
, the code example still says beside
.7.6
We could also make the fill color a function n
should probably be a function OF n
.8.2
8.6
scala mdoc
in the solution.8.8.3
9.1.1
9.3.2
(1, 2)
but as Range 1 until 3
. You have to convert it to see it as a list.9.3.3
scala> 0.0 to 10.0 by 1.0
warning: there was one deprecation warning (since 2.12.6); for details, enable `:setting -deprecation' or `:replay -deprecation'
res2: scala.collection.immutable.NumericRange[Double] = NumericRange 0.0 to 10.0
9.4
Add detailed installation instructions for both pathways (IntelliJ and Atom) and all platforms. Consider taking screenshots. Look at the ScalaBridge screenshots for example. Consider creating installation screencasts.
Atom / Command line
IntelliJ
Exercise has the solution inline (it should be wrapped in <div class="solution">
) and the exercise calls cross
where it should recurse to itself.
In the PDF on page 105 in Chapter 9.8 the following code snipped is supposed to generate the stars shown in Fig. 9.12:
val star = Image
.star(100, 50, 5, 0.degrees)
[...]
however the order in which the arguments are given seems to be wrong when looking at the source code: https://github.com/creativescala/doodle/blob/79e41e13637592519cf809b0e2b34c5f4958b418/image/shared/src/main/scala/doodle/image/Image.scala#L203
I fixed it thus using the following order to create something like shown in the Fig. 9.12:
val star = Image
.star(5, 100, 50, 0.degrees)
[...]
https://www.creativescala.org/creative-scala/methods/writing-methods.html is broken in various ways:
Reported by Kim Morgan.
Go through "Turtles" chapter and fix typos, edit as necessary, etc.
https://github.com/underscoreio/creative-scala/blob/develop/src/pages/programs/names.md#exercises--
object One {
val a = b - 1
val b = a + 1
val answer = a + b
}
Trick question! This code doesn't work. Here
a
andb
are defined in terms of each other which leads to a circular dependency that can't be resolved.
I think the reason because this code doesn't work is actually two folds.
b
as val b: Int = a + 1
.val a = b - 1
is referencing b
before it is initialized, which seems to be treated as 0
. Making answer
into (0 - 1) + (0 - 1 + 1)
, which is -1
.scala> object One {
| val a = b - 1
| val b: Int = a + 1
|
| val answer = a + b
| }
<console>:12: warning: Reference to uninitialized value b
val a = b - 1
^
defined object One
scala> One.answer
res1: Int = -1
If we want to expose the readers to val
initialization order issue, it might be worth changing the exercise to:
object One {
val a = b - 1
val b = 10
val answer = a + b
}
and note that fact that without -Xfatal-warnings
one could end up with incorrect answer?
Given the complicated license and update situation (https://www.aspera.com/en/blog/oracle-will-charge-for-java-starting-in-2019/, https://www.oracle.com/technetwork/java/java-se-support-roadmap.html) and ever changing JDKs and Scala's varying degree of support for it, I think Creative Scala should instruct new users explicitly to use Java 8. If someone has an Oracle JDK already that's ok, but for new installs I recommend AdoptOpenJDK OpenJDK 8 + HotSpot.
It's a binary distribution created from OpenJDK project source. Hopefully it should provide patches long after January, 2019.
https://github.com/underscoreio/creative-scala/blob/develop/src/pages/pictures/exercises.md
For bonus credit add a stand so we can place the target on a range, as shown in
[@fig:pictures:target2]
.
https://github.com/underscoreio/creative-scala/blob/develop/src/pages/pictures/target2.svg shown is actually a target with red and white color, not a stand.
Correct the image.
For example, calling chessboard(-1) will lead to endless recursion and eventually stack overflow.
def chessboard(count: Int): Image = {
val blackSquare = Image.rectangle(30, 30) fillColor Color.black
val redSquare = Image.rectangle(30, 30) fillColor Color.red
val base = (redSquare beside blackSquare) above (blackSquare beside redSquare)
count match {
case 0 => base
case n =>
val unit = chessboard(n-1)
(unit beside unit) above (unit beside unit)
}
}
The solution could be just adding additional case on top:
case n if n<0 => Image.Empty
However, Dave suggested to turn it into a learning opportunity by adding:
I like his approach better.
As part of updating Creative Scala to Cats 1.1.0 the description of |@|
need to change to mapN
. This is in the generative art chapter.
A larger project to tie together concepts would be good. Perhaps a Twitter bot that tweets generative artworks?
The SVG image rendering is broken in the web version because the base64-encoded inline images don't contain the xmlns value.
This can be fixed manually, but the real problem is in the doodle library. I've opened a PR to fix it there so the images are generated correctly in future, as well as one fixing the existing SVGs here.
This fix should also fix #72.
I was wondering if you think that using cousier for faster artefact resolution could be helpful, I have tested a branch and it is working. Since the docker is usually a cold resolution cache, this can help a lot (pity it does not work for the sbt and plugin artefacts)
Happy to create a PR from that branch (it is a one-liner anyway)
Thanks for all the hard work!
On a fresh clone of the project, the log looks like this:
scala> Example.image.draw
java.lang.NullPointerException
at java.util.concurrent.ConcurrentLinkedQueue.checkNotNull(ConcurrentLinkedQueue.java:920)
at java.util.concurrent.ConcurrentLinkedQueue.offer(ConcurrentLinkedQueue.java:327)
at java.util.concurrent.ConcurrentLinkedQueue.add(ConcurrentLinkedQueue.java:297)
at doodle.jvm.Java2DFrame.interpret(Java2DFrame.scala:19)
at doodle.jvm.Java2DFrame.interpret(Java2DFrame.scala:8)
at doodle.syntax.ImageSyntax$ToImageOps.draw(ImageSyntax.scala:9)
... 39 elided
P.S.: happens only through sbt console. On IntelliJ Idea the error is not reproduced.
A reference to an allOn
method is made in three places in chapter eleven. This method does not seem to exist, in the current version. The following is an example of where it is mentioned.
This is the equivalent of the
allOn
method we’ve developed previously,
One solution would be to create or restore an exercise, to create such a method.
Second exercise on https://www.creativescala.org/creative-scala/methods/syntax.html is wrapped within a solution tag.
Impure code depends on all the prior code --> clarify we mean the meaning of impure code, as it depends on state, and the state depends on all prior code that has run.
The goal here is to add the easy bits of creating axes. Anything that feels like large enough that it isn't easy should be a separate ticket.
A few notes:
All chapters, except introduction / setup, should have recaps at the end.
All chapters need proof-reading. Any errors found should be fixed. Proof reading only needs to focus on grammatical errors, typos, and the like. The structure of the book doesn't need to be reviewed.
$ npm install
npm WARN package.json [email protected] No repository field.
npm WARN engine [email protected]: wanted: {"node":"~0.10.1"} (current: {"node":"0.12.0","npm":"2.5.1"})
Needs to explain why we've chosen Scala, and give background on Scala, FP, and the approach of the book.
there are a lot of missing or glossed-over steps and choices to make.
I've used IntelliJ and Scala before, but regardless, I found these instructions difficult to follow and I felt very uncertain whether I was doing it right.
I'm skeptical that a new user could follow these instructions without a lot of guesswork and/or outside assistance
There's a box at the start of chapter 3 saying:
If you run the examples from the SBT console within Doodle they will just work. If not, you will need to start your code with the following imports to make Doodle available.
mdoc scala import doodle.core._ import doodle.core.Image._ import doodle.syntax._ import doodle.jvm.Java2DFrame._ import doodle.backend.StandardInterpreter._
That mdoc scala
at the beginning shouldn't be there.
Most students are keen to get started and are skipping over the background. Put the instructions---the important stuff---first and then follow with background.
Also clean up the instructions to some extent, and don't suggest forking from Github unless they're taking the course with an instructor.
Following the instructions the first step run from the sbt console is
Example.image.draw
However with the latest version this triggers the following error:
<console>:27: error: could not find implicit value for parameter renderer: doodle.effect.DefaultRenderer[[x[_]]doodle.language.Basic[x],Nothing,Nothing,Nothing] Example.image.draw
However, using parens when calling draw properly resolves the implicit and draws the doodle
Example.image.draw()
Doodle 0.8.0 has been released, and it breaks a few things. Update the book accordingly.
Make it good.
Hi there! I'm trying to teach my sister Scala with this book and I've realized that the epub book version doesn't render images. I attach a screenshot of page 67, at the beginning of the section of "Computing with Pictures", to illustrate what I mean:
I'm using macOS Catalina 10.15, I'm on the latest version. My sister has tried on her iPad and it doesn't work there either, so this might be a general platform on the iOS and OSX platforms. For now, I've referred my sister to the PDF version, so this is not a blocker but my sister had a preference for the EPUB format.
tut
ify the code.Content is not a concern at this point.
The following TODO was left at two places in the text (page 134 in the PDF):
This generates the anima on shown in TODO: render animation
Could a temporary fix, until the new build for the book is finished, simply be a QR code as a pointer?
Flame fractals are simple to implement and look impressive. Consider adding them as a project. This will require changes to Doodle to support bitmap images.
I was puzzled not to find it under https://github.com/creativescala
Figure22 is not stacked boxes now. It is same as figure 21.
Create circles that are 1, 10, and 100 units wide. Now draw them!
circle(1)
If the passed in parameter is radius, then circle(1)
would draw circle with 2 unit width.
I'd think the following would give the circle with 1
width:
circle(0.5)
Am I understanding this wrong?
Go through "Generative" chapter and fix typos, edit as necessary, etc. In practice I've found students struggled with Applicative, so consider replacing with further discussion of Monad.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.