Re: [racket-users] Replacing nodejs with Racket... possible?

2018-02-12 Thread 'Paulo Matos' via Racket Users
Thanks. RacketScript is just what I need. :)

On 10/02/18 21:26, Jens Axel Søgaard wrote:
> Check the Playground for RacketScript. Sounds like your program have the
> same components.
> 
> https://github.com/vishesh/racketscript-playground
> 
> /Jens Axel
> 
> 
> 2018-02-10 20:19 GMT+01:00 'John Clements' via Racket Users
> >:
> 
> I think you might be most interested in RacketScript, available on
> the package server. It compiles racket into JS.
> 
> https://github.com/vishesh/racketscript/blob/master/README.md
> 
> 
> Haven’t used it myself, but I probably will, the next time I need
> something written in JS.
> 
> John
> 
> 
> > On Feb 10, 2018, at 08:17, 'Paulo Matos' via Racket Users
>  > wrote:
> >
> > Hi,
> >
> > I am far from being a web dev so please bear with me. I need to do a
> > simple web interface with two text areas side-by-side in order to
> > test-drive a commercial product from a web interface. The user
> writes on
> > the left side. The content is driven through a server side app (in
> > racket but I don't think it matters for this use case) and the
> output is
> > shown on the right-most box.
> >
> > This is similar, although not necessarily as complex as the Compiler
> > Explorer:  https://gcc.godbolt.org/
> >
> > Compiler Explorer is written in NodeJS (with layout by Golden Layout).
> > That's a non-starter. I look at the source (available in github) and
> > doesn't say much.
> >
> > I am curious, could this be potentially written in pure racket? I have
> > heard of Whalesong as a sort of racket replacement to JS.
> >
> > Any references to how to even start implementing something like
> this in
> > Racket?
> >
> > Kind regards,
> > --
> > Paulo Matos
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send an email to racket-users+unsubscr...@googlegroups.com
> .
> > For more options, visit https://groups.google.com/d/optout
> .
> 
> 
> 
> --
> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to racket-users+unsubscr...@googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout
> .
> 
> 
> 
> 
> -- 
> -- 
> Jens Axel Søgaard
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

-- 
Paulo Matos

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] (dynamic-require) performance problem

2018-02-12 Thread Dmitry Pavlov

Matthew,


I can imagine a problem where the "language implementation" is in the
reader, in which case it wouldn't get run when loading from bytecode,
but that doesn't explain why `racket ` works --- unless the
initialization is also triggered by a `main` or `configure-runtime`
submodule, which would be run by `racket `.


You are right, it is in the configure-runtime. Here is the source of
my slon/lang/configure-runtime.rkt file. It has not changed since 2011
when I wrote it. It probably reflects my incompetence in implementing
languages, but anyway:



[...]


Oh, I see that the upstream Racklog source [1] has changed and no
longer uses the odd-read/even-read hack. I will borrow the
implementation from there, again, effectively removing the parser
dependency in configure-runtime,and see how it goes.


No, the Racklog still does use parser and compiler in the configure-runtime.
And so am I.

I have addressed the issue by (require)-ing the needed module directly in the
language runtime, too, so my hash table gets filled up even if the reader has 
not acted. Thank you!

Best regards,

Dmitry


--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] (dynamic-require) performance problem

2018-02-12 Thread Dmitry Pavlov



   Does the port `p` contain
the source text for , or does it contain the bytecode from
the ".zo" file created by `raco make ?

In this dedicated test, just the source text of  and nothing else.


I think this is the main cause of the performance difference, but just
to make sure, does

   raco make ; rm ; time racket 

take ~4 seconds, where  is in a "compiled" dierctory
relative to ?


Yes, it does! So the issue is just that  itself takes ~3 seconds
to compile. Having other sources consumed even more time to compile,
I did not figure that. Thank you.


If so, then the solution could be to use `require-input-port` on a port
that has bytecode for , instead of the program source.


I just tried that, and... got the hash table error that is the same as with
(dynamic-require  #f).



I just tried to check what I get with (dynamic-require  #f) instead
of require-input-port.
In turns out that I get a "hash-ref: no value found for key" error originating
from  implementation.
It indicates that something went not as is was supposed to go in the dependent
modules loading.
There is a certain module (I will call it "functions") that, when loaded,
fills up the hash table in another module ("functions-table"), and this hash
table is being used by the language implementation. Of course, the language
implementation does (require) "functions-table" and then "functions".
Something went wrong with that scheme when I used the (dynamic-require
 #f) approach.
It never went that way when I used (require-input-port) or "racket
".


I'm stumped here.

I can imagine a problem where the "language implementation" is in the
reader, in which case it wouldn't get run when loading from bytecode,
but that doesn't explain why `racket ` works --- unless the
initialization is also triggered by a `main` or `configure-runtime`
submodule, which would be run by `racket `.


You are right, it is in the configure-runtime. Here is the source of
my slon/lang/configure-runtime.rkt file. It has not changed since 2011
when I wrote it. It probably reflects my incompetence in implementing
languages, but anyway:



#lang racket/base

(require slon/slon-parser)
(provide configure)

(define (configure data)
  (current-read-interaction even-read))

;; Taken from Datalog source, which says "This is almost certainly wrong."
;; So we are going to be wrong too.
(define (even-read source-name input-port)
  (begin0
(slon-read-syntax source-name input-port)
(current-read-interaction odd-read)))

(define (odd-read src ip)
  (current-read-interaction even-read)
  eof)



slon/slon-parser.rkt requires slon/slon-compiler.rkt, which, in turn,
requires those "functions" and "functions-table" modules that make
the error happen.

So, how bad is this all, really? :)

Oh, I see that the upstream Racklog source [1] has changed and no
longer uses the odd-read/even-read hack. I will borrow the
implementation from there, again, effectively removing the parser
dependency in configure-runtime,and see how it goes.


Best regards,

Dmitry

[1] https://github.com/racket/racklog/blob/master/lang/configure-runtime.rkt

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] (dynamic-require) performance problem

2018-02-12 Thread Dmitry Pavlov

Matthew,


I'm not clear on why you're using `require-input-port` here instead of
`dyanmic-require` with 's path.

Originally, I needed it to prepend "#lang " to the source because I did 
not have it in the file.
That requirement is not so strict now and I will be able to lift it if it is 
critical for performance.

I just tried to check what I get with (dynamic-require  #f) instead 
of require-input-port.
In turns out that I get a "hash-ref: no value found for key" error originating from 
 implementation.
It indicates that something went not as is was supposed to go in the dependent 
modules loading.
There is a certain module (I will call it "functions") that, when loaded, fills up the hash table in another 
module ("functions-table"), and this hash table is being used by the language implementation. Of course, the 
language implementation does (require) "functions-table" and then "functions".
Something went wrong with that scheme when I used the (dynamic-require 
 #f) approach.
It never went that way when I used (require-input-port) or "racket ".
Should I provide more details? Does the dynamic-require vs require-input-port 
issue matters for performance?


  Does the port `p` contain
the source text for , or does it contain the bytecode from
the ".zo" file created by `raco make ?

In this dedicated test, just the source text of  and nothing else.

Best regards,

Dmitry

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] (dynamic-require) performance problem

2018-02-12 Thread Matthew Flatt
At Mon, 12 Feb 2018 15:55:44 +0300, Dmitry Pavlov wrote:
> I measure the time taken to execute a program in two different ways:
> 
> 1. raco make ; time racket 
> 
> 2. raco make my-runner.rkt; raco make ; time racket my-runner.rkt 
> 
> 
> [...]
>
> To load it dynamically in my-runner.rkt, I use the following function
> kindly provided by Matthew Flatt a few years ago on this mailing list:
> 
> (define (require-input-port p [name (gensym)])
>(define module-name (make-resolved-module-path name))
>(parameterize ([current-module-declare-name module-name])
>  (eval-syntax (check-module-form ; ensures that `module` is bound
>(with-module-reading-parameterization
> (lambda ()
>   (read-syntax (object-name p) p)))
>'ignored
>#f)))
>(dynamic-require module-name #f))

I'm not clear on why you're using `require-input-port` here instead of
`dyanmic-require` with 's path. Does the port `p` contain
the source text for , or does it contain the bytecode from
the ".zo" file created by `raco make ?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] (dynamic-require) performance problem

2018-02-12 Thread Dmitry Pavlov

Hello,

I have a performance problem with loading a Racket program dynamically.

I measure the time taken to execute a program in two different ways:

1. raco make ; time racket 

2. raco make my-runner.rkt; raco make ; time racket my-runner.rkt 


In the first case, execution takes ~1 second, in the second case ~4 seconds.
(The time to run 'raco make' is not measured.)
I checked Racket 6.10 and Racket 6.11 on Linux.

Some additional observations (very basic, since I know little about Racket
module loading mechanism):

- Delay does not go anywhere if I run  second time within the same
  my-runner.rkt instance.

- It I omit 'raco make' and remove all the 'compiled' folders from my source
  code tree, running the program takes ~18 seconds in both cases, so there is
  no performance difference in that case.


 is written in a non-Racket #lang with its own reader.
To load it dynamically in my-runner.rkt, I use the following function
kindly provided by Matthew Flatt a few years ago on this mailing list:

(define (require-input-port p [name (gensym)])
  (define module-name (make-resolved-module-path name))
  (parameterize ([current-module-declare-name module-name])
(eval-syntax (check-module-form ; ensures that `module` is bound
  (with-module-reading-parameterization
   (lambda ()
 (read-syntax (object-name p) p)))
  'ignored
  #f)))
  (dynamic-require module-name #f))

Other than performance, it works great.
Is there a way to make it as fast as the "static" command-line runner?
Many thanks in advance.


Regards,

Dmitry

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Concise way to get completions for Racket code?

2018-02-12 Thread Gour
On Mon, 12 Feb 2018 03:37:54 -0500
Neil Van Dyke  wrote:

> Regarding Emacs (Esc-Meta-Alt-Ctrl-Shift) specifically... The Emacs
> features that reduce the amount of repetitive typing required (for,
> e.g., formatting, completion, navigation) are good, but what's bad
> for some people is that Emacs encourages simultaneous keypresses. If
> you're using one hand to press two keys simultaneously, the
> repetitive contortions involved seem to be a problem.  

Very true.

> Five things you can do, to save your hands : (1) for 2-simultaneous-key
> combinations, train yourself to use both hands; (2) for the Emacs Meta key,
> instead of holding down the Alt key and pressing the modified key(s),
> consider the pressing and releasing the Esc key, and then pressing the
> modified key(s); (3) add your own easier Emacs key bindings for commands you
> use often, perhaps your F keys; (4) try out Emacs features and add-ons that
> might save typing; (5) write your own Emacs functions to save typing.

I also tried with sticky-keys...

> There's also non-Emacs-specific things, like keyboard height, wrist
> angles, torso and arm positions, neck position, taking breaks,
> stress, etc.  Very subtle changes here can make all the difference.
> Different things work for different people, so Google around, and
> find what works for you.

I am aware of that, but I do not have any problem when using (n)vim.

> I was very fortunate that others started raising issues about typing
> RSI at the start of my career, so I just try to spread the gospel of
> good typing.

Thank you for the tips. ;)


Sincerely,
Gour

-- 
The work of a man who is unattached to the modes of material
nature and who is fully situated in transcendental knowledge
merges entirely into transcendence.


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Concise way to get completions for Racket code?

2018-02-12 Thread Neil Van Dyke

Gour wrote on 02/12/2018 03:01 AM:
I had tried tried several times with Emacs, but, for some strange 
reason, very soon I would experience some wrist pain and finally gave 
up on it.


Something that's not Racket-specific, but is very important to software 
developers...


I've seen several developers cause permanent damage to their 
wrists/hands, from bad typing practice, and a few of them had to find 
jobs that didn't involve typing.


Never type through hand pain, and find good workstation ergonomics that 
work for you.


Regarding Emacs (Esc-Meta-Alt-Ctrl-Shift) specifically... The Emacs 
features that reduce the amount of repetitive typing required (for, 
e.g., formatting, completion, navigation) are good, but what's bad for 
some people is that Emacs encourages simultaneous keypresses. If you're 
using one hand to press two keys simultaneously, the repetitive 
contortions involved seem to be a problem.  Five things you can do, to 
save your hands :

(1) for 2-simultaneous-key combinations, train yourself to use both hands;
(2) for the Emacs Meta key, instead of holding down the Alt key and 
pressing the modified key(s), consider the pressing and releasing the 
Esc key, and then pressing the modified key(s);
(3) add your own easier Emacs key bindings for commands you use often, 
perhaps your F keys;

(4) try out Emacs features and add-ons that might save typing;
(5) write your own Emacs functions to save typing.

There's also non-Emacs-specific things, like keyboard height, wrist 
angles, torso and arm positions, neck position, taking breaks, stress, 
etc.  Very subtle changes here can make all the difference. Different 
things work for different people, so Google around, and find what works 
for you.


I was very fortunate that others started raising issues about typing RSI 
at the start of my career, so I just try to spread the gospel of good 
typing.


--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Concise way to get completions for Racket code?

2018-02-12 Thread Gour
On Sun, 11 Feb 2018 16:12:34 -0800 (PST)
HiPhish  wrote:

> One large advantage DrRacket has is its graphics capabilities. 

That's somehing I would just have to discover. :-)

> What's really cool about Neovim is that the developers have been de-crufting
> Vim. For example, GUIs are now independent of the editor itself, you could
> even use another editor like Atom and embed Neovim. In the past you would
> have had to use a Vim emulator, which is usually a hit or miss, but now you
> can just embed the real thing. Remote plugins I have already mentioned; in
> Vim if you want to write plugins in another language you have to re-compile
> Vim, with Neovim you just retrofit it. Then there is all the async stuff
> which was the prime motivation for starting Neovim. I was still new to Vim
> when I was getting really annoyed about things like syntax-checking always
> blocking and I was considering switching to Emacs, but then I discovered
> Neovim.

I had tried tried several times with Emacs, but, for some strange reason, very
soon I would experience some wrist pain and finally gave up on it.

Otoh, it does never occur when using Vim...yes, I also have Neovim installed
and start using/learning it, but it is still light usage.

My question was simply curiosity whether using non-Emacs editor is an obstacle
'forcing' me to choose some other language to tinker with. Of course, DrRacket
is always a viable option, but I simply prefer not to 'change gears' (aka
editors), if possible, when working.


> Emacs is older than Neovim and I don't think anyone here on this mailing list
> is using Neovim (except me)

:-)

> but people do use Emacs, so the Emacs-Racket ecosystem (and Lisp in general)
> has had more time to mature. It will be a while before Racket support in
> Neovim catches up with Emacs.

Thank you very much for your input!


Sincerely,
Gour

-- 
As a strong wind sweeps away a boat on the water,
even one of the roaming senses on which the mind
focuses can carry away a man's intelligence.


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.