User loginNavigation |
LtU Forumcounterexamples.orgCounterexamples in Type Systems The "counterexamples" here are programs that go wrong in ways that should be impossible: corrupt memory in Rust, produce a ClassCastException in cast-free Java, segfault in Haskell, and so on. This book is a collection of such counterexamples, each with some explanation of what went wrong and references to the languages or systems in which the problem occurred. By raould at 2021-05-14 19:18 | LtU Forum | login or register to post comments | other blogs | 2640 reads
Emacs modes: what is it?I've been using Emacs as my OS since time started and I've always taken its programming model as granted, part of the nature. However, now I'm looking back at it when I'm trying to design an editor/OS based on S-exp rather than text, I found I understand Emacs very poorly. So here's the question: Hooks and advices look like AOP. However, emacs hooks and advices usually make heavy use of buffer local variables. Lots of them also interact with modes by looking at the mode variable. So I don't think AOP captures the full picture. Sure, mode looks like context-oriented programming (see ContextL LtU thread ). However I never see mode associated with dynamic scope, they just got turned on or off (for a particular buffer). Is this "resembling ContextL" impression just another instance of fitting a too-general concept into a much more specific (but not understood) concept? And finally, let me give the context that all those question arises: I want to clean up the Emacs model, and apply it to a S-exp (tree) based editor. So the practical question is: Can we find a cleaner/more elegant version of the Emacs model, and generalize it to tree document structure? Will we have node-local variables, node-local modes, etc? If so, how will all those "attachments" interact between, say, parents and children nodes? Objective-SMorally kinda similar to ArchJava, apparently. Objective-S is an architecture-oriented programming language based loosely on Smalltalk and Objective-C. It currently runs on macOS, iOS and Linux, the latter using GNUstep. By allowing general architectures, Objective-S is the first general purpose programming language. What we currently call general purpose languages are actually domain specific languages for the domain of algorithms. Objective-S includes an Objective-C compatible runtime model, but using a much simpler and consistent Smalltalk-based syntax. Unlike Smalltalk, Objective-S has syntax for defining classes and so can be file-based and is "vi-hackable". Paper: Tyranny of call-return Java / CPython Language BridgeI've implemented support for two-way compatibility between Java and Python/CPython, meaning that Java can import standard CPython modules and use code as if it were Java, and Python can import Java classes and use them as if they were Python classes. Imports in both languages are done with standard import statements. How It Works Java code imported into Python is subjected to reflection and then Python wrapper classes are generated using the Python API that provide runtime translations between the two language runtimes. A native Python module is provided that provides the "magic import" functionality from Java to Python (more info). Python code imported into Java is introspected using the Python C API and then bytecode is generated for Java wrapper classes that provide a similar runtime translation as the imports in the other direction. A custom compiler based on javax.tools is provided (QoreJavaCompiler) as well as runtime dynamic code generation support for wrapper APIs in a custom class loader (QoreURLClassLoader) - more info. This is all accomplished using a third language called Qore that provides the functionality of a "language bridge" and also manages the references to data in each separate runtime. Because Qore has a deterministic garbage collector, strong references to Python and Java data are managed in Qore and released when there are no more valid references to the data (in Qore - therefore various tricks are used to manage references transparently including sing thread-local data; there is also the possibility of using custom reference handlers to maintain the validity of objects using different language runtimes and garbage collection implementations). A high level description of the approach is here. While support for importing Java into Python has been released, importing Python into Java will be released in April 2021 but is currently working and stable. The idea is to facilitate the mixed use of enterprise technologies (Java) and AI / data science technologies (Python). All of the source code required has been released under permissive open source licenses (MIT). I hope it could be interesting and useful for someone - happy to provide more information if there's interest. John Shutt, creator of Kernel and an LtU regular, dies at 56Apparently he was also a wikinews contributor as they have an obituary: Wikinews mourns loss of volunteer John Shutt
Racket is ‘Scheme all the way down’ with v8 on Chez SchemeChez Scheme’s (nanopass) compiler produces native code x86+x86-64, ARM (incl Raspberry Pi to the Apple M1). By spdegabrielle at 2021-02-14 12:49 | LtU Forum | login or register to post comments | other blogs | 9038 reads
High level languages with optimal code generationOne of the issues that arises during the implementation of programs that need to have high performance, is that a large percentage of time is spent doing and debugging optimizations. These range from reorganizing data, reorganizing control flow, and sometimes even going as far as using inline assembly. This is work seems to be very error prone and quite difficult to do, with a lot of specialized knowledge that is necessary to achieve good performance. A good example of the difficulties of this process can be seen in the series handmade hero. How can we make it easier for compilers to help generate faster code automatically? I found out about superoptimization, but this seem to be very limited in capability. Specifically, it is very slow, can't deal with control flow and can't do anything about data structures. Regarding this last point, most languages force us to decide on them, and so a compiler can't even do much about it. A different strategy is used in Compilation of Bottom-Up Evaluation for a Pure Logic Programming Language, where a Turing complete Datalog inspired language is proposed. With this approach, the data structures are selected by the compiler. What other research looks at this problem, and what other ideas do you have? Is relational algebra + mapreduce a good way to approach this problem? How can we have program descriptions that compile into optimal or close to optimal code? Or at least how can we decouple optimizations from the problem description? P.S. This is a bit of a sequel to the Why is there no widely accepted progress for 50 years?. The answers I got in that thread were very thought provoking and helped to clarify much of my thinking. Thank you very much to all that participated in the discussion! Concurrent System Programming with Effect HandlersFrom 2017 cf. github repo of materials for CUFP 17 tutorial about it
A problem about programming with macros vs Kernel F-exprsI love Kernel F-exprs which looks better than ordinary macro in almost every ways, However, I have trouble trying to implement the following using F-expr (defmacro f () (make-array 1)) ;; Common Lisp style macro (define g (lambda () (list (f) (f))))
The two I can't think of a way to replicate this behavior using Kernel F-exprs. Any ideas? Loop and recursionGeneric loops are problematic to reason about and understand when you read the code, and therefore prone to cause bugs. I think it would be beneficial to forbid generic loops, and only have iterators. Recursions can also be problematic since the stack usage can become unpredictable. The exception is of course tail recursions, since those can re-use that current stack frame. If the language would prohibit generic loops and recursions except for tail recursions, would it still be useful as a generic programming language or would those restrictions make some common designs impossible? |
Browse archives
Active forum topics |
Recent comments
5 weeks 12 hours ago
45 weeks 2 days ago
45 weeks 2 days ago
45 weeks 2 days ago
1 year 15 weeks ago
1 year 19 weeks ago
1 year 21 weeks ago
1 year 21 weeks ago
1 year 23 weeks ago
1 year 28 weeks ago