Learn something for 2025? - Page 1
Forum section: electronics / general

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 01, 2025, 10:52:52 pm
content: Maybe it's time to give it a shot:https://ada-lang.io/

author: wilfred
author_rank: Super Contributor
timestamp: January 02, 2025, 02:30:04 am
content: For me it would be Simula 67. Anyone know where to download a compiler, specifically for the DEC System10?

author: tggzzz
author_rank: Super Contributor
timestamp: January 02, 2025, 11:26:08 am
content: Quote from: wilfred on January 02, 2025, 02:30:04 amEasier to find a Smalltalk implementation, since there are many available. Better as well, IMHOAs for ADA-like languages, I'd go for SPARK or VHDL.

author: eeproks
author_rank: Newbie
timestamp: January 02, 2025, 05:40:59 pm
content: I always enjoyed Ada, and I find itwaymore comfortable than the new hotness 'safe' languages, particularly Rust. GNAT is kinda crufty, but the AdaCore stuff looks much more polished. The language has also evolved alotsince the Ada-95 days.

author: tggzzz
author_rank: Super Contributor
timestamp: January 02, 2025, 06:02:59 pm
content: I liked Ada's starting point and attitude, but I was wary of the 1980s Ada. I never had the opportunity to use it in anger. The same can be said of Erlang.Instead I had to use C, and Rust is shaping up to be preferable to that. (C++: I chose to avoid it, and managed to).Smalltalk in the 80s was remarkably productive and introduced many seminal advances, e.g. IDEs and JIT runtime environments. Java is its natural successor, with many improvements.But the Adacore offering does look like it is worth investigating, especially the SPARK subset.

author: nctnico
author_rank: Super Contributor
timestamp: January 02, 2025, 10:12:41 pm
content: Quote from: SiliconWizard on January 01, 2025, 10:52:52 pmIt would be cool if you can get it going on a microcontroller without needing to pay license fees for commercial products.

author: radiogeek381
author_rank: Regular Contributor
timestamp: January 03, 2025, 11:41:53 pm
content: Quote from: wilfred on January 02, 2025, 02:30:04 amI remember waiting in joyful anticipation for the arrival of the DECUS tape with the Simula compiler on it. It will be in one of the "decus_20tap" files found here:http://www.bitsavers.org/bits/DEC/pdp10/sri-arc/There may also be a SAIL compiler in there somewhere for the Algol fans.I wrote a fair bit of Simula code as late as the mid 80's, as it was a simple language for writing discrete event simulators.

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 04, 2025, 11:01:49 pm
content: Quote from: nctnico on January 02, 2025, 10:12:41 pmYou can. But even with 'alire', setting up the toolchain is a PITA (it's doable, but still annoyingly quirky, probably for lack of traction, so not enough people helping making this available for free).One can start here:https://blog.adacore.com/ada-on-any-arm-cortex-m-device-in-just-a-couple-minutesDon't expect it to work right as is described in the tutorial though in "a couple minutes". It probably won't happen. I tried on Linux and was able to get everything working (so up to generating the link­er script and start­up code) except getting the support for ARM cortex eabi, so building the project failed. 'alire' doesn't pull the compiler on its own as is "suggested". Or maybe I missed something. The Ada front-end for GCC for arm-none-eabi is not available directly in my Linux distro and I doubt it is in most others either. I think this can be downloaded from AdaCore, but didn't try going this route yet:https://www.adacore.com/downloadTrying Ada for x86_64 targets on desktop is relatively easy though with alire, and can also be done without it, just with the raw GCC toolchain with the Ada front-end. If you're on Linux, many distros have a "gcc-ada" package of some kind.Building the Ada front-end when building GCC for x86_64 is pretty much merely a matter of adding "ada" in the list of supported languages when configuring it, because the runtimes are already part of mainline. For embedded targets, that's not so and thus it's a royal pain. Too bad.For those having a working GCC with the Ada front-end ("GNAT") on the desktop, here is a "bit more than hello world" to get you started, and the way you can build it purely with GCC/GNAT, without alire or gprbuild (which is a popular build tool for Ada).Code:with GNAT.IO; use GNAT.IO;procedure Hello istype Number is digits 12 range -999_999_999_999.0e999 .. 999_999_999_999.0e999;function Sum(A, B : Number) return Number withPre => A <= 0.0 and B >= 0.0,Post => Sum'Result = A + B;function Sum(A, B : Number) return Number isbeginreturn A + B;end;beginPut_Line("Hello World!");Put_Line("Sum(-2, 5) = " & Number'image(Sum(-2.0, 5.0)));Put_Line("Sum(2, 5) = " & Number'image(Sum(2.0, 5.0)));end Hello;Name the source file "hello.adb".It contains an example of a function with pre- and post-condition. As you may have guessed, the second call to Sum: "Sum(2, 5)" will fail as it doesn't match the pre-condition.To build it:Code:gcc -c -Wall -gnata hello.adbgnatbind hellognatlink helloNote the '-gnata' option that is required to support assertions, which will trigger an assertion at run-time when executing the second Sum(). If you omit '-gnata', the two Sum() will execute ignoring the pre-condition. You can otherwise catch it with an exception block.Now, apparently GCC doesn't support checking pre- and post-conditions at compile time, which is a bummer. I think Spark does.Otherwise, you need to use a static analysis tool, such as GNAT SAS:https://docs.adacore.com/live/wave/gnatsas/html/user_guide/introduction.htmlI think it's integrated in GNAT Studio, although that'll have to be checked.And if you prefer using GNAT Studio (AdaCore's IDE), see here:https://github.com/AdaCore/gnatstudiothere are Linux and Windows binaries.

author: DiTBho
author_rank: Super Contributor
timestamp: January 05, 2025, 12:27:23 pm
content: Quote from: SiliconWizard on January 04, 2025, 11:01:49 pmAda-core is mainline and it is written in Ada.You can compile gcc with ada support only if the installed gcc toolchain already supports Ada in the language list.Code:macmini2 # gcc -vUsing built-in specs....--enable-languages=c,c++,fortran...By default Gentoo GNU/Linux does not have "Ada" in the enable-languages list, and this means you need a bootstrapper!which, unfortunately, is no more available for { arm, powerpc, ... }Code:!system-bootstrap? (amd64?(${BASE_URI}/${magic}?filename=${BTSTRP_AMD64}.tar.gz -> ${BTSTRP_AMD64}.tar.gz)x86?(${BASE_URI}/${magic}?filename=${BTSTRP_X86}.tar.gz -> ${BTSTRP_X86}.tar.gz)Available { amd64, x86 }I managed to build myself { HPPA2, MIPS32BE, PPC32BE, ... } native toolchains in 2020.Still in the to-do list { MIPS32LE, PPC32LE, PPC64BE, PPC64LE, ARM5LE ... }

author: DiTBho
author_rank: Super Contributor
timestamp: January 05, 2025, 12:35:08 pm
content: Quote from: tggzzz on January 02, 2025, 06:02:59 pmRust? For which projects do you say it's shaping up to be preferable to the standard C/89/99/...?Quote from: tggzzz on January 02, 2025, 06:02:59 pmYes, I think the same thing. In the end you can evaluate Arduino/C++, a limited use of C++ might make sense.But don't look at the default libraries because they are not a good example.

author: DiTBho
author_rank: Super Contributor
timestamp: January 05, 2025, 12:40:29 pm
content: -your "language" myC is nothing but a debug tool for the C language!nobody will ever use its extensions nor consider it a programming language... -the worst thing I was said by the end of the 2024So true, in the end.Good luck getting Ada working on MIPS32 and MIPS5++ ...

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 05, 2025, 11:47:47 pm
content: The tooling is certainly one important issue for anyone who really wants to use Ada. If you're on x86_64, it's not a problem though, and toolchains are available either from AdaCore, or from your Linux distro if you're on Linux. I find it odd that Gentoo apparently doesn't have an existing package for that. Many other distros do. Otherwise, one can download ready-made binaries from AdaCore. They have binaries for RISC-V and ARM apparently too, but I didn't try them. I think these are "native" tools though, meaning, not cross-compilers. Building a cross-compiler for Ada for any other target than x86_64 looks like a bit of a mess. To say the least.But for those that can use it on x86_64, I say that's worth a try. If just to discover the language, learn something, even if you don't routinely use it afterwards. Judging not just from this thread, but from comments one can hear everywhere, a majority of people seem to have little clue what Ada really is and what it has to offer as a language, with a lot of prejudice. The last standard revision is 2022.As to using one's own language, it can certainly be a solution in some cases. Being dependent on maintainers from a large organization leads to situations where you're usually out of luck if your target is not supported. Independence is great. It has a cost, though.

author: DiTBho
author_rank: Super Contributor
timestamp: January 06, 2025, 12:03:52 am
content: Gentoo has a gnat ebuild, which, as I wrote above, needs a bootstrapper to be compiled because the default gcc toolchain does not have Ada in the gcc-enabled-languages.I don't know why, already suggested to include Ada, no dice.

author: DiTBho
author_rank: Super Contributor
timestamp: January 06, 2025, 12:14:06 am
content: Ghdl depends on gnat.Imagine your boss invests 5k euro in a modern 8 cores PPC64le server, and ... Ops, can't compile ghdl because I don't have a working ada compiler.Fixed this situation for HPPA2, partially solved for ppc64le.System76 is now promoting a new arm64le multicore server. Interesting hw, good price. It would be more interesting with ghdl running.

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 06, 2025, 01:04:45 am
content: Quote from: DiTBho on January 06, 2025, 12:03:52 amAh yes, then it's like most other distros. It's just that as a source-based distro, you feel the pain of the build, bootstrapping included. Others with binary packages do the same. The base GCC packages usually don't have Ada enabled. They rarely enable more than C and C++. Then there are additional packages for adding Ada support, or D support. The reason is probably that since there are so few users of Ada, the extra build time (and space for binary distributions) is not warranted for most users. I bet many would get angry on Gentoo if the Ada front-end was automatically built when they emerged gcc.As to supporting more targets, I don't know how hard it is. Isn't it mainly a matter of writing runtimes? (But that's not a trivial task apparently.)I've seen that there was a Ada front-end for LLVM, didn't try though. I don't know if it supports more targets. Possibly so?https://github.com/AdaCore/gnat-llvm