Difference between revision 8 and current revision
No diff available.https://sneklang.org/doc/snek.html has, among other things, the following curses functions:
16. Curses built-in functions
16.1. curses.initscr()
16.2. curses.endwin()
16.3. curses.noecho(), curses.echo(), curses.cbreak(), curses.nocbreak()
16.4. stdscr.nodelay( nodelay )
16.5. stdscr.erase()
16.6. stdscr.addstr( row , column , string )
16.7. stdscr.move( row , column )
16.8. stdscr.refresh()
16.9. stdscr.getch()---
A NEW LIBRARY FOR SMALL-C by James Hendrix and Ernest Payne
archive10/ddj_devnetwork_small_c from https://www.drdobbs.com/developer-network-small-c-compiler-book/184415519?queryText=%2522small%2Bc%2522 ddj_devnetwork_small_c/articles/chaps/chap6/chap6.htm
---
https://fuchsia.dev/fuchsia-src/reference/syscalls
https://fuchsia.dev/fuchsia-src/reference https://fuchsia.dev/fuchsia-src/concepts
---
https://docs.zephyrproject.org/latest/guides/c_library.html
"
The following functions are implemented in the minimal C library included with Zephyr:
abs()
atoi()
bsearch()
calloc()
free()
gmtime()
gmtime_r()
isalnum()
isalpha()
isdigit()
isgraph()
isprint()
isspace()
isupper()
isxdigit()
localtime()
malloc()
memchr()
memcmp()
memcpy()
memmove()
memset()
mktime()
rand()
realloc()
snprintf()
sprintf()
strcat()
strchr()
strcmp()
strcpy()
strlen()
trncat()
strncmp()
strncpy()
strrchr()
strstr()
strtol()
trtoul()
time()
tolower()
toupper()
vsnprintf()
vsprintf()"---
https://www.evanmiller.org/statistical-shortcomings-in-standard-math-libraries.html
---
rudolfwinestock 2 hours ago [–]
Related: The MGR Window System https://hack.org/mc/mgr/
“MGR provides each client window with: curses-like terminal control functions, graphics primitives such as line and circle drawing; facilities for manipulating bitmaps, fonts, icons, and pop-up menus; commands to reshape and position windows; and a message passing facility enabling client programs to rendezvous and exchange messages. ”
Essentially, each window was a souped up ASCII terminal with extra escape sequences which implemented primitive graphics. It competed with X-Windows on low-end workstations during the 1980s.
Discussion: https://news.ycombinator.com/item?id=18742611
reply
" Client programs may ask to be informed when a change in the window system occurs, such as a reshaped window, a pushed mouse button, or a message sent from another client program. These changes are called events. MGR notifies a client program of an event by sending it an ASCII character string in a format specified by the client program. Existing applications can be integrated into the windowing environment without modification by having MGR imitate keystrokes in response to user defined menu selections or other events. "
" If you want to compare MGR to the X Window System, you might consider the MGR server as something like a combination of an X server + window manager + xterm, but with xterm's Tektronix 4014 graphics terminal emulation and its DEC VT100 emulation in the same window.
A window in MGR doesn't emulate any existing hardware terminal. It has a new set of terminal codes combining text, vector graphics and basic bitmap graphics. See the termcap entry in the distribution.
Compared to X11, MGR has a very small memory footprint and demands very little of the graphics hardware. "
---
i downloaded the mgr tarball (mgrsrc-0.69.tgz ; listed as "Pristine MGR 0.69 source" on https://hack.org/mc/mgr/) and i had some trouble compiling the documentation, but i finally got it to sorta work. I had to first do
sudo apt-get install linuxdoc-tools-text linuxdoc-tools-latex linuxdoc-tools-info
and then
tbl macros doc.1 doc.2 doc.3 doc.4 doc.5 doc.6 tocindex doc.9
| nroff -ms -rI0 > mgr_manual_compiled_sorta_broken.txt |
which is a mangled version of a line from the file doc/groffit in that tgz. The groffit line was: tbl macros doc.1 doc.2 doc.3 doc.4 doc.5 doc.6 tocindex doc.9
| croff/croff -k -c '\fI' '\fP' | groff -Tps -mgs -rI0 > body.ps |
As you can see, i changed groff to nroff, -mgs to -ms (gs and s are macro libraries, one of the packages linuxdoc-tools-text linuxdoc-tools-latex linuxdoc-tools-info seems to give me s), removed the Tps option, and removed the croff because i don't know where to get croff; there is a version of croff in this tgz in doc/croff, but it doesn't immediately compile (i bet it was written for an older version of C!). The result seems pretty readable even though the croff step was removed, however there are a bunch of errors emitted like
doc.1:292: macro error: KE without KS or KF
and also an error about tocindex, which hasn't been built.
I saved mgr_manual_compiled_sorta_broken.txt in my personal archive10 folder.
---
" ...Windows 1.0 GUI...
The bundled apps (including MS-DOS Executive) and the window decorations generally used the same GDI (Graphics Device Interface) calls as third party apps:
Text was drawn with TextOut?() or DrawText?().
Bitmaps were copied to the framebuffer with BitBlt?() or StretchBlt?().
Lines were drawn with MoveTo?() and LineTo?().
Rectangles were drawn with Rectangle() or RoundRect?().
This is not an exhaustive list but should give you the general idea.
All of these functions operated on a "device context" (DC) that you obtained with functions like GetDC?() or CreateCompatibleDC?(). Some, like BitBlt?(), used two DCs for the source and destination.
The MS-DOS Executive drive icons were bitmaps drawn with BitBlt?() with TextOut?() for the drive letter. The selected drive letter and icon were inverted with InvertRect?(), or possibly drawn with the DSTINVERT raster operation code.
These are the same functions that any Windows application could use. The MS-DOS Executive was just another app.
The non-client area of a window (titlebar and such) was drawn with the same GDI calls as the client area. Your app would get a WM_PAINT message to draw the client area and a WM_NCPAINT for the non-client area. Most apps passed WM_NCPAINT through to the default handler DefWindowProc?(). "
---
http://www.sigala.it/sergio/tvision/html/hierarchy.html
---
string.startswith
" How would you add a large standard library without compromising Lua’s main purpose - to be a lightweight, embeddable language?
reply
ebg13 1 day ago [–]
It would still be lightweight and embeddable with common sense pure Lua functionality like classes and major utility methods like string.startswith/string.endswith/string.trim/string.split/table.deepcopy. You don't have to integrate a multiprocessing web server for different operating systems.
Instead you're left with bullshit community essays like http://lua-users.org/wiki/SplitJoin which shows pages and pages of different user attempts for one extremely common function, many of which explicitly do not work! "
fit2rule 1 day ago [–]
1. Luarocks. 2. I regularly carry these little enumerables around with me and use it so frequently I found it quaint to be reminded of the 'hole problem':
--- get all packed entries, until gap
-- func on the provided list
-- @param list table to be inspected
-- @param func do func what you func want
table.each = function(list, func)
for i,v in ipairs(list) do
func(v, i)
end
end --- get all entries, packed or not, until completion
-- func on the provided list, completely
-- @param list table to be inspected
-- @param func do func what you func want
table.all = function(list, func)
if (list ~= nil) then
for i,v in pairs(list) do
func(v, i)
end
end
endDisclaimer: I love Lua and would us it for everything if I could.
reply
ebg13 1 day ago [–]
Do you also carry a table deepcopy with you? What about string.trim?
And LuaRocks? is a trash fire that doesn't integrate well with Lua's primary role as an embedded plugin engine and leaves you to waste your time in endless discovery of a slew of unmaintained packages that all do the same thing in different ways and with different bugs. Want to collaborate? I hope everyone is familiar with "classy" and not "oops" or "objectlua" or "Luaoop" or "lobject" or "classyng" or "klesi" or "halo" or "lua-c3class" or "pool" or "middleclass" or "Sunclass" or any other module that implements one of the half dozen official recommendations for faking classes with metatables or closures. It also becomes a huge "left-pad" risk.
reply
---
https://stevedonovan.github.io/Penlight/api/index.html https://stevedonovan.github.io/Penlight/api/manual/01-introduction.md.html#
---
https://www.google.com/search?channel=fs&client=ubuntu&q=S-Lang+is+like+ncurses slang ncurses
---
LOVE pico8 TIC-80 https://tic80.com/ https://github.com/nesbox/TIC-80/ https://tic80.com/learn https://github.com/nesbox/TIC-80/wiki
tic-80 fork for education: https://github.com/afonsojramos/feup-8/tree/development/Website
https://news.ycombinator.com/item?id=24407370 mentions also Pq93, Pixelvision 8, Liko-12, PX8 but says they are all similar
---
https://github.com/nesbox/TIC-80/wiki
" Console Demo Available Commands
help - Show available commands
vram - Show 16K VRAM layout (0.80)
ram - Show 80K RAM layout
exit - Exit the application
edit - Switches to the code editor
new [lua | moon | js | wren | fennel] - Create new Hello World cartridge
load <cart> [sprites | map | cover | code | sfx | music | palette] - Load cartridge from the local filesystem (there's no need to type the .tic extension). You can also load just the data (sprites, map etc) from another cart
save <cart> - Save cartridge to the local filesystem, use .lua / .js / .moon cart extension to save it in text format [PRO version]
run - Run current project
resume - Resume last loaded project
dir - Show list of local files
cd - Change directory
mkdir - Make directory
folder - Open working directory in OS (Windows, Linux, MacOSX)
add - Show file open dialog to add file to TIC
del <file> - Delete from the filesystem
get <file> - Show file save dialog to download file
export [html | native | sprites | cover | map] - Export cart to HTML or as a native build, or export sprites or cover as .gif images
import [sprites | cover | map] - Import sprites or cover from .gif
cls - Clear screen
demo - Install demo carts
version - Show the current version (0.60.3)
config [save | default] - Show config.tic file editor, use save param to save current configuration, use default to edit default cart template
surf - Open carts browser
menu - Show game menu where you can setup keyboard/gamepad buttons mapping (0.80)For those operating systems that support it, tab completion and command history is available in the console.
...
Special Functions
TIC - Main function called at 60 fps
SCN - Called on every line render, has one parameter
OVR - Called on every frame. You can draw things like a HUD on a separate layer (with own palette)Functions
print - Print string with system font
font - Print string with font defined in foreground sprites
clip - Set screen clipping region
cls - Clear the screen
pix - Set/Get pixel color on the screen
line - Draw line
rect - Draw filled rectangle
rectb - Draw rectangle border
circ - Draw filled circle
circb - Draw circle border
spr - Draw sprite by ID, can be rotated or flipped
btn - Get gamepad button state in current frame
btnp - Get gamepad button state according to previous frame
sfx - Play SFX by ID on specific channel
key - Get keyboard button state in current frame
keyp - Get keyboard button state relative to previous frame
map - Draw map region on the screen
mget - Get map tile index
mset - Set map tile index
music - Play music track by ID
peek - Read a byte value from RAM
poke - Write a byte value to RAM
peek4 - Read a half byte value from RAM
poke4 - Write a half byte value to RAM
reset - Reset game to initial state (0.60)
memcpy - Copy bytes in RAM
memset - Set byte values in RAM
pmem - Save integer value to persistent memory
trace - Trace string to the Console
time - Returns how many milliseconds have passed since game started
tstamp - Returns the current Unix timestamp in seconds (0.80)
mouse - Get XY and press state of mouse/touch
sync - Copy modified sprites/map to the cartridge
tri - Draw filled triangle
textri - Draw triangle filled with texture
exit - Interrupt program and return to console
fget - Returns sprite flag (0.80)
fset - Set sprite flag (0.80)"---
fantasy consoles
https://github.com/paladin-t/fantasy
https://lobste.rs/s/lp4jgz/i_am_trying_collect_list_toy_processors
"similar to PICO-8, TIC-80, LIKO-12"
"Some fantasy consoles and computers that stood out to me in my brief research into them so far are the PICO-8, the TIC-80, the PQ93, the SCRIPT-8, the LIKO-12 and Pixel Vision 8 (PV8). Many of these use popular languages like C# and JavaScript?."
https://itch.io/c/195696/fantasy-consoles
" Into JavaScript?? You might be interested in Phaser. Comfortable with C++ or C#? Unity, Unreal Engine, or Godot might be a good match for you. Proficient with Python? Check out Pygame or Godot. Dangerous with Java? Take a look at libGDX. In love with Lua? Check out LÖVE?, Defold, and the wonderful world of fantasy consoles like LIKO-12, PICO-8, Pixel Vision 8, and TIC-80. "
https://www.saashub.com/compare-tic-80-vs-pico-8
"
What are some alternatives? When comparing TIC-80 and PICO-8, you can also consider the following products
Pixel Vision 8 - 8-bit fantasy console built on top of an open source C# SDK
8bitworkshop - Online IDE for Atari 2600 development based on Javatari.
Voxatron - Voxel-based fantasy console
Aseprite - Aseprite is an art program dedicated to the creation of pixel art.
LIKO-12 - Fantasy console built with the Love 2D game engine.
Pyxel - Retro game engine for Python inspired by fantasy consoles.
"
https://www.reddit.com/r/pico8/comments/e6kq9y/why_is_pico8_more_popular_then_others/
---
libuv rktio
---
this blog post recommends some date libs at the bottom: luxon day.js date-fns js-joda https://momentjs.com/docs/#/-project-status/
---
most fns in https://www.jsoftware.com/help/learning/01.htm are useful and should indeed get special syntax even if only in the form of those capital letter operators i was thinking of (should those really be operators when they are connected e.g. "fnMlist" (map fn list) (which would prevent camelCase), or only when they are alone e.g. "fn M list"?)
probably lots of useful fns in further chapters in that book, too
---
svnpenn 3 hours ago [–]
I like this idea, but I dont know if Hyper is the best package to go with. Hyper occupies part of the Rust ecosystem that I think suffers from package bloat, like much of NPM. For example, currently Hyper requires 52 packages:
autocfg, bitflags, bytes, cfg-if, fnv, fuchsia-zircon, fuchsia-zircon-sys, futures-channel, futures-core, futures-sink, futures-task, futures-util, h2, hashbrown, http, http-body, httparse, httpdate, indexmap, iovec, itoa, kernel32-sys, lazy_static, libc, log, memchr, mio, miow, net2, pin-project, pin-project-internal, pin-project-lite, pin-utils, proc-macro2, quote, redox_syscall, slab, socket2, syn, tokio, tokio-util, tower-service, tracing, tracing-core, try-lock, unicode-xid, want, winapi, winapi-build, winapi-i686-pc-windows-gnu, winapi-x86_64-pc-windows-gnu, ws2_32-sys
reply
nicoburns 2 hours ago [–]
Part of this is just crates being broken up more in Rust. For example the `http` crate only contains trait (interface) definitions. They break down like so:
Platform integration: libc, winapi, winapi-build, winapi-i686-pc-windows-gnu, winapi-x86_64-pc-windows-gnu, ws2_32-sys, fuchsia-zircon, fuchsia-zircon-sys, kernel32-sys, redox_syscall
Primitive algorithms: itoa, memchr, unicode-xid
Proc macro / pinning utilities: proc-macro2, autocfg, cfg-if, lazy_static, quote, syn, pin-project, pin-project-internal, pin-project-lite, pin-utils
Data structures: bitflags, bytes, fnv, hashbrown, indexmap, slab
Core Rust asyncio crates: mio, miow, iovec, tokio, tokio-util, futures-channel, futures-core, futures-sink, futures-task, futures-util,
Logging: log, tracing, tracing-core
The following are effectively sub-crates of the project: http, http-body, httparse, httpdate, tower-service, h2
Not sure what these are for: net2, socket2, try-lock, want
reply
---
---
"By marking themselves as no_std, programs confine themselves to the functionality found in libcore. This functionality, in turn, makes no system assumptions — and in particular, performs no heap allocations. This is not easy for a system to do; it requires extraordinary discipline by those developing it (who must constantly differentiate between core functionality and standard functionality) and a broad empathy with the constraints of embedded software. Rust is blessed with both, and the upshot is remarkable: a safe, powerful language that can operate in the highly constrained environment of a microcontroller — with binaries every bit as small as those generated by C. " -- [1]
libcore: https://doc.rust-lang.org/core/
---
rust pretty print in hex:
" Two years ago, I mentioned that I love format!, and in particular the {:?} format specifier. What took me longer to discover was {:#?}, which formats a structure but also pretty-prints it (i.e., with newlines and indentation). This can be coupled with {:#x} to yield {:#x?} which pretty-prints a structure in hex. " -- [2]
---
"Rust refuses to paper over the cracks in computing’s foundation for sake of expediency. If this can feel unnecessarily pedantic (can’t I just have a timestamp?!), it is in multi-platform support where this shines: software that I wrote just… worked on Windows. (And where it didn’t, it was despite Rust’s best efforts: when a standard library gives you first-class support to abstract the path separator, you have no one to blame but yourself if you hard-code your own!)" -- [3]
---
"
Concurrency
It shouldn't come as a surprise that a lot of effort in the new C specification went into making it easier to write multithreaded code in C. The biggest change is that C now has a memory model that accepts the fact that variables may be modified from multiple threads. This comes with a set of explicit memory orderings and barriers, which I discussed in my earlier article "Understanding C11 and C++11 Atomics."
Interestingly, C11 comes with a set of standard functions for creating threads, as well as their basic synchronization primitives, which has been the cause of a lot of grumbling. The interfaces are semantically more or less equivalent to the POSIX threading APIs, but with some subtle differences.
C11 also includes some poor design choices, such as specifying timeouts in absolute times. This leads to some interesting problems when; for example, when the Network Time Protocol changes your clock time backward. In general, expiring from a timeout too early is mildly irritating, whereas a timeout that's never reached can cause code to lock up completely. With absolute timeouts, the C11 versions opt for the worse option.
The rationale for C11 threading support is twofold. First, since C is now designed to support concurrency, it would be a bit silly if the standard didn't provide any mechanism for actually spawning multiple threads. Second, the POSIX thread API isn't universal. The standards committee hopes that the C11 threading APIs will be implemented for embedded environments on non-POSIX systems. Other systems are expected to implement them on top of their native threading APIs.
The other thread-related change is the inclusion of the _Thread_local storage qualifier, which means that each thread gets a private copy of a variable. Unfortunately, as with the GCC version of this feature, it's incredibly difficult to use correctly. The POSIX threading APIs for thread-local storage allow you to register a cleanup function to avoid leaks when a thread exits. _Thread_local variables lack this capability; so, for example, they can't safely contain pointers to objects that need to be cleaned up when the thread exits. " -- [4]
---
"
This implements an approximation to C++ vector<> for C, in that it provides a generic definition for dynamic arrays which you can still access in a typesafe way using arr[i] or *(arr+i). However, it is simply a convenience wrapper around the common idiom of of keeping a set of variables (in a struct or globals) which store - pointer to array - the length of the "in-use" part of the array - the current size of the allocated array I find it to be the single most useful non-built-in-structure when programming in C (hash tables a close second), but to be clear it lacks many of the capabilities of C++ vector<>: there is no range checking, the object address isn't stable (see next section for details), the set of methods available is small (although the file stb.h has another implementation of stretchy buffers called 'stb_arr' which provides more methods, e.g. for insertion and deletion). " -- [5]
---
gui lib
https://eugenkiss.github.io/7guis/tasks/
---
https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/
---
https://github.com/darklang/tablecloth
" Standard library#
Most of the code in Dark uses Tablecloth, which has the same interface for Bucklescript and native OCaml.
A lot of the backend uses Core, one of the most popular standard libraries for OCaml. The Jane Street Core library has three flavors: Base, Core_kernel and Core, each with progressively more expansive functionality. The native version of Tablecloth is built on top of "Base". The Dark backend typically uses Core_kernel as we have not transitioned to Tablecloth fully.
Note: we try to use Core_kernel directly when implementing the language and standard libraries, as Tablecloth is still in flux and has not yet reached stability. "
---
[6] makes the point that we need the efficiency of clojure transducers with the syntax of ->>
e suggests a syntax of something like
(t-> payments (filter cash?) (map :amount) (transduce +))
and provides a macro to give that (which is the example macro i gave in the previous section)
---
Go's new file system lib:
https://tip.golang.org/pkg/io/fs/
https://go.googlesource.com/proposal/+/master/design/draft-iofs.md
---
high-speed mutation friendly SortedSet?
https://blog.discord.com/using-rust-to-scale-elixir-for-11-million-concurrent-users-c6f19fc029d3
kilotaras 19 hours ago [–]
Articles SortedSet?[0] is basically a pseudo-BTree with fixed depth = 2 and fixed max_size of leafs. This gives O(log n) search and O(sqrt n) inserts [1].
It would mean that insertion at beginning is worst case scenario (split + need to move all buckets), but timing of insert is actually dominated by adding size of the buckets to calculate final index.
Spending a little bit of time on research, finding https://en.wikipedia.org/wiki/Order_statistic_tree and just using G++ implementation would probably yield better result and less code to support.
G++ has __gnu_pbds which add O(log n) "find_by_order" and "order_of_key" to trees, e.g. [2].
[0] https://github.com/discord/sorted_set_nif/blob/master/native...
[1] Technically O(n/max_size + max_size) but we can assume that max_size is selected to be ~sqrt n
[2] https://www.ideone.com/8mzxGR
reply
---
kornel 1 month ago
| link |
WASM is sandboxed to maximally hermetic paranoid level. It doesn’t support any communication with the outside world, except callbacks exposed by the interpreter. You can’t write WASM for your operating system. There is an emerging abstraction layer called WASI, which is like a very basic tiny abstract operating system.
In practice that means you can’t use use your language’s standard library, not even printf, unless it’s been rewritten for the WASI “operating system”.
---
https://github.com/louthy/language-ext
---
" Very few applications need random read/write access to files. Most of the time, you need to read an entire file in, or write an entire file out via the streaming access APIs. This core fact of typical usage is why I think so many application developers have naive expectations about filesystem behavior.
Read-only random-access is well served by mmap() and pread(). " [7]
---
"I write database engines for Linux and the filesystem situation really is a train wreck. ... Ironically, I now tend to borrow the low-level storage interface from database kernels, which abstracts the filesystem mess, for all code that needs to work with storage even if it isn't a database. It provides a saner interface with more consistent guarantees and often better performance. "
ChrisSD?