6 ms·
Show HN: PDF parsing in Racket, my weekend project
- jonathansizz 15y agoThis is excellent. Having recently discovered Racket, it has become my language of choice for personal projects. It has been a revelation to me after a lengthy false start with Haskell ultimately led nowhere. Racket really deserves a lot more recognition and visibility: the language builds on the traditional strengths of Scheme and adds multiple compatible and innovative language dialects, first-rate documentation, extensive libraries, a great IDE and other tools, along with an active and enthusiastic community. I really hope Racket grows in popularity and we keep seeing more stories like this, as the developers deserve praise for what they have created. And of course, HN is built on it too!
- dsrguru 15y agoRacket really is an awesome language. When you want a LISP that you can optimize to get near-C performance, go with Common Lisp. When you want a LISP that does concurrency more concisely than Scala or Erlang, go with Clojure. But for literally anything else, you probably want Racket. Don't forget to add its ridiculously awesome continuation-based web server to your above description!
- elibarzilay 15y agoThese days Racket is on a similar performance level as many lisps, and it also has three kinds of concurrency for you to choose from.
- Peaker 15y agoWhat kind of difficulties did you encounter when you tried Haskell?
- jonathansizz 15y agoUltimately, I never reached the point where I could build anything much beyond toy programs. Haskell is a beautiful language full of great ideas, and I certainly learned a huge amount from wrestling with it, but eventually I decided that I wasn't really progressing as I wanted, and most importantly I was getting frustrated rather than having fun (e.g. constantly fighting against the type system and the cryptic error messages it produces). I don't have a CompSci background, which may have made things more difficult, but I know Haskellites who are computer scientists, and have stronger mathematical backgrounds than I have, and many of those guys told me it took months of effort and several attempts before they were truly comfortable with the language. In contrast, Racket feels like it's on my side, like it will help me to grow as a programmer rather than forcing me to grow on my own. I was able to start writing useful (but simple) stuff almost immediately, but at the same time there's plenty of scope to learn more sophisticated techniques and approaches later on. There's even a typed Racket dialect (http://docs.racket-lang.org/ts-guide/index.html http://docs.racket-lang.org/ts-guide/index.html)! I may look at Haskell again in the future, but at the moment I'm very happy with Racket.
- dons 15y agoThe phrase "fighting against the type system" usually indicates some misconceptions about the language -- the approach is to program with the type system as a tool to help you get the right code written, sooner. Approach it more as a thorough personal assistant, than a mean boss.
- Peaker 14y agoThe learning curve of Haskell can indeed be daunting. It took me about 4-5 months to get comfortable with Haskell, and a couple of years to make it the language I'm most comfortable in. GHC type errors can also be very frustrating. But I agree with dons that unless you're doing very advanced "type hackery" at the edges of what it can do, you really aren't "fighting the type system", just fighting the difficult error messages. I do find that months of investment into a crucial tool such as a programming language is worth it for anyone who careers in programming. I can testify that with time, the amount of type errors becomes much smaller, and that you start to smell GHC error messages a mile away :) That is, when seeing an error message, the cause is usually immediately clear simply by having been trained to see that same error message many times. When I do rarely happen to struggle with a type error, it is a real bug, whose debugging in many cases would have been more frustrating in run-time.
- prezjordan 15y agoAs a sort of beginner to functional programming, could you explain to me why you chose a functional language to do this sort of thing? Just for fun? I love it but I can't see the benefits of functional programming.
- pavpanchekha 15y agoIt's not a functional programming language. It isn't Haskell or Coq. It's Racket, a derivative of Scheme, which happily supports mutable or immutable state, monads or continuations, imperative, procedural, functional, object-oriented, or logical programming.
- jgn 15y agoIt's not a PURE functional language, but it's certainly functional.
- mahmud 15y agoRacket also has an Algol mode :-P
- Locke1689 15y agoIt also has a dataflow language, a typed language, a lazy language, etc. Racket is not one language, it's a language family platform (or language laboratory). Matthias summarized this pretty well[1]. [1] http://www.ccs.neu.edu/home/matthias/Thoughts/Racket_is____.html http://www.ccs.neu.edu/home/matthias/Thoughts/Racket_is____....
- mahmud 14y agoI found that essay most enjoyable. Thank you for the link, mate! :-)
- dsrguru 15y agoThat just becomes a debate about the definition of a functional language. The point is that unlike Haskell, SML, and OCaml (the last two aren't "pure" in the sense of syntactically enforcing referential transparency like Haskell, but they strongly encourage a functional design), Racket is first and foremost a LISP. You can use it to write and make use of a lot of functional abstractions, and it certainly is better suited to that style of programming than C or Java is, but Python and Ruby are just about equally suited for that style of programming, and they even have equivalents of map, filter, fold, lambda, etc. Racket code doesn't look like Haskell, the MLs, or even dynamically typed "functional" languages (like Erlang). It looks like LISP. What drives your coding is not functional abstractions or object-oriented data structures (which it can do equally well) or anything like that. What drives your coding is the fact that syntax itself is a first-class data structure. You have access to the reader. You can write macros that adapt the language to anything you want. You can write a DSL in a few hundred lines that might save you tens of thousands of lines. Now, Racket is certainly good for functional programming. In fact, some Racket developers prefer the Scheme-style tail recursion method of iteration (via the named let or letrec) to the looping constructs provided in the library, even when for loops would be just as effective. In the same way, not all Common Lisp programmers like the loop macro, and some (e.g. pg) actually use Common Lisp in a style that resembles functional programming. However, don't think of Racket as a functional language. That's as misleading as calling C++ a procedural one, even though you could write all your code C-style without ever using objects. Racket is a LISP, which means it can be adapted to fit virtually any paradigm. Racket is far closer to Common Lisp and Clojure than it is to literally any non-LISP.
- exim 15y agoThis is great of course, but I'd be more happy to see the actual PDF renderer with a more permissive license than GPL.
- gcr 14y agoI would too, but - To my knowledge, there are no sane C-based PDF renderers with a permissive BSD-like license - Poppler renders to Cairo --- a _huge_ win because I don't actually have to do anything to convert Cairo surfaces to Racket's native drawing type - I don't know / don't have the time to implement my own PDF reader/parser from scratch.