News for hackers. Stuff that matters.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by GreaterFool on Wednesday March 18, 2015 @02:56AM (#9224005)
It is not hard to write code in Racket or Clojure; what's hard is maintaining it!

I've written a small Clojure project, maybe 3k loc. It was great fun. But when I go back to add small features I find it quite tricky. Bugs often sneak in.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by TeMPOraL on Wednesday March 18, 2015 @09:12AM (#9225159)
I have an opposite experience with Common Lisp. Yes, I tend to make bugs in it, but I tend to fix them so quickly I don't really mind. SLIME is godsend.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by biesnecker on Wednesday March 18, 2015 @05:51AM (#9224433)
I think maintaining old software is a known problem, regardless of the language. What about lisps make them more challenging in this regard?
Re:John Carmack: “I just dumped the C++ server I wrote for a... by GreaterFool on Wednesday March 18, 2015 @07:23AM (#9224721)
Lack of types.

I don't want to start a discussion here on typed vs untyped so please consider everything I say to be qualified "It is only my personal opinion and experience".

I'm writing Haskell in my day job, Clojure for fun side project, OCaml because it's a nice language that's a bit underused and C++ because it's useful to know and not so evil as most people say (and it's progressing fast!). I should throw Rust into the mix because it might have a bright future.

WARNING: personal opinions and anecdotal evidence ahead!

Maybe there's a level of lisp enlightenment that I haven't reached yet but I can't just get by with writing lisp without writing tests. On the other hand I can get by with writing Haskell and OCaml without writing tests.

This is particularly true when I'm coming back to a project that I haven't touched for a few weeks. I change something and something breaks. In Haskell and OCaml I change something and compiler complains.

Maybe we'll see HaLispML one day.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by jacobm on Wednesday March 18, 2015 @08:59AM (#9225087)
The types objection may apply to Clojure (I've never used it, I don't know) but one of Racket's major development thrusts has been providing a way to get the benefits of both typed and untyped languages.

* Racket has a sophisticated contract system that allows you to enforce "type-like" properties at runtime very easily (e.g., you can say "This function should behave as an ((int -> int) -> int) function" and it will do all the necessary runtime checks to make sure that contract is honored as your program executes)

* It also has an optional modern type system, Typed Racket, that you can opt into on a per-module basis. Typed Racket modules can interact with untyped modules safely via contracts. The Typed Racket type system was designed specifically so that it's easy to migrate untyped, idiomatic Racket code to the type system, so you can write untyped Racket code idiomatically, and then go back and port your untyped module to Typed Racket with a minimum of fuss and get the benefit of the type system.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by steveklabnik on Wednesday March 18, 2015 @09:39AM (#9225330)
Clojure has Core.Typed, which lets you add optional typing.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by ufo on Wednesday March 18, 2015 @09:51AM (#9225417)
Core.Typed is directly inspired by typed racket :)
Re:John Carmack: “I just dumped the C++ server I wrote for a... by kyllo on Wednesday March 18, 2015 @09:59AM (#9225468)
Does Typed Racket give you a way to run your whole program through a typechecker without executing the code? Because catching type errors at compile time is a major benefit you get from a static type checker, that you wouldn't get from just runtime type checking.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by samth on Wednesday March 18, 2015 @10:17AM (#9225599)
Typed Racket operates on a per-module basis -- only some of your program has to be typed. But it's entirely static -- errors are caught at compile time.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by agentultra on Wednesday March 18, 2015 @01:51PM (#9227337)
As others have noted and in my own limited experience picking up OCaml -- a static type system does not solve the problem you need unit tests and functional tests for. They're good for readability if you explicitly annotate everything (and forgo the type inference) and they're good for flushing out a whole class of run-time type errors. But that's about all.

At this point in my learning it's more about pleasing a SAT solver than getting anything useful done... but I'm sure that will change with time.

Common Lisp does have a type system... it's just dynamic so you can hit things at run-time. This is great in development because it allows you to under-specify things that aren't terribly important (like types) at that time. However when you begin to find your code is ready to be locked in place you can annotate your function to hint to the implementation what the types should be. In particularly well-tested and heavily-typed code you can even turn off dynamic type-checking entirely for your production builds and get the performance boost from that.

Regardless of your approach and requirements, tests have a completely different use beyond ensuring type consistency. They set expectations, inform API design, and catch mistakes in refactoring; they act as a specification for the module under test. I've had plenty of OCaml code compile that still failed tests. Even in the presence of strong static typing you need unit, integration, and regression tests.

Just food for thought.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by swah on Wednesday March 18, 2015 @08:16AM (#9224890)
At some point, I thought OCaml would be the NBL since the writing part was fun and easy due to type inference (mostly, I hate using +.) and the refactoring felt safe.

BUT those guys are much smarter than us... so creating a language that combines the qualities of dynamic and static languages is probably a hard problem.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by cwyers on Wednesday March 18, 2015 @10:50AM (#9225853)
F# isn't exactly OCaml, but it's a close relative and... I don't know if it's the next big language, but it feels like it's one of them.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by swah on Wednesday March 18, 2015 @02:13PM (#9227499)
Haven't you heard? Javascript is the NBL :(
Re:John Carmack: “I just dumped the C++ server I wrote for a... by mordocai on Wednesday March 18, 2015 @10:44AM (#9225807)
> On the other hand I can get by with writing Haskell and OCaml without writing tests.

Well, I never want to have to maintain one of your Haskell or OCaml projects. If you think you can get by with any language without tests you are wrong.

That being said, yes it is easier to deal with lack of tests in a staticly typed/compiled language than in a dynamic language like clojure/ruby/python/perl/etc.

The main point I'd like to make to you is you aren't complaining about Clojure per say, you are complaining about dynamic languages in general. It just so happens clojure is the one you are picking on.

Either way, you might like Shen (http://www.shenlanguage.org/) though it is very much academic and has few tools around it, it is very much a HaLisp, though i'm not sure about the ML part.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by bad_user on Wednesday March 18, 2015 @09:05AM (#9225120)
I'm a Scala developer and I use its type system to approximately its full potential and I prefer it to other languages precisely because of its static-ness. With a powerful type system you effectively eliminate certain problems from happening, like I once had a bug that I couldn't understand, yet I eliminated the possibility of it happening. And I prefer it precisely because I'm not smart enough for the problems I'm working on, so I prefer having a static type-system holding my hand.

That said ...

> On the other hand I can get by with writing Haskell and OCaml without writing tests

Tests and static type-safety serve different purposes. If you end up writing tests for properties that should have been inferred by a static compiler, then you're using the language in a wrong way or you've picked the wrong language for the problem at hand.

When working with a dynamic language, I don't need to write tests just to see that my code works. It's because I work with a REPL and in terms of happy paths, that's just as effective as having a static type system.

And surely having a compiler is very cool when refactoring, however we tend to miss the fact that (a) the kind of refactorings we are doing are very superficial and for architectural / design refactorings the compiler doesn't save you and (b) in a dynamic language there is less need for refactoring, because you don't end up modelling the whole world through types.

> I don't want to start a discussion here on typed vs untyped

I'm also thinking you're making a confusion. Dynamic languages can be strongly typed. A language Clojure is very much typed. The difference is in the moment those types are used, at compile time or at runtime.

This is important, because a dynamic language like Clojure can do optional typing when you want it. Of course, something like core.typed will never be as expressive and potent as Haskell's type-system, however this leads to gradual evolution - at first you don't have a well defined shape for the data you're working with, so you can enjoy the relaxed rules and protocols of Clojure and afterwards you can start introducing type definitions with core.typed or with prismatic/schema.

As I said, I'm a developer that leans on the static side of the argument, however this debate will never be settled simply because which tool is the best depends on the problems you're trying to solve, therefore people will never agree on anything, because people are always thinking from their "personal experience".

Re:John Carmack: “I just dumped the C++ server I wrote for a... by bmh100 on Wednesday March 18, 2015 @08:36AM (#9224955)
Have you tried typed Clojure [1]? It seems promising for bringing in types.

[1]: https://github.com/clojure/core.typed/

Re:John Carmack: “I just dumped the C++ server I wrote for a... by GreaterFool on Wednesday March 18, 2015 @10:08AM (#9225535)
I tried core.typed and I think it's pretty cool. However, if you're using external libraries in your typed code you'll need annotations for those libraries too.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by bitwize on Wednesday March 18, 2015 @07:10AM (#9224662)
For one, static typing is optional in Lisp -- if it's even there at all.

If you want to write maintainable code and catch bugs early, that pretty much rules out dynamically typed languages.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by ayrx on Wednesday March 18, 2015 @07:13AM (#9224679)
Are you implying that it's impossible to write maintainable code in any dynamic language?
Re:John Carmack: “I just dumped the C++ server I wrote for a... by pjc50 on Wednesday March 18, 2015 @08:22AM (#9224907)
Dynamic languages rely on test suites to catch bugs. The test suite is also software that must be maintained.

Statically typed languages apply typechecking as a "test" to the entire program at load time.

People have written and maintained code in typeless assembler, including for mission-critical systems. It's just more work and requires a different kind of rigor. The larger and more complex your system gets, the more useful typechecking becomes.

"Maintainable" is not a boolean, it's a cost function.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by GreaterFool on Wednesday March 18, 2015 @07:31AM (#9224742)
In lisp you have the power to easily invent abstractions. Strip things down to a bare minimum and you can see that your code is good. And write some tests just in case.

OTOH in strongly typed languages with rich type systems the actual code might be uglier and more complicated because you're constructing a proof of something. The property might be week (tests needed!) or strong (tests? what tests). Depends how far the rabbit hole you want to go.

At least that's my view on this.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by kd0amg on Wednesday March 18, 2015 @09:29AM (#9225261)
uglier and more complicated because you're constructing a proof of something

It's rare for the programmer to actually produce proofs that a piece of code meets the spec given by its type[1]. Those proofs are generally produced by the type checker, possibly with occasional hints from the programmer.

1: Even in Coq, detailed specs for some code are typically given (and proven) separate from the code itself rather than in that code's own type.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by s_kilk on Wednesday March 18, 2015 @08:44AM (#9225000)
Not impossible, but in my experience it takes disproportionately more work than if you have a decent type-system to help you out.

In a dynamically typed system, every expression and line of code is a liability, and requires a large weight of tests to have any confidence that it might work.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by mpdehaan2 on Wednesday March 18, 2015 @08:03AM (#9224840)
Type errors in programs don't come up nearly enough to warrant languages completely dwelling on them so much. Now, say, consistent argument order does help a lot if you are writing your own libraries, but I wouldn't place the blame there on the language.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by rkrzr on Wednesday March 18, 2015 @08:59AM (#9225082)
Type errors come in more shapes than the obvious one: e.g. Untyped data structures like dictionaries are a frequent source of error in Python (KeyError e.g.) or non-uniform lists. These are pretty common bugs, I'd argue, which simply cannot happen in statically typed languages like Haskell.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by bitwize on Thursday March 19, 2015 @10:33AM (#9232164)
No, but depending on the size of your code base and your available budget, it can get prohibitively expensive really quickly.

Static typing eliminates entire classes of bugs. The cost of the up-front inconvenience to the programmer is tiny compared to the ongoing maintenance costs of possibly-incorrect, we-won't-know-for-sure-until-that-code-path-executes-in-production dynamically-typed code.

This is dependent on many variables but a good rule of thumb is that for any project bigger than a doddle, it's a safe bet to just fucking use a statically typed language.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by s_kilk on Wednesday March 18, 2015 @08:41AM (#9224982)
I tend to agree. I've had great fun banging out programs in Clojure, but the lack of types makes coming back to fix bugs or extend the program quite unpleasant.

I'm doing a lot more Scala these days, which feels a lot easier to work with in the long run.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by Jare on Wednesday March 18, 2015 @09:01AM (#9225095)
That has been my very limited experience as well, but with Scala I'm still things will get out of hand. The only "new" language I feel confident would not disappoint or surprise me negatively down the road is Golang.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by ibebrett on Thursday March 19, 2015 @07:51AM (#9231252)
What makes you think that? I have had the opposite experience with Scala/Haskell
Re:John Carmack: “I just dumped the C++ server I wrote for a... by Jare on Sunday March 22, 2015 @08:19PM (#9248811)
The language is large, supports multiple paradigms and in general allows many different ways to express the same thing. That's great for short term productivity and/or small and tightly knit teams, but I worry about less ideal conditions. In theory a strict and well defined style guide should take care of that (I have used them successfully in C++), but I feel with Scala that will not be enough. Expressed differently: Scala is a great language for smart and careful programmers, but a ticking bomb for the less talented masses.

Golang, in comparison, is very transparent, WSYIWYG.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by Adrock on Wednesday March 18, 2015 @06:43AM (#9224585)
How many lines were tests?
Re:John Carmack: “I just dumped the C++ server I wrote for a... by Adrock on Wednesday March 18, 2015 @08:55PM (#9229646)
I'll just assume that the answer to the question is expressed in points it earned.