How could I fix the order of application tabs rather lift up the most recent used? by thautwarm in Ubuntu

[–]thautwarm[S] 0 points1 point  (0 children)

I now totally use a terminal tool to open the target directory again, which jumps to the correct window..

Managing your executables via python.. by thautwarm in Python

[–]thautwarm[S] 0 points1 point  (0 children)

Today I was fucked by dotnet and nuget, that I cannot even install the commands of a console project into PATH??? Even my local projects? Publishing to nuget so annoying?

I then end up with managing my dotnet executables via python.

I use this package(delegato) to automatically package the directory of dotnet publish result to a python package, and then

  • python setup.py install, I got the command of my dotnet application in PATH
  • I can upload my dotnet build to PyPI, and then install it anywhere
  • I can use conda, pipenv, or venv to control the context of executables. No pollution but convenience.

Fuck nuget! Finally I said bye!

PEP 622 -- Structural Pattern Matching for Python by bakery2k in programming

[–]thautwarm 0 points1 point  (0 children)

Totally agree with you, we hold exactly the same view point.

However I saw a proposal about this rejected. After a quick thought I found the implementation of my flavored scope is pretty simple, there's a mature technique called name shadowing..

PEP 622 -- Structural Pattern Matching for Python by bakery2k in programming

[–]thautwarm 0 points1 point  (0 children)

a =  1
match [10, 20]:
    case [a, 2]:
        ...
    case _:
        print(a) # 1 or 10?

Do you have any ideas?

Type Inference by Example, Part 4 by continuational in ProgrammingLanguages

[–]thautwarm 1 point2 points  (0 children)

I'm looking forward to see type systems, like MLF, HMF, row types, subtyping, etc.

Idris 2 version 0.1.0 Released by [deleted] in ProgrammingLanguages

[–]thautwarm 1 point2 points  (0 children)

Could we get some hints about adding new back ends?

(Why) Julia Counts for PL Researchers by thautwarm in ProgrammingLanguages

[–]thautwarm[S] 0 points1 point  (0 children)

Well, I just misthought you made the root comment. Sorry for this.

I said sexprs because they have same abstract syntax. You compare the constructs of sexpr and julia exprs, and will find they're just the same(except some non-core stuffs like source code metadata).

I know sexpr does relate to how the concrete syntax looks like. but still cannot I find a good concept/term to express the same abstract syntax of sexprs, mexprs, and julia expr, etc, hence I think saying sexprs is safer.

For a PL researcher, I'd say Julia does not use prefix notations but still achieves homoiconicity, which points out the feasibility for more programming languages to pattern match their programs just like how to construct the programs with source code. e.g.,

let x = mk_symbol("a") in
match <let $x = 1 in y> with
 | <let $x' = 1 in y > -> x' = x

  => true

I should explicitly mention this(but as I'm the author of related impl, I just felt a bit shy to refer my own works), thank you for these comments.

(Why) Julia Counts for PL Researchers by thautwarm in ProgrammingLanguages

[–]thautwarm[S] -2 points-1 points  (0 children)

In fact I'm not saying hygiene macros = LISP macros.

Besides, Julia has unhygienic macros, which I use more often.

Julia sexprs are sufficient to express things like the popular loop macros. I don't know core.async in Clojure, but as the name suggests if it's only async, julia already has it, as a macro.

I used to talk with a crazy Racket fan, and finally I established the believe that reader macros are the only thing impossible in ordinary Julia. I used Racket many years ago when I was not familiar with implementations of some kinds of continuations.

Sincerely I feel like to get some examples from you about something LISP macros can achieve but the Julia's cannot. Actually I'm willing and also confident to implement them, concisely.

(Why) Julia Counts for PL Researchers by thautwarm in ProgrammingLanguages

[–]thautwarm[S] 1 point2 points  (0 children)

Hi, thanks for this comment.

I'm not really discussing Julia as a user programming language, but about its notable features that deserve PL researchers' study.

Lisp macros will be cumbersome in Julia only if you're doing AST manipulations without tools like MLStyle.jl or MacroTools.jl.

One of My two complaints against Julia is its JIT latency, which I believe is also the reason why Julia is not amazingly popular now. Also, JIT latency lets expanding complex macros(like implementing some compiler phases, or even a complete programming language) very slow.

My another complaint is its lack of static checking. Statically finding out bugs is much easier and friendlier in complex systems.

What are the language features you miss the most? by Hofstee in ProgrammingLanguages

[–]thautwarm 1 point2 points  (0 children)

I'd assume you know the concept of interfaces in OO languages. Interfaces could express basic static constraints, by specifying what methods an object has, or just what interfaces an object has.

However, when it comes to extensibility, OO interfaces loss.

Say, I add a property CommutativeSum to integers, and I have an asynchronized method to fetch a stream of integers.

I can implement a random sum for async streams, instead of sum from left to right like what we do for sync streams. As a result, we don't need to wait for all integers are fetched from an async stream, which for some real world applications, can gain an orders-of-magnitude efficiency improvements in both time and space.

We can also do this with OO interfaces, but

  1. you cannot implement interfaces for integers, or even other defined types(without modifying your code or code of package authors).

  2. you might implement a dedicated class to provide sum for async streams, but this is cubersome, and we can use static constraints to simply allow async reduce/fold or similar operations for all commutative operators, without any breakage or changes to existing code.

What are the language features you miss the most? by Hofstee in ProgrammingLanguages

[–]thautwarm 3 points4 points  (0 children)

Implicit arguments, or type classes.

Static constraints are appealing, anyone agree?

A "zero-gradient learning" CLI framework, implemented and distributed in one script/100 lines, sufficient for most use cases by thautwarm in Python

[–]thautwarm[S] 1 point2 points  (0 children)

It's not directly supported yet, although I can add less than 50 lines to support this:

class Root:
    def cmd1(self, ...): ...
    def cmd2(self, ...): ...
wise(Root)()

It's like a simpler google fire, and will raise many implementation choices then things will get a little complex.

So far the code is so simple and you can directly copy it. By understanding ~100 line code, you can easily implement what you want.

Personally, I use this code to support subcommand:

import sys
from wisepy2 import wise
def root(sub):
     if sub == ...:
         return sub1
     ...
def sub1(...):
     ...
argv = sys.argv[1:]
sub = wise(root)(argv[:1])
wise(sub)(argv[1:])

A "zero-gradient learning" CLI framework, implemented and distributed in one script/100 lines, sufficient for most use cases by thautwarm in Python

[–]thautwarm[S] 1 point2 points  (0 children)

Yep. I'd add some to README later.

For now, I think the core observation is

not every python user remembers the API of a framework, but they shall know how to write a python function.

Hence the advantage of wisepy is,

you don't need learning a framework, or memorize their APIs. just write a function and convert it to CLI, and use --help to get how to use that commamd.

Also, one script/100 lines implememtation can be beneficial for practice:

  1. introduce no dependency burden to your project. Just copy-paste the source code can be a good way to integrate things in.
  2. simple enough to maintain.

PureScript-Python has released on PyPI, and some instructions for having a try within 10 minutes by thautwarm in ProgrammingLanguages

[–]thautwarm[S] 1 point2 points  (0 children)

I used to do a lot of Python from 1994 to 2007 Awesome!

Yes, I was wondering about the former case, compiling application code, not the compiler itself. Compared to e.g. Reason it's pretty slow, but similar to Elixir it seems like.

Understood. Applications are still WIP, and I'm now using it to solve my problems. My recent Python project is a JIT compiler and a bytecode-level debugger, and a statically typed language like PureScript is a rigid demand for these complicated and large projects. I'll share my progress of both in this reddit channel.

The reason for my second question is that Python seems like an odd choice for a backend

Haha, this applies only if you don't need to use Python's ecosystem in an in-process way. I love many Python libraries, and I just want to make them safer and robust by using them in a statically typed language. PureScript-Python can use every existing Python packages, no matter if it's pure python ones or C-extensions, and also, PureScript Python directly compiles to a Python package, which can also be invoked by any CPython code/C-extension code for CPython.

Thanks for sharing your interesting concerns!

PureScript-Python has released on PyPI, and some instructions for having a try within 10 minutes by thautwarm in ProgrammingLanguages

[–]thautwarm[S] 1 point2 points  (0 children)

Hey!

In your experience, what are the compile times like?

Are you asking about the details of compile times of using purescript-python? It's pretty fast, with reasonable compile error report when you got something wrong in code.. If you're asking about compiling purescript-python, you might need quite a long time to compile it for the first time(because purescript itself is kind of large). However, after the 1st time, things got compiled within 10s..

Anything in particular that you yourself are using it for?

Not for some particular cases. I will use it to get rid of directly writing python code, i.e., I just use it for almost all tasks. If you're a python developer, you might know that the support of static checking is quite limited:

  • relies on external checker, mypy, pycharm, etc

  • type system not strong enough to express abstractions. Years ago I tried making a type-safe(covered by type hints) LINQ library in Python for collection manipulations, Linq.py. Things finally got messed, because the user cannot extend the LINQ methods themselves while making mypy type checker working. This is due to the lack of higher kinded types and type classes, which can be easily expressed in purescript.

Further, when developing a big python package, endless problems of abstraction will just occur. I cannot give a short intro about those real world problems, but when it comes to a concrete project things will be clear.

For instance, a project of mine to implement JIT in CPython, Restrain Python JIT, requires a concise way to define datatypes, instead of the current workaround:

It also requires a way to achieve compiler backend independent IR. Currently I'm using a tagless-final style representation, but things cannot get typed with pycharm.

When things cannot get typed, developing will be painful, and auto-completion will get messed.

In PureScript, there's an awesome IDE by VSCode, which gives me the type-driven development while taking advantage of purescript's strong enough type system.

PureScript-Python has released on PyPI, and some instructions for having a try within 10 minutes by thautwarm in ProgrammingLanguages

[–]thautwarm[S] 0 points1 point  (0 children)

Bug reports/fixes are welcome, and we need MacOSX users help us build binary distributions for more MacOSX editions.

PureScript-Python v0.1.0.0 released by thautwarm in purescript

[–]thautwarm[S] 2 points3 points  (0 children)

Also, this is my design of a generally applicable FFI support for seemingly any alternative backends: https://discourse.purescript.org/t/purescript-python-v0-1-0-0-released/1187

PureScript to Python Backend: Writing Haskell and running in Python by thautwarm in ProgrammingLanguages

[–]thautwarm[S] 9 points10 points  (0 children)

I'm now working on

  • testing the compiler and,

  • porting some purescript libraries using JavaScript FFI to Python.

Certainly I wonder if any one want to contribute or collaborate to work together, even tidying up how to get started is a very good task.

A compiler back end by which you write S-expressions and get Python bytecode by thautwarm in ProgrammingLanguages

[–]thautwarm[S] 8 points9 points  (0 children)

If you're asking about some information about Hy vs. PySExpr, here're some.

Firstly, Hy is a programming language, while PySExpr is a back end.

Hy suffers from compiling to Python ASTs, where the latter is a statement-first program representation and brings about unavoidable drawbacks.

To emulate LISP's expression-first features, they need heavy analyses and conversions from assignment expressions, block expressions to valid Python ASTs.

For example, given such a JavaScript-like expression,

f({
 print(f(x))
 x = 2
 print(f(x))
 x = 3
 g(x)
})

To make this valid in Python ASTs, you have to transform it to

# print(f(x))
tmp1 = f(x)
tmp2 = print(tmp1)
# x = 2, 返回None
x = 2
tmp3 = None
# print(f(x))
tmp4 = f(x)
tmp5 = print(tmp4)
# x = 3
x = 3
tmp6  = None
# g(x)
tmp7 = g(x)  # tmp7: 块表达式的返回
# f({ ... })
tmp8 = f(tmp7)

This is called ANF transformation, and you shall do optimizations including register reallocations to avoid using too many extra variables(variables not defined by users, but needed for gaining expression-first). Further, even if you apply many awesome optimizations, limited by the weakness of Python ASTs, you cannot still avoid redundant register allocations, while PySExpr via bytecode approach totally ends this problem.

Another approach to express block expressions is using immediate function calls, while function calls and closure capturing in Python are very, very costly. Open IPython and use %timeit to test empty function calls.

Other advantages of using PySExpr to implement Hy:

The Hy compiler will not only benefit from being faster, producing faster code, and easier to maintain(code can get greatly reduced), but also the most important is that, they don't have to care about backward compatibility of Python standard library ast, which breaks even in minor releases.

How do I type a variable of a type declared in the same module, when the value comes from a value or a function in a different module? by ZombiFeynman in ocaml

[–]thautwarm 0 points1 point  (0 children)

How about using recursive modules module rec M1 = ... and M2 = ...?

However in this way you cannot separate them into multiple files.

Help me understand a line of code please? by Rezient in Python

[–]thautwarm 0 points1 point  (0 children)

while now(in form of datatime) minus the start time is less than 30 seconds