Giter Club home page Giter Club logo

learn-julia-the-hard-way's Introduction

Learn Julia the Hard Way DOI

Slant

The Julia base package is pretty big, although at the same time, there are lots of other packages around to expand it with. The result is that on the whole, it is impossible to give a thorough overview of all that Julia can do in just a few brief exercises. Therefore, I had to adopt a little 'bias', or 'slant' if you please, in deciding what to focus on and what to ignore.

Julia is a technical computing language, although it does have the capabilities of any general purpose language and you'd be hard-pressed to find tasks it's completely unsuitable for (although that does not mean it's the best or easiest choice for any of them). Julia was developed with the occasional reference to R, and with an avowed intent to improve upon R's clunkiness. R is a great language, but relatively slow, to the point that most people use it to rapid prototype, then implement the algorithm for production in Python or Java. Julia seeks to be as approachable as R but without the speed penalty.

Owing to this, and partly to my own background as a data scientist, LJTHW is going to be somewhat biased towards the needs of statisticians. As such, there will be relatively little talk about fast Fourier transforms, integration and other mathemagical concepts that are beyond the immediate need, while some other components, such as the plotting package Gadfly, which would normally not be of general interest, will be explored. I have tried to strike a fair balance, and I hope I have succeeded there.

Audience

Unlike most of Zed Shaw's Learn X the hard way books, LJTHW is not intended for complete novices to programming – Julia is simply not ready yet for people wishing to learn programming by using it, although I see great potential in teaching people a functional programming language ahead of clobbering them with object-oriented concepts. On the other hand, one of the best things about Julia is that it was written by hackers, not language nerds. Yes, it's got all sorts of metaprogramming goodness, it's homoiconic and it's got all sorts of other amazing things about it that may be of interest to a few, but they are not relevant to being good, or even pretty good, at Julia. Therefore, I am treating the audience as one of people who need to get a job done, not computer scientists. The latter probably already have taught themselves Julia!

How to compile

Install GitBook and run make.

How to contribute

Learn Julia the Hard Way by Chris von Csefalvay is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Pull requests are welcome! Please note that the contents of this book, including your contributions, may form the foundation of a future publication. By contributing, you waive any and all rights over the content you contribute, save the right to be credited as a contributor to the finished work. While I do intend to eventually market a full-length book version of this manuscript, the Github version will remain forever free and open-source (although it might not get updated). I will always acknowledge the community's contributions to this work, and anyone who has contributed to it and is acknowledged in the CONTRIBUTORS.md file will be expressly acknowledged unless they wish otherwise.

Author

I'm a data scientist, hacker and recovering lawyer living in Northern Virginia. In my day job, I'm a software architect, and my parents still don't know what that means. When not working, I am coding for fun and spending time with my wife and our adorable Tortie kitten, River. My website is here. You can e-mail me here.

Creative Commons License

learn-julia-the-hard-way's People

Contributors

0fiscalentropy avatar 4amvim avatar alemelis avatar aznashwan avatar chrisvoncsefalvay avatar dikeeris avatar fixablecar avatar gabehassler avatar ikselven avatar isislovecruft avatar klausc avatar markhalonen avatar matthieugomez avatar melvin0008 avatar mschauer avatar omar-elrefaei avatar pauljurczak avatar prcastro avatar rubikx avatar scls19fr avatar sergiorgiraldo avatar siyaoxu avatar svaksha avatar szarnyasg avatar tapanprakasht avatar tk3369 avatar tndoan avatar visr avatar winterrdog avatar yairfrid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learn-julia-the-hard-way's Issues

Short-Circuit Evaluation != Bitwise Operators

In chapter 6 section combining-comparisons: "Comparisons can be combined using the boolean operators && (and) and || (or)."

I think it would be better not to blend the Bitwise Operators (& and |) with the operators for Short-Circuit Evaluation (&& and ||). The Bitwise Operators require both operands to be Boolean values. When using the Short-Circuit operators then the last operand can be any random expression.

	julia>> 2) &< 3)
	false

	julia>> 2) |< 3)
	true

	julia>> 2) && println("Short-Circuit Evaluation")
	Short-Circuit Evaluation

Gitbook PDF task fails: path undefined

Hi,

I cloned this repo installed gitbook-cli via running sudo npm install -g gitbook-cli and ran make from the top-level directory of this repository and I received the error message:

gitbook pdf
(node:17051) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
(node:17051) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
info: loading book configuration....OK 
info: load plugin gitbook-plugin-highlight ....OK 
info: load plugin gitbook-plugin-search ....OK 
info: load plugin gitbook-plugin-sharing ....OK 
info: load plugin gitbook-plugin-fontsettings ....OK 
info: >> 4 plugins loaded 

TypeError: Path must be a string. Received undefined
Makefile:16: recipe for target 'book.pdf' failed
make: *** [book.pdf] Error 1

is relevant my operating system is 64-bit Arch Linux, my version of NPM is 3.8.8 and Node.js is 6.0.0.

Thanks for your time,
Brenton

Chapter 2 ranges are not expanded.

I'm testing on the latest official docker image which uses 0.5.0.

I'm currently obtaining this result:

julia> a = [0:10]
1-element Array{UnitRange{Int64},1}:
 0:10

Instead of what is shown on the tutorial:

julia> [0:10]
    11-element Array{Int64,1}:
      0
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10

To obtain the same result I have to collect the range:

julia> a = collect(0:10)
11-element Array{Int64,1}:
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10

Use 0.4 as reference

This work probably will be finished (or have a 'stable release') after Julia v0.4 launches. Wouldn't be easier to change the tutorial to match 0.4 now instead of 0.3, so we wouldn't need to port this tutorial in the future?

Modules and packages

Great work so far! I think you need a chapter on modules and packages, though.

gitbook pdf failed

E:\gitbook\julia
λ gitbook pdf
info: 7 plugins are installed
info: 6 explicitly listed
info: loading plugin "highlight"... OK
info: loading plugin "search"... OK
info: loading plugin "lunr"... OK
info: loading plugin "sharing"... OK
info: loading plugin "fontsettings"... OK
info: loading plugin "theme-default"... OK
info: found 14 pages
info: found 17 asset files
internal/streams/legacy.js:59
throw er; // Unhandled stream error in pipe.
^

Error: ENOENT: no such file or directory, open 'C:\Users\user\AppData\Local\Temp\tmp-13740uUWLhu6QJYAG\2dc5c5cb.png?w=1024'

Chapter 7: splat vs slurp

Thanks for the easy to read tutorial.

Chapter 7 gives an example of a 'splat':

function shout_mi(foods...)

If I compare this to the Julia FAQ 1, I'm not quite sure this is the right way round, it looks more like a slurp. Thanks again for the Tutorial.

Where to put profiling (or even, should we put it in?)

I'm planning on putting in a subchapter's worth of material on profiling scripts. Do you have any suggestions on where this would be most appropriate – within the part on funx? Within a separate chapter? At error handling?

Chapter 3: LSD example

Hello,

The LSD example doesn't seem "to work" for me.

      type LSD
       pounds::Int
       shillings::Int
       pence::Int
       function LSD(l,s,d)
       if l < 0 || s < 0 || d < 0
       error("No negative")
       end
       if d > 12 || s > 20
       error("Too many pence or shillings")
       end
       new(l,s,d)
       end
       end

I get

tomato = LSD(0, 50, 50)
LSD(0,50,50)

julia doesn't complain that s and d are over 20 and 12.
Has the syntax changed after the tutorial publication?
Thanks a lot.

Sets / deprecated constructor, and confusion...

Hi,

julia> stooges = Set({"Moe", "Curly", "Larry"})
    Set{Any}({"Moe","Larry","Curly"})

throws a deprecation warning in 0.4.0.

Also, from a newbie, this construction seems unintuitive since curly braces are usually used to denote type. Why are you using it in the constructor when Set("Moe", "Curly", "Larry") is equivalent (down to the deprecation warning) and Set(["Moe", "Curly", "Larry"]) is the nondeprecated constructor that gives a type-relevant set (Set(ASCIIString["Moe","Larry","Curly"]))?

Thanks - this is a great book and I'm learning a lot by going through the examples.

Chapter 5: Strings

In the interpolation section, you talk about * and $ constructs, and mention that $ is faster than *, but you don't mention that string(...) is fastest of all.

License?

Before you accept too many contributions to this text, you should pick a licence that clearly states how people are allowed to use it, and what rights you want to have to the finished text.

If you at some point want to publish this text as a book (or somehow earn money on it), you should get that permission from everyone that contributes directly as soon as possible. It's a pain to have to rewrite a chapter because you can't get in touch with the person that originally wrote it.

Do you want others that write a book about Julia to copy text from you and include it with (or without) attribution?

I'd recomend one of the creativecommons licences. If you pick one of the Non Commercial licences, you should probably also add a note in your CONTRIBUTING.md file about who has the commersial rights (Either if you want them for yourself, or shared among anyone that has contributed over a certain level).

Error in "Danger zone" in chapter 7

The section "Danger zone" that introduces @inbounds contains an error. It speaks only of the variable x, but not of y that is also used, and which doesn't have its length checked.

ToC for Part II

I have now split the book into two parts – Part I, for syntax and the sort, and Part II, for application examples and worked through use cases, kinda 'project'-like. Part I should also be more Base focused while Part II can make more liberal uses of frequently used packages such as Gadfly or the stats packs.

This place is for recommendations for good project examples to work through, ideally from real-world fields.

make failed

fresh install of ljthw and gitbook
make returns
gitbook build
make: *** [_book/index.html] Error 1

Hate going down these rabbit holes.

Chapter 4: Collections

Existence of a particular value

To find out whether an array has a particular value among its elements, you can use in():

    julia> in(2, primes)
    true
Somewhat strangely, in the in() syntax, the needle comes before the haystack, i.e. in(value, array), where value denotes the value you are looking for.

Why not talk about contains() as well, where the haystack comes first?

Chapter 6: Control Flow

"Value truthiness" - everything here is correct, but perhaps this should be explained:

julia> true * 6
6

julia> true + 8
9

julia> false + 8
8

julia> true + 64.7
65.7

julia> 6 + (true)im
6 + 1im

(That is, true evaluates in numerical contexts to 1, and false to 0.)

Error in chp4

Under the section 'Type inference and empty collections' It is mentioned that 'Julia has a dedicated type, None – a subtype of Any – that applies to the empty set'. But following is the output I am getting in REPL:

	julia> empty_set = []
       Any[]

instead of:

	julia> empty_set = []
	0-element Array{None,1}

Types / why use this constructor as an example?

julia> addition(1+1) ERROR:additionhas no method matching addition(::Int64)

I think a better example would be addition(1, 1) since it's not clear what point you're trying to make: that the number of arguments is not matched, or the type is not matched.

However, later on we have

In the same way, you can assign new values to it. However, these values have to comply with the
type's definition in that they have to be convertible to the type specified (in our case, Float64). So, for
instance, an Int64 input would be acceptable, since you can convert an Int64 into a Float64 easily. On
the other hand, an ASCIIString would not do, since you cannot convert it into an Int64.

And, of course, home = GeoCoordinates(1,1) works, but there's no detail explaining WHY this works as a constructor but it doesn't work for function arguments. (I admit I'm confused by this as well.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.