HNHacker News
TopNewBestAskShowJobs

bad_login

46 karma · joined February 8, 2014

submissionscomments
bad_login··on A Visa for founders, engineers and investors willing to join France
I am french here is my earnings:

24000€ of gross (the company pay ~0.30 * 24000 = 31200€). 18360€ (1530€/month) is my income but on that i pay ~1000€ of taxes (salary tax) and ~400€ of city tax(this vary from city to city).

My rent is 360€/month for 60 square meters, sure i live in the middle of nowhere regarding jobs.

After all the mandatories costs of life i can save ~550€/month ~6600/year.

bad_login··on Racket Language – New website design
> I don't want to learn languages, I want to solve my problem.

I think the idea is that there is one good approach to solve a given problem (eg: use class to do the GUI code, use match to traverse some xml, use thread for async io instead of an event loop approach).

bad_login··on Concurrency has landed (emacs-devel post announcing the new threads feature)
You should up your joke to 2016:

Emacs is now a proper web browser.

bad_login··on Comparing Haskell and Node concurrency performance
preemptive green thread solve that.
bad_login··on PHP 7.1.0 Released
> When you use proper opcode caching, you avoid the startup hit.

In a setup with nginx, php-fpm and symfony here is how i understand the whole process.

  1. A request hit nginx
  2. Nginx parse the request and send it as fastcgi protocol specify to
     php-fpm.
  3. Php-fpm looks it's pool of php processes if there is none
     available, it starts a php process (so some code is run).
  4. Php-fpm fill the $_GET,$_POST etc... variable of the running php
     and give it a file to execute.
  5. The php process check if the file is in opcache load the bytecode
     from it otherwise compile the file to bytecode and store it to
     opcache.
  6. The process run the script and write back to php-fpm who write back to nginx.
  
  So now more on 6. from the point of view of a Symfony app.
  
  1. the app.php will include an autoloader, this mean during the
     lifetime of the php process every time a new
     \Some\Class\Or\Function\Or\Whatelse is encounter the autoloader
     code will be run. To mitigate this composer could generate an
     autoload that is an associative array of \ClassName\And\The\Like =>
     filename.
  2. Then it include the bootstrap.cache.php this file is a
     concatenation of the Symfony classes (all or the most used) in
     order to reduce autoloader calls.
  3. Then it create the kernel the it load more file (from app/cache)
     like the service container definition+configuration and the
     routing (and maybe more stuff but i don't know).
  4. Then it put $_GET,$_POST etc... on it's own abstractions
     (HttpFoundation\Request etc...).
  5. At this point the bootstraping is done.
  
  And i also want to remind that a class declaration like "class House
  {}" is a code, that create a datastruct that has to be run on every
  request, this is also what people call bootstraping.
  
  The bootstraping is take seriously enough to have :
  
  1. composer -o (generate the associative array)
  2. bootstrap.cache.php
  3. the whole app/cache directory of symfony which i find pretty
     terrible as comp. sci. point of view (choose a limited language and
     build compilers to work around) even if they do a great job at
     error reporting.
  4. php-fpm pool of thread
  5. opcache
bad_login··on GNU Guile 2.1.4 released
In what ways having call/cc for free is usefull?

The use of call/cc i see in real programs i am aware of is green threads.

bad_login··on Show HN: “OK Google” – Explore Google Now voice commands
Real hipster used a the service of a professional Griot.

https://en.wikipedia.org/wiki/Griot

bad_login··on Erlang Scheduler Details and Why They Matter
FYI racket and gambit VM use preemtive green thread, but they have nothing to do with SMP.
bad_login··on Let's Write Some Bad Ruby
Before i thought mastering regexp were a must to have in a day to day programmer job to quickly modify data with different syntax.

Now i am still convinced that regexp are still usefull but you will not get it right for the first try due to syntax corner case. The best solution in my opinion is to have easy to use parsers including one for your main programming language.

Actually i emacs with its macro feature (not elisp) + racket with regexp (didn't mention earlier but having a strong repl for this kind of incremental script is also a must to have) and sometimes parsers.

bad_login··on Boris – A tiny REPL for PHP
I tried boris and psysh at work but they both failed when i wanted to redefine a function or a class.
bad_login··on Show HN: Pgcli – A CLI for Postgres with auto-completion and syntax highlighting
I have build https://github.com/antoineB/emacs-assistant to work with sql-mode it provide a simple completion for table and columns.

For now it serve me well.

bad_login··on ARMv7 vs. x86-64: Pathfinding benchmark of C++, D, Go, Nim, Ocaml, and more
I just made the code a little more idiomatic - avoided using the box arount max - used a named let for loop and made it terminal recursive

removed the box improve performance from 10s to a 9s.

  #lang typed/racket

  (struct: route ([dest : Integer] [cost : Integer]) #:transparent)

  (struct: node ([neighbours : (Listof route)]) #:transparent)

  (: str->int (String -> Integer))
  (define (str->int str)
    (define n (string->number str))
    (if n (numerator (inexact->exact (real-part n))) 0))

  (: read-places (-> (Vectorof node)))
  (define (read-places)
    (define lines
      (file->lines "agraph"))
    (define num-lines (str->int (car lines)))
    (define nodes (build-vector num-lines (lambda (n) (node `()))))
    (let loop ([i : Integer 0])
      (define nums (string-split (list-ref (cdr lines) i)))
      (define len (length nums))
      (when (and (> len 2) (> (length lines) (+ i 2)))
          (let ([node-id (str->int (list-ref nums 0))]
                [neighbour (str->int (list-ref nums 1))]
                [cost (str->int (list-ref nums 2))])
            (define new-node (node
                              (append (node-neighbours (vector-ref nodes node-id))
                                      (list (route neighbour cost)))))
            (vector-set! nodes node-id new-node)
            (loop (+ i 1)))))
    nodes)

  (: get-longest-path ((Vectorof node) Integer (Vectorof Boolean) -> Integer))
  (define (get-longest-path nodes node-id visited)
    (vector-set! visited node-id #t)
    (define sum
      (foldr
       (lambda ([neighbour : route] [max : Integer])
         (if (not (vector-ref visited (route-dest neighbour)))
             (let ([dist (+ (route-cost neighbour) (get-longest-path nodes (route-dest neighbour) visited))])
               (if (> dist max)
                   dist
                   max))
             max))
       0
       (node-neighbours (vector-ref nodes node-id))))
    (vector-set! visited node-id #f)
    sum)

  (define nodes (read-places))
  (define visited : (Vectorof Boolean) (build-vector (vector-length nodes) (lambda (n) #f)))
  (define start (current-inexact-milliseconds))
  (define len (get-longest-path nodes 0 visited))
  (define duration (- (current-inexact-milliseconds) start))
  (printf "~a LANGUAGE Racket ~a\n" len (inexact->exact (floor duration)))
bad_login··on Why Racket? Why Lisp?
I ditch clojure because i wanted something with a more meta-language capabilities (syntax object + racket macro), it also as a llar parser and a lexer lib which i needed when i made the choice.

For the libraries you can checked out yourself at http://pkgs.racket-lang.org, for what i do i don't need one of the library.

For concurrency keep in mind that racket use green thread where clojure use jvm thread so OS thread in openjdk.

I don't what you want to do with clojure, but i think it is a best choice than racket. Clojure as a very opiniated way of how you should write a program and this view reflects in propably every clojure library. The documentation in clojure is lacking but it provide the implementation (on the web page) so the learning is imho faster especialy if you are new commer to functional programming. The other advantage is the leverage it get from the jvm in term of performance use of the java lib.

bad_login··on Why Racket? Why Lisp?
For 4 if i run from the command line (racket 5.93) i just get the contract violation message, which don't provide positional informations, it's not usefull when you have a list contract error with dozen of uses in a file.

For 3 i mean the words like 'visiting', 'instantiated', the phases, the syntax transformer there are many things to grasp. For instance i used to believe that phase 1 bindings where the functions executed by the expander instead of the one defined by define-syntax.

For complex macro i just expand it that's fine.

Other point the continuation is hard to grasp, i really understand when i see http://www.infoq.com/presentations/continuations-web-os, the key point that help me is the fact he mentions continuation capture also the exit.

Another flaws i didn't mention is messages of typed/racket could be hard to understand especially one involving parametric function, this problem occur time to time in the mailing list. I know you take this kind of problems seriously.

A point why i like racket is because it's lexical scoped but also let me precise the portion i want more dynamism in with parameters or with eval + namespace.

Racket also miss some tooling the one come in mind is coding standard checker and formater, it could be done with free-identifier=? and have some rules. New macro could write their associated rule as metadata in a submodule. Is it doable, i mean technically not the fact to expect macro writer will write such rules?

bad_login··on Why Racket? Why Lisp?
It seems most people here have never used (and not tried) racket.

I decided to use racket for my little sides projects, as replacement for scala and clojure.

I choose it because it was clear for me i can't stand limitations other language impose to me in way of style and boilerplate, the racket macro (aka syntax transformer) system is the most advanced i know to reduce the boilerplate to a minimum and so just write what i want to express. In facts i rarely write macro because writing a good macro demand you take care of errors syntax, i am lazy in the bad meaning of the term.

I choose it because it's dynamic typed and i get more convinced that type go on your way most of the time (expect complex algorithms)(i write little projects, so refactoring argument is out). It enable me to write code and eval it on the fly with geiser (using enter! on the back), after eval the new function i test it in the repl, hack until the function meet the requirement copy paste from repl and boom i get a unit test. Because it as eval and it will become handy one time in your programmer life for sure.

I choose it because of it's sexpr syntax, as a heavy user of emacs i know that other syntax is a pity.

Also because it has (and i use):

1. llar parser (implemented through a macro).

2. A pattern matching nothing to envy scala or clojure deconstructs.

3. An optional type system.

4. A contract system.

What i find hard as a new comer (to racket, not as a programmer already now scala, clojure, half of c++ :), php) is

1. The broadness of the features the language offer, which feature to use e.g.: class or generics.

2. The documentation is rich but lack of examples for the common cases, so you need to read the doc of the function (sometime it's huge).

3. Understanding how racket module works is quite hard and you have the documentation, if you don't plan to play with the macro expander (the stuff that run your macro) and some dynamic features you don't really need to.

4. You need to 'register' the errortrace library if you want a stacktrace, quite a surprising behaviours for me.

My opinionated conclusion:

Racket is the best language design i ever see, it's hard to learn but make you feel learning an other language will just become to learn a new sub-optimal syntax. Sadly the ecosystem is lacking libraries and peoples and i am not helping in this way.

bad_login··on Lisp implementation in sed

   ;; comparing with racket:

   (define (grade student)
     (cond 
      [(excellent-work student) "A+"]
      [(and (okay-stuff student) (tried-hard student)) "B"]
      [(okay-stuff student) "B-"]
      [else "C"]))

   ;; Or

   (require racket/match)

   (define (grade student)
     (match (map (lambda (fn) (fn student)) 
                 '(excellent-work okay-stuff tried-hard))
       [(list #t _ _)  "A+"]
       [(list _ #t #t) "B"]
       [(list _ #t _)  "B-"]
       [else           "C"]))
← PreviousPage 2 of 2