Re: vibe-d REST API: POSTing a struct
On Saturday, 2 December 2023 at 12:39:01 UTC, bomat wrote: On Friday, 1 December 2023 at 19:18:19 UTC, bomat wrote: So my question is, is it possible to have vibe-d parse the request body into a struct "implicitly"? I'm gonna answer my own question here, it's `@bodyParam`. https://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/40001/ https://github.com/vibe-d/vibe.d/pull/1676 I wasn't aware of the dedicated vibe-d forum before. As I've seen some vibe-d related questions in this forum as well, I thought this would be the place to ask... does it active?
Re: Checking path name
On Thursday, 14 December 2023 at 03:58:37 UTC, Joel wrote: If I get user input, for example, how do I check to see if it's a valid path, like, file name. ```d // something like this: if (getUserInput.isValidPath) { ... } ``` https://dlang.org/phobos/std_file.html#exists
Re: Checking path name
On Thursday, 14 December 2023 at 09:38:30 UTC, Joel wrote: On Thursday, 14 December 2023 at 08:47:49 UTC, Anonymouse wrote: On Thursday, 14 December 2023 at 03:58:37 UTC, Joel wrote: https://dlang.org/phobos/std_path.html#isValidPath https://dlang.org/phobos/std_path.html#.isValidFilename Oh, forgot about std.path But what's the difference between path and file name? File name can't contain path separators.
Re: Advent of Code 2023
On Sunday, 3 December 2023 at 15:04:09 UTC, Siarhei Siamashka wrote: On Saturday, 2 December 2023 at 14:35:19 UTC, Sergey wrote: Some other solutions that could be worth to check: https://github.com/andrewlalis/AdventOfCode2023/blob/main/day_1/solution.d https://github.com/schveiguy/adventofcode/blob/master/2023/day1/trebuchet.d It's indeed a good idea to have solutions on github, so I pushed mine here: https://github.com/ssvb/adventofcode/blob/main/2023/day01/trebuchet.d Bummer, looks like publishing the puzzle input data is forbidden: https://www.reddit.com/r/adventofcode/comments/18ehed6/re_not_sharing_inputs_psa_deleting_and_committing/ So for the purposes of automated testing and/or benchmarking, it would be necessary to invoke one of the numerous existing AoC command line client applications to download the input data before running the test. BTW, there seems to be no `aoc-cli` tool implemented in D yet ;-)
Re: D is a great language, but I've had a bad experience getting started
On Thursday, 14 December 2023 at 12:59:32 UTC, Renato wrote: On Thursday, 14 December 2023 at 12:30:35 UTC, Renato wrote: The other compilers were also easily installable on Kubuntu using snap. It seems that the Ubuntu "snap"s are not being updated for a few years?? It seems some of my problems are related to the very old versions I got with snap :( dub - 1.19.0 (seems to be from Oct 2020) ldc2 - 1.24.0 (seems to be from Oct 2020) dmd - v2.090.1 (Feb 2020) I feel stupid for choosing snap (I don't use snaps, just felt like a convenient thing to try this time!). I will try using latest of everything on Linux (on Mac I think I was already fine on latest) and hope it works better. What's worked for me on Ubuntu is to download the .deb from the downloads page and sudo apt install ./dmd_2.106.0-0_amd64.deb. Always have the latest release and never have problems.
Re: D is a great language, but I've had a bad experience getting started
On Thursday, 14 December 2023 at 13:27:29 UTC, Renato wrote: On Thursday, 14 December 2023 at 13:12:06 UTC, Richard (Rikki) My build options are currently: ``` "dflags-dmd": [ "-v"], "lflags": ["-ld_classic"] ``` I tried some variations but nothing worked. Previously for macOS it was required to write “export MACOSX_DEPLOYMENT_TARGET=11” Also remove dmd/dub first. Then try to use LDC from official GitHub Release. And update the PATH variable. Maybe script from the official download page is doing the same - idk. At least this is what I’m using on macOS (but M1). DMD just doesn’t exist for me anymore)
Re: D is a great language, but I've had a bad experience getting started
On Thursday, 14 December 2023 at 13:12:06 UTC, Richard (Rikki) Andrew Cattermole wrote: On 15/12/2023 2:02 AM, Renato wrote: How do you tell dub to "build and link in a single step"? This should do it: ``--combined --build-mode=allAtOnce`` I run this: ``` dub build --combined --build-mode=allAtOnce ``` Still got an error: ``` cc /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o -o /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject -g -m64 -Xlinker -no_compact_unwind -ld_classic -L/Library/D/dmd/lib -lphobos2 -lpthread -lm ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: pointer not aligned at address 0x1000741C9 ('anon' + 457 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o) ld: warning: pointer not aligned at address 0x1000741E6 ('anon' + 486 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o) ld: warning: pointer not aligned at address 0x1000742C9 ('anon' + 713 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o) ld: warning: pointer not aligned at address 0x100074311 ('anon' + 785 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o) ld: warning: pointer not aligned at address 0x100074367 ('anon' + 871 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o) ld: warning: pointer not aligned at address 0x1000743A2 ('anon' + 930 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o) ld: warning: pointer not aligned at address 0x1000743BE ('anon' + 958 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o) ld: warning: pointer not aligned at address 0x1000743FA ('anon' + 1018 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o) ld: unaligned pointer(s) for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: linker exited with status 1 Error /Library/D/dmd/bin/dmd failed with exit code 1. ``` cc version: ``` cc --version Apple clang version 15.0.0 (clang-1500.1.0.2.5) Target: x86_64-apple-darwin23.1.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin ``` Not sure that the options are correct: "-Xlinker -no_compact_unwind -ld_classic -L/Library/D/dmd/lib -lphobos2 -lpthread -lm". My build options are currently: ``` "dflags-dmd": [ "-v"], "lflags": ["-ld_classic"] ``` I tried some variations but nothing worked.
Re: D is a great language, but I've had a bad experience getting started
On Thursday, 14 December 2023 at 12:59:04 UTC, Hipreme wrote: Yeah, D has a really bad experience in MacOS. If you want to use it on mac, I suggest using LDC. And the package managers doesn't do D justice. You want to get the zip and setup the environment variables yourself, this is the best way to make it work. The "D recommended way" to install is by using the install.sh script, found at https://dlang.org/install.html Thanks for letting me know! It's good to have other's perspectives. Hope your game engine is coming along nicely :) Looks like I got it working with the overly complicated Ubuntu instructions (I used snap instead before because it was just "snap install dmd" rather than 5 large shell commands!)... if that still gives me trouble I will stick with the sh file you've linked (there were so many options for installing the compilers and I had to pick the worst one I suppose).
Re: D is a great language, but I've had a bad experience getting started
On 15/12/2023 2:02 AM, Renato wrote: How do you tell dub to "build and link in a single step"? This should do it: ``--combined --build-mode=allAtOnce``
Re: D is a great language, but I've had a bad experience getting started
On Thursday, 14 December 2023 at 12:59:34 UTC, Richard (Rikki) Andrew Cattermole wrote: Welcome! Regarding the problems with dub on OSX, that'll be due to separate build + link steps. It should work ok if you build and link in a single step with the workaround applied. DC is an environment variable that should point to the D compiler. As a variable this particular one has some sort of story with it, I just can't remember it. We'd need to know what is requesting it to find out how to resolve it. Please try again with ``-v`` that should tell us what is wanting it. That output was already with -v enabled. It just didn't show anything else relevant. But I found an issue from a few years ago about that: https://github.com/vibe-d/vibe.d/issues/2677 That's why I figured out I was using very old versions of everything on Linux. How do you tell dub to "build and link in a single step"?
Re: D is a great language, but I've had a bad experience getting started
Welcome! Regarding the problems with dub on OSX, that'll be due to separate build + link steps. It should work ok if you build and link in a single step with the workaround applied. DC is an environment variable that should point to the D compiler. As a variable this particular one has some sort of story with it, I just can't remember it. We'd need to know what is requesting it to find out how to resolve it. Please try again with ``-v`` that should tell us what is wanting it.
Re: D is a great language, but I've had a bad experience getting started
On Thursday, 14 December 2023 at 12:30:35 UTC, Renato wrote: The other compilers were also easily installable on Kubuntu using snap. It seems that the Ubuntu "snap"s are not being updated for a few years?? It seems some of my problems are related to the very old versions I got with snap :( dub - 1.19.0 (seems to be from Oct 2020) ldc2 - 1.24.0 (seems to be from Oct 2020) dmd - v2.090.1 (Feb 2020) I feel stupid for choosing snap (I don't use snaps, just felt like a convenient thing to try this time!). I will try using latest of everything on Linux (on Mac I think I was already fine on latest) and hope it works better.
Re: D is a great language, but I've had a bad experience getting started
On Thursday, 14 December 2023 at 12:30:35 UTC, Renato wrote: Hi, I have been trying D for the last few days... I am only writing because I really, really like the language! It's absolutely stunning how the features it has are simple, well designed and at the same time incredibly advanced! All with an extremely fast compiler, which is almost unbelievable. Yeah, D has a really bad experience in MacOS. If you want to use it on mac, I suggest using LDC. And the package managers doesn't do D justice. You want to get the zip and setup the environment variables yourself, this is the best way to make it work. The "D recommended way" to install is by using the install.sh script, found at https://dlang.org/install.html I personally never used GDC since I develop on Windows 99% of the time (the other time is only used on the other platforms when I need to develop specific things for them). The error you're seeing is related to a DC variable. The D Compiler variable. I would guess this is a problem caused by your package manager when installing D. I've been developing a game engine which does compiler execution for the user because it can get quite hard to understand depending on the size of the project.
D is a great language, but I've had a bad experience getting started
Hi, I have been trying D for the last few days... I am only writing because I really, really like the language! It's absolutely stunning how the features it has are simple, well designed and at the same time incredibly advanced! All with an extremely fast compiler, which is almost unbelievable. However, I faced a lot of issues which I think could be addressed to make others have a much better time getting started so they don't stop before even being able to appreciate all the great things about D. First of all, if you have latest MacOS and install DMD (I tried several methods) it just doesn't work due to a linker problem: https://forum.dlang.org/post/asanawokkhqhhvryn...@forum.dlang.org Luckily, it seems the issue was fixed 2 weeks ago, but unfortunately that's not released yet (so one less problem for newcomers). Anyway, the workaround is to use a linker flag to make it work with the current DMD compiler... compiling on the CLI now worked with that, but then I tried to compile a dub project and faced the same issue even after adding the linker flag. The error was this: ``` d: warning: pointer not aligned at address 0x1000743BE ('anon' + 958 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o) ld: warning: pointer not aligned at address 0x1000743FA ('anon' + 1018 from /Users/renato/.dub/cache/myproject/~master/build/application-debug-tVTrfpmFVmiMN6SGvTQC-w/myproject.o) ld: unaligned pointer(s) for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: linker exited with status 1 Error /Library/D/dmd/bin/dmd failed with exit code 1. ``` At this point I had to give up MacOS development and use my Linux machine. On Linux I like using Nix for package management... when asking the DMD package to install, however, it seems to run the full test suite for the DMD compiler locally... I waited for 30mins before giving up. Would be nice to get instructions on how to install it without running the tests. I then decided to usg GLC on Linux. That worked fine and installed with `apt install gdc` in a couple of seconds :). The other compilers were also easily installable on Kubuntu using snap. Now, I tried to create a HTTP server using vibe.d. I followed their instructions to run "dub init" and that seemed to be working fine until some error came up. Here's my terminal output: ``` ➜ dserver dub build Fetching vibe-core 2.5.1 (getting selected version)... Fetching memutils 1.0.9 (getting selected version)... Fetching taggedalgebraic 0.11.22 (getting selected version)... Fetching vibe-container 1.0.1 (getting selected version)... Fetching vibe-d 0.9.7 (getting selected version)... Fetching stdx-allocator 2.77.5 (getting selected version)... Fetching diet-ng 1.8.1 (getting selected version)... Fetching openssl 3.3.3 (getting selected version)... Fetching eventcore 0.9.27 (getting selected version)... Fetching mir-linux-kernel 1.0.1 (getting selected version)... Fetching libasync 0.8.6 (getting selected version)... Fetching openssl-static 1.0.2+3.0.8 (getting selected version)... Invalid variable: DC ➜ dserver ls dub.sdl dub.selections.json public source views ➜ dserver dub build Invalid variable: DC ``` Really hard to get stuff working, unfortunately, and the error message is just not helpful. I also tried the Language Server (serve-d) with emacs and it's not working properly on Linux, but seems to work somewhat (it shows errors but no autocompletions using eglot at least) on Mac. I was really eager to get a D project and up and running, but due to these issues I am not quite sure I will persist, unfortunately, as even a language like Nim (which is a bit similar to D in its scope) has a much better story getting started. Anyway, please let me know if you have hints for some of the issues above and hope things like this can get better in the future.
Re: surviving wasm
I forgot to link this nice website that got me started with WASM: https://schellcode.github.io/webassembly-without-emscripten
Re: surviving wasm
On Wednesday, 13 December 2023 at 20:40:20 UTC, monkyyy wrote: so long term planning on wasm raylib; I want compatibility with the good parts of the std, the std is causal about using libc while ldc-wasm half-baked implication is missing a bunch of basically worthless symbols but given the std is 1 million lines of code it will be a perennial problem that I make something work natively, I try it in wasm, it breaks citing a random core lib at a random line; the options I know about are: 1. use a "team betterc" personal std that doesn't have the apis I want, apis I know and probably limited 2. merge "use libc less" upstream to a std that has been slow to merge changes and probably doesnt care about wasm 3. fork the std 4. maintain patches to the std that go in and rewrite them live with root :D what could go wrong 5. make my own personal std that matches the std api of the parts I use I hate all these options there is no libc on WASM, you'll either have to use WASI or emscripten emscripten was made for this specific case, so you don't have to worry about anything https://theartofmachinery.com/2018/12/20/emscripten_d.html I personally started from scratch, so i only pay for what i use, and carefully craft my own std/runtime, and it's the way to go imo, just like i'd do in C, but with the advantage of using a better language (D)
Re: Checking path name
On Thursday, 14 December 2023 at 08:47:49 UTC, Anonymouse wrote: On Thursday, 14 December 2023 at 03:58:37 UTC, Joel wrote: If I get user input, for example, how do I check to see if it's a valid path, like, file name. ```d // something like this: if (getUserInput.isValidPath) { ... } ``` Is that not how it works? https://dlang.org/phobos/std_path.html#isValidPath https://dlang.org/phobos/std_path.html#.isValidFilename Oh, forgot about std.path But what's the difference between path and file name?
Re: Checking path name
On Thursday, 14 December 2023 at 03:58:37 UTC, Joel wrote: If I get user input, for example, how do I check to see if it's a valid path, like, file name. ```d // something like this: if (getUserInput.isValidPath) { ... } ``` Is that not how it works? https://dlang.org/phobos/std_path.html#isValidPath https://dlang.org/phobos/std_path.html#.isValidFilename