HN Gopher Feed (2017-08-26) - page 1 of 10 ___________________________________________________________________
New implementation of Git in OCaml
183 points by tosh
https://github.com/mirage/ocaml-git/pull/227___________________________________________________________________
avar - 9 hours ago
This implementation is freely licenced enough that the BSDs and
others that don't use Git for license reasons could use it.It would
be interesting to see an alternative implementation like this get
enough feature parity that projects like the BSDs could migrate and
still be protocol and worktree compatible so most users could
continue using the GPL2 implementation.Edit: Seems people here are
unaware that the BSDs treat GPL software like cooties, see e.g.
[1]. They wouldn't start using source control that gave them less
freedom than SVN, an with CVS there's the expectation that OpenCVS
might get finished.1. https://wiki.freebsd.org/GPLinBase
doozy - 7 hours ago
Unfortunately OCaml itself has its own weird licensing issues
being distributed under a combination of the QPL and GNU
licenses.Every few years I take a look at it, notice the license
and move on. There's no reason whatsoever for a language not to
have an implementation under a permissive license.
moron4hire - 4 hours ago
No, there's no reason to avoid the GPL for languages, because
you aren't building a derivative work of the language itself,
so it's licensing has no bearing on your software.
steinuil - 3 hours ago
That's not entirely true; GCC (and almost every other GPL-
licensed compiler) has a specific exception for its runtime
libraries that lets you distribute their compiled version
under any license [1].But for example, Ada Core's GNAT is
licensed under GPL but doesn't have that exception, which
makes the binaries it outputs be licensed under the GPL as
well, to make you buy the Pro version of the
compiler.https://www.gnu.org/licenses/gcc-exception-faq.html
Drup - 6 hours ago
The QPL is not used anymore. The OCaml compiler is GPL, the
OCaml standard library is LGPL with the OCaml linking exception
and the license of produced binaries is whatever the author
wants.If you still have issues with that .. I would really like
an explanation.
xfer - 5 hours ago
People just want reasons to complain about languages, see
also: racket, when they have nothing to complain about they
pick the license.
k__ - 9 hours ago
What's the problem with using GPL software if you don't want to
change it?
toast0 - 9 minutes ago
Who says they don't want to change it? Integration with OpenBSD
pledge or FreeBSD capsicum could be useful.
user5994461 - 8 hours ago
You can't use GPL code in non GPL software.
perlgeek - 8 hours ago
I thought you can't link to GPL Software in non-GPL
software?Shipping an unmodified copy of git and calling it
should be fine even in proprietary code, no?
marcoperaza - 7 hours ago
This is an open question. The GPL itself does not define
what constitutes a derivative work. The FSF does, however,
promote the view that linking does create a derivative
work, while simply calling an external binary in usual
cases does not. But that can't function as a hard rule.
Because I could just make a wrapper binary that handles all
of the scenarios I need a GPL'd library for, and then call
my wrapper executable from my proprietary code.
jahewson - 7 hours ago
> Because I could just make a wrapper binary that handles
all of the scenarios I need a GPL'd library for, and then
call my wrapper executable from my proprietary code.Yes,
you can literally do this. It's not a derived work
because your code is entirely independent of the GPL'd
code and the GPL can't possibly cover code that you wrote
independently. Simply interacting with some external
GPL'd program does not expose your code to any GPL
requirements.
marcoperaza - 7 hours ago
You can't just work around the GPL by placing a command-
line interface as a shim between your code and the
function call interface of the GPL'd library. I'm talking
about a contrived binary that just calls library
functions, forwarding command line parameters to the
arguments of that function as necessary.
michaelmrose - 5 hours ago
Can you substantiate that claim?
jahewson - 6 hours ago
Oh yes you can. The GPL gets its power from copyright -
the rights that the authors of the original software have
over their work. It does not and cannot place any
restrictions on any software that you write, unless you
literally incorporate the GPL'd source or binary into
your software, which a CLI interface does not. The same
would be true of an RPC interface.For example, many
databases are GPL'd and provide their entire
functionality over RPC. Many CLI programs are GPL'd and
(of course) provide their entire functionality over CLI.
Neither of these cases place GPL obligations on clients,
and it's no different for any given library which you
wrap with a CLI.
marcoperaza - 6 hours ago
The FSF disagrees with you. https://www.gnu.org/licenses
/gpl-faq.html#GPLInProprietarySy...A contrived wrapper
that is not an independently useful program does not
allow you to circumvent the GPL.You are leaning very
heavily on a technical distinction (linking vs. not
linking) instead of on a holistic analysis of what a
"derived work" is.
michaelmrose - 5 hours ago
Pretty sure the FSF can't magically extend what copyright
means to comport with what they think it ought to mean in
regard to free software.
adament - 4 hours ago
Now I am not a lawyer, but I think by analogy the FSFs
interpretation would also be needed to enforce the
CreativeCommons NoDerivatives licenses. Imagine someone
creates an interview-based documentary video series on a
controversial scientific topic say global warming and
releases it under a NoDerivatives license because they
are afraid that a clever edit of their videos would
present the topic incorrectly and they have made promises
to the scientists about how they will and will not
present them.Now imagine that I rather than edit the
video files themself create a playlist, in a (fictive?)
format which has the ability to play subsequences of the
linked files, and then creates a version of the series
which presents the complete opposite message of the
original. Would a court find this to be a derivative work
of the original videos? What if in my need to edit the
video I want to insert certain new short sequences, and
thus I distribute a second video along with the playlist,
but this video is useless in itself since it just
contains a number of short clips in sequence. Would this
video be considered a derivative work of the original -
remember it serves no purpose in itself except along with
the playlist and the original? To me it is not clear, but
if they are not derivatives, then this will practically
render the concept moot. Since most derivatives could
potentially be formulated as the original + a diff. Now I
would expect in this case that the combination of the
playlist + my video file + original series be considered
a derivative work, remember that in the arts transferring
a work from one format to another (a dramatization for
example) is considered to be a derivative work, even if
all the actors would be seen on stage to read from the
original book.As I read it, this is the center of the
FSFs argument. Now whether this would apply equally to
software I do not know. But I have a hard time imagining
that copyright is not as easily circumvented as you seem
to indicate.
zokier - 5 hours ago
FSF is neither authoritative nor unbiased source for
answer to this question. I'd like to see few court cases
that have gone through the motions before thinking this
subject to be settled.
yorwba - 8 hours ago
AFAIK, software for the BSDs is usually maintained in-tree, and
patched to integrate with the rest of the distribution. I don't
think including GPL-licensed software would be compatible with
the BSD license of the overall project. That doesn't mean you
can't use anything GPL, just that it can't become part of the
system.
_delirium - 6 hours ago
All the BSDs have traditionally included GPL'd software in
the base system, so I don't think many people share this view
(it's a possible interpretation of the GPL, but not a common
one). As one major example: every BSD until recently included
gcc in-tree, and OpenBSD and NetBSD still do.
gribbly - 9 hours ago
Hmmm... in what way does Git being GPL/LGPL cause licence
problems for the BSDs ?
teamhappy - 8 hours ago
I guess you'd want to be able to include it in your
distribution. FreeBSD for example includes svn (or svnlite or
whatever) so you can fetch/update the source and do a
buildkernel or buildworld without having to install any ports.
gribbly - 7 hours ago
But you can include Git in the distribution, it's a self-
contained program, it's license won't affect anything else it
ships alongside with.
teamhappy - 7 hours ago
> The FreeBSD Project aims to produce a complete,
> BSD-licensed operating system allowing consumers of the
> system to produce derivative products without constraint
> or further license obligations.
https://www.freebsd.org/internal/software-license.htmlAlso
https://www.openbsd.org/goals.html and
https://www.netbsd.org/about/redistribution.html#why-
berkele...
michaelmrose - 5 hours ago
If someone wanted to produce a FreeBSD derivative would
they really need to be able to ship a modified version of
git?
xyzzy_plugh - 2 hours ago
Probably not, but then it wouldn't be "Free".
gribbly - 5 hours ago
Ok, so it's license philosophy rather than any actual
license legality problematics, I can understand that.
jlg23 - 6 hours ago
It does affect the users' abilities to hack on the
software. Since BSDs are used a lot in commercial
environments this is a real concern for BSD-hackers.
[deleted]
rjsw - 8 hours ago
There isn't one single reason for avoiding use of GPL software
that is true for all BSD variants.Requiring OCaml in the base
operating system could equally be a reason to avoid this,
whatever licence is used.
throwawayjava - 7 hours ago
> Requiring OCaml in the base operating systemI'm not sure I
understand this concern in the majority use cases. Why would
you need an OCaml compiler installed?
messe - 7 hours ago
The base system is usually capable of compiling itself. If
the source for your base system is stored on a remote git
repository, and your implementation of git in your base
system is written in OCaml, you're going to have to use an
OCaml compiler to recompile it.
yen223 - 8 hours ago
I've been using OCaml for a couple of side projects, and I have
been absolutely blown away by the amount of power this language
provides. It strikes a nice balance between high-level
expressiveness, while not sacrificing on performance.I feel like
OCaml is one of the programming world's best kept secret - if it
had better tooling and better marketing, it could have taken over
the world. I'm cautiously optimistic about ReasonML for this
reason.
marmaduke - 6 hours ago
Agreed. I'm always looking for excuses to use it or F# at work
but rarely come up.
microcolonel - 6 hours ago
Threading is the one thing that's missing for me, in OCaml; they
may have added it, but it wasn't there last I checked.
yodsanklai - 6 hours ago
You have light threads (Lwt or Async) that are sufficient for
most purpose.
weberc2 - 6 hours ago
Project tooling and standard library are the two things keeping
me from using it. If they built Cargo for OCaml and improved the
standard library, I think people would flock to it. Although I
never seem to quite get used to the syntax...
yawaramin - 53 minutes ago
Maybe you'll have better luck with ReasonML syntax?
wenc - 5 hours ago
OCaml is great in itself, but in practical terms, it is only
great for limited dependency projects (this however doesn't mean
limited complexity--a Perl 6 implementation called Pugs was once
written in OCaml. FFTW's code generator is also written in
OCaml).In many projects where one has to "stand on the shoulders
of giants", OCaml has a limited ecosystem to draw from.A
practical compromise is F#, which is an ML language for the .NET
platform. And even with Microsoft's heft behind it and a rich
.NET ecosystem, F# is still a niche language used in finance and
a few other specific domains.A functional language "taking over
the world" is a tough proposition. That usually requires a strong
use-case (like scientific computing--and now data science--for
Python) and fungibility of expertise, which in turn calls for a
language with a very low barrier to entry.
eru - 1 hours ago
You are right about the difficulty of a functional _language_
taking over the world anytime soon. But as a consolation prize
we are seeing functional features making it into more and more
mainstream languages.Even people using eg C++ no longer look at
you too funny if you explain that you prefer all your variables
to be 'const'.
profquail - 4 hours ago
Minor correction: `pugs` was written in Haskell, not
OCaml.https://hackage.haskell.org/package/Pugs
noir_lord - 7 hours ago
Have you seen https://github.com/BuckleScript/bucklescript ?It's
outputted js is fantastic.
eru - 1 hours ago
OCaml even does relatively well compared to Haskell: OCaml is a
much simpler language with more predictable resource usage (space
and time), but still gives a sizable fraction of Haskell's
power.If you like Reason, you might also be interested in
BuckleScript.
josteink - 7 hours ago
> if it had better tooling and better marketingIt would known as
F# :)
thesmallestcat - 7 hours ago
Version incompatibility is a big problem for OCaml. Every time I
try to use it seriously, the recommended tools never seem to work
together on anything but the latest version. It's like Rust, but
without the "young language" excuse. My impression is that INRIA
is too eager to add features and tweak the language.Next,
everything builds so slowly, and just trying to set up Core,
utop, and ocp_indent is a trial in patience, watching the same
dep build again and again, confusion about OPAM switches.... nope
nope. OCaml/OPAMs's got a distribution problem. They've pushed
the complexity off to the end user and the experience is
terrible. Jane Street planting their flag on the language and
encouraging massive dependencies like Core, or shit like
"corebuild" is even worse. I would never depend on anything
OCaml-based on it unless it could be installed by my OS' package
manager (Arch/AUR doesn't count, because it builds). That rules
out most popular OCaml tooling, and ruins the development
experience.I'd prefer OCaml to Haskell, I find it more practical,
but I feel much better depending on Haskell-based software, which
generally "just works." As much as they're a wart, Haskell syntax
extensions are a real benefit. You can build new fancy Haskell
software with older GHC versions.
vvanders - 6 hours ago
> It's like Rust, but without the "young language"
excuse.Howso? Stable Rust has been nothing but 100% solid for
the past 1+ year I've worked with it.
[deleted]
thesmallestcat - 6 hours ago
Tools depend on Rust nightly. My points are more about the
respective ecosystems than the core languages. For instance,
getting up and running with RLS is a real hassle (in my
experience, but I'm sure it's improving).
vvanders - 3 hours ago
RLS is a pretty new thing and is very much a nice to have
but not in any way required. I haven't used it until about
a month ago. Racer worked just fine on Stable.I dunno,
maybe you had a bad experience but considering how well
Cargo and the stable compiler work I don't thing it's fair
to categorize Rust as never working correctly.
talex5 - 5 hours ago
> the recommended tools never seem to work together on anything
but the latest versionWhenever a package is added to the
repository, the CI tests (the latest compatible version of)
every package that depends on it to check everything still
works. However, non-current packages may break if they're
missing upper bounds (it doesn't check all previous
releases).However, since opam-repository is just a Git repo,
you can clone a known snapshot of it at some point in time and
keep using that. That allows you to continue using old versions
of packages without the risk of new software causing unwanted
upgrades.> My impression is that INRIA is too eager to add
features and tweak the language.That's strange. I've always had
the opposite impression - that they maintain compatibility at
all costs, including leaving sub-optimal APIs in the standard
library.> Next, everything builds so slowly, and just trying to
set up Core, utop, and ocp_indent is a trial in patience,
watching the same dep build again and againThe Core alternative
standard library is pretty huge, indeed (I don't use it). I
just tried installing all the tools you mention in a fresh
container:$ time docker run ocaml/opam:debian-9_ocaml-4.05.0
opam install core utop ocp-indent6:03.75elapsedSo, 6 min to set
up a dev environment with those tools. That installed 67
packages, so compilation took about 5 seconds/package on
average. I'm not sure why it would build the same dep twice - I
haven't seen it do that.
mcguire - 5 hours ago
"> My impression is that INRIA is too eager to add features
and tweak the language."That's strange. I've always had the
opposite impression - that they maintain compatibility at all
costs, including leaving sub-optimal APIs in the standard
library."When I started using OCaml, many standard library
functions weren't tail recursive---you couldn't get the
length of a list with more than ~10,000 elements, for
example. The library definitely seems like an afterthought
compared with the language. (And that would be why there are
so many of them.)
zoren - 3 hours ago
Why would you hold 10,000 elements in a linked list?
mcguire - 2 hours ago
I couldn't hold them in my cupped palms.
fsloth - 1 hours ago
That's just - for example - every point in 100?100 R^2
cartesian grid. 10k elements is not by any measure a
'large number of elements'.Just pick your algorithmic use
case for a good excuse to use list and not an array from
here:http://bigocheatsheet.com
eru - 1 hours ago
When you first write design your program, you might
indeed use a different data structure than a linked list
when you anticipate 10k+ elements.But often programs are
used long after they are designed, and it is great if
they can degrade gracefully as you move outside their
original design parameters.
mcguire - 5 hours ago
I largely agree with you on OCaml, which was one of my favorite
languages for quite a while and still is somewhere near the
top. Last I checked, there were 3 (?) standard libraries,
counting Core and the OCaml release.But,"I'd prefer OCaml to
Haskell, I find it more practical, but I feel much better
depending on Haskell-based software, which generally "just
works.""I take it you haven't been bitten by cabal? It's a
nightmare every time I touch it.On the other hand, I've been
using stack (https://docs.haskellstack.org/en/stable/README/)
with hakyll, which seems to improve the situation dramatically.
It's just that first build for a new project that's very slow.
yodsanklai - 6 hours ago
I've been working on a side project in OCaml and I can totally
relate. I'm an OCaml old timer and I find amazing the amount of
development that has happened recently. There's a lot of
ongoing development in the libs and the surrounding tools (more
so than in the language). I've spent a lot of time just to set
up my environment and I had to pin several packages to their
development version to make things work (jbuilder, merlin,
ppx...). Moreover, a lot of these tools lack proper
documentation, and it's difficult to get answers to your
questions since it's a very small community.
djs55 - 5 hours ago
I'm also an OCaml old timer and I think I can relate too. I
believe the recent tooling changes are going in the right
direction and will eventually fix several of these problems,
for example:There's a push to remove "optional dependencies"
which are the reason why opam dependencies rebuild again and
again: http://rgrinberg.com/posts/optional-dependencies-
considered-... For example in the Mirage project we've been
working on this https://discuss.ocaml.org/t/ann-major-
releases-of-cohttp-con... but it has caused some breakage
here and there.jbuilder (from Jane Street) is excellent:
expressive, easy to understand, builds packages extremely
quickly, is actively developed, has minimal dependencies and
a lovely manual http://jbuilder.readthedocs.io/en/latest/ It
takes care of generating boilerplate for other tools like
merlin (which to be honest I never got around to manually
configuring). There's also work to integrate it with utop
https://github.com/janestreet/jbuilder/issues/114jbuilder
also supports building multiple libraries in one big source
tree, so we could switch to a package lockfile model: the
author uses opam to create a solution to the package
constraints and checks in the specific versions known to
work, the build clones the dependency sources and jbuilder
builds it all simultaneously. I'm keen to try this on one of
my larger projects so that "git clone; make" just works,
irrespective of where the host OCaml comes from.PPX syntax
extensions depend on specific compiler versions, so when (for
example) homebrew updates to OCaml 4.05 you might find that
extensions you need have not been ported yet. ocaml-migrate-
parsetree aims to fix this problem
http://ocamllabs.io/projects/2017/02/15/ocaml-migrate-
parset...There's obviously still plenty of work to do, but I
think things are improving!
yodsanklai - 4 hours ago
Yes, I agree that things are going in the right
direction.But a lot of things I'm trying to use aren't
quite there yet. You mention jbuilder and the generated
.merlin... it just doesn't work with current opam packages
(at least not with ppx - I'm not doing anything fancy, just
basic project with core). To fix this, I had to learn about
opam pinning features, and then I had to carefully choose
the jbuilder commit that works (the one after the bug has
been fix, but before it breaks the compilation of bin_prot
that I also use) and so on... As for Merlin, it's great,
but the documentation is minimal. When it doesn't work as
expected, it's hard to find where to look.Core and Async
are great, but besides 'Real World OCaml' that is a bit
outdated and insufficient, there is little documentation
and not much help on Stack Overflow.That being said, I'm
not complaining and I'm grateful to the guys developing
these tools. But I think newcomers should expect some
difficulties if they want to do anything serious using
these most recent tools.
marmaduke - 6 hours ago
The opam is pretty new. When I looked at OCaml a few years back
my phd work, it didn't exist, so there's some churn in the tool
chainI think your overstating the pain though. Even in other
languages, best practice demands you pin a library version so
you wouldn't have some of those issues.
thesmallestcat - 6 hours ago
OPAM was released in 2013 and I recall it being mainstream by
2014. Maybe I am overstating the pain, but I've jumped
through hoops for plenty of languages, and OCaml stands alone
here. As somebody who's pretty good on the command line and
at solving installation issues, the thought of a junior
developer trying to get started with OCaml gives me shivers
(probably another impetus for Facebook's Bucklescript).
cies - 3 hours ago
> Facebook's BucklescriptI think you mean FB's ReasonML.
Buckle is Bloomberg's OCaml-to-JS compiler.
sandGorgon - 9 hours ago
I was in two minds about attending FunctionalConf in Bangalore,
India ... but after seeing this PR, I'm
there.https://confengine.com/functional-
conf-2017/proposal/4052/gi...
joshmarlow - 9 hours ago
If OP interests you, then this may too: https://pijul.org/IIRC,
when I last looked at this, they were doing dual implementations in
OCaml and Scala, but now it looks like it's being done in Rust.
logingone - 6 hours ago
I thought there might be some comments on darcs in here. I've only
just started learning OCaml so haven't yet used darcs, but am
looking forward to trying it out.
marmaduke - 6 hours ago
Darcs is interesting but not same system as Git.
logingone - 2 hours ago
Yes, the first two lines of the front page: "Darcs is a free
and open source, cross-platform version control system, like
git, mercurial or svn but with a very different approach"
altotrees - 7 hours ago
This is fantastic. I have played around with Clojure and Haskell a
bit, but really want to get into functional programming more. Not
to hijack the thread, but I guess I am having trouble getting
started. Any good resources for novices out there?Edit: for the
record I have Googled the topic and am overwhelmed by how much is
out there. Looking for personal recommendations.
yen223 - 7 hours ago
I highly recommend https://fsharpforfunandprofit.com/. F# is
spiritually similar to OCaml, so there's a lot of crossover
there. This is geared towards "enterprise" developers, and so
tends to be more pragmatic than most other resources.For what
it's worth, I got a surprising amount of mileage from learning
Idris[0], of all things. Even if you ignore the dependent type
system, it is still essentially Haskell but with a lot of the
warts removed, making it much simpler to grok.Beyond that, the
usual recommendations apply: Learn You a Haskell[1], and Real
World OCaml[2] were what got me started.[0] http://docs.idris-
lang.org/en/latest/[1] http://learnyouahaskell.com/chapters[2]
http://dev.realworldocaml.org/
gilmi - 7 hours ago
If you want to learn Haskell the most recommended book nowdays is
Haskell Programming From First Principles[0].[0]:
http://haskellbook.com
eru - 1 hours ago
The consensus on the Haskell subreddit was that the Haskell
Wikibook (https://en.wikibooks.org/wiki/Haskell) has gotten
even better than "Haskell Programming From First Principles".In
any case, that book ain't bad either. It's better than Learn
You A Haskell.I also like "Discrete Mathematics Using a
Computer" (https://github.com/ryukinix/discrete-
mathematics/blob/master...). It focuses on teaching discrete
mathematics and introduces some Haskell as executable
mathematical notation on the side.
nuclx - 5 hours ago
Real World Haskell[0] is the best freely available resource
imho.If some concepts remain unclear, Learn You a Haskell[1] is
a good complement, though it doesn't go as deep as Real World
Haskell. For example there is no coverage of monad
transformers, which is a pity.Typeclassopedia[2] is a great
overview of common category-theoretic abstractions used in
Haskell programs.[0] http://book.realworldhaskell.org/read/[1]
http://learnyouahaskell.com/chapters[2]
https://wiki.haskell.org/Typeclassopedia
gaius - 2 hours ago
RWH chapters 1-3 are great. It goes a bit weird from chapter
4. LYAH is better IMHO.
joshmarlow - 6 hours ago
The way I first learned to think functionally was reading and
working through http://realmofracket.com/ It intros you to
Racket, which is sort of a Scheme dialect (which is a Lisp
dialect) and teaches functional programming.Haskell, OCaml, etc
take those functional idioms and apply strong typing, algebraic
data types, pattern matching and something like the Option/Maybe
type - but they build on the same functional concepts in Realm of
Racket.Caveats to the above:1) Racket has an optional 'typed'
variant which gives you type checking.2) Rust is (IMHO) a little
weaker with regards to pure functional programming than OCaml,
but very nicely integrates pattern matching, type checking and
algebraic data types in.
sbov - 6 hours ago
As an FP newbie, for Clojure, I used
https://www.braveclojure.com/ to start with.When I wanted to
build something beyond a toy program,
https://pragprog.com/book/vmclojeco/clojure-applied helped me
immensely. It goes beyond "what you can do" and delves into
"when you should do it". IMHO every language should have a book
like this.
arunc - 7 hours ago
Functional programming in D could be a good start for youhttp://b
eza1e1.tuxen.de/articles/functional_D.htmlhttps://tour.dlang.org/
tour/en/gems/functional-programming
a0 - 7 hours ago
There?s a beginner?s guide to OCaml?s beginner?s guides:
http://blog.nullspace.io/beginners-guide-to-ocaml-beginners-...
yawaramin - 47 minutes ago
IMO, the best functional programming resource out there is this
free online course by Prof. Dan Grossman at UW:
https://www.coursera.org/learn/programming-languagesHe focuses on
teaching the syntax, semantics, and idiom of Standard ML, a
classic functional programming language that's closely related to
OCaml, Haskell, and others. He has a gift for explaining simply
and clearly and keeps his lecture videos short (~10min) which
helps to absorb their info. Check it out:
https://www.coursera.org/learn/programming-languages