[ / / / / / / / / / / / / / ] [ dir / animu / doomer / fa / hentai / sl / sw / tahlia / wmafsex ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Email
Comment *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

[–]

 No.1004425>>1004435 [Watch Thread][Show All Posts]

Is Ada worth learning for a hobbiest C/C++ programmer who doesn't intend to LARP as a DoD contractor?

Where's the best place to start?

 No.1004427

Why would you want to learn Ada if you're not LARPing as a DoD contractor?


 No.1004435>>1004617

>>1004425 (OP)

Read the book by John Barnes - Programming in Ada 2012. It's a great language. Very cool and legal.


 No.1004617

>>1004435

Thanks. I looked around for a while and finally found a PDF because my local library system is bereft of CS books.

https://0x0.st/sGEm.pdf


 No.1004739>>1004758 >>1004762

I've got a few C projects for work, some of them inherited from p. terrible codebases. I'd like to use Ada for some of them. My thoughts went more or less as follows:

>let's write it in C

yeah, that works...

>let's write it in C++

that'd probably still be acceptable, but I don't like C++ and I'm not willing to invest the amount of time and effort into it that it'd take for a simple one-screen application to not commit some trivial mistake that makes it silently 50x times as expensive as it looks.

>let's write it in memelang

with a GC? No. Not for this stuff.

>let's write it in vaporlang

wow vaporlang is p. cool anon but I can't help noticing that there's no real documentation and that there are several breaking changes planned in the core syntax of the language.

>let's write it in cancer-curing superpowered superlang

after spending a year in deep meditation, I can finally say that I'm somewhat competent at curing cancer but... nobody is ever going to be able to read this code and I don't want the next maintainer of these projects to just instantly rewrite them.

>let's write it in Rust

the community is way too hostile towards and exclusive of people like me. I just wouldn't feel safe if I ever attended a Rust conference, you know?

>let's write it in Ada

OK.

gnatpp means not having to care about formatting.

Words_Like_This are impossible to type without RSI but they're very pleasant on the eyes and with a tiny bit of setup you can only ever type words-like-this.

actually the language as a whole is crazy easy to read. The only problem I've run into is that all the names are in one namespace so you can run into situations like

<what's a good name for a guard record type?

<How about guard?

<What's a good name for a guard variable?

<How about guard?

<oops, make that some_guard.

<Now let me pass this guard variable to a function:

<some_routine (guard);

<error: PC LOAD LETTER ??

<WHAT THE FUCK DOES THAT MEAN?

I started reading other material and only got "Programming in Ada 2012" late, but it seems like the best book to start with. In particular it goes through the standard libraries in a lot of detail. So far, Ada's impressed me in

1. you can create very precise numeric types and do all your work with them, and then the types themselves carry a lot of information that code can refer to. Ada has capabilities here that only experimental dependent-type languages are starting to rediscover.

2. you can use dynamic memory a lot less, because it's more natural to get an allocation from the caller (which can be stack-allocated) instead of allocating something and then expecting the caller to take it over.

3. Pre/Post conditions are amazing for code correctness. You read about them and you're like, eh, this is just assert(), but then they catch all your bugs without you putting any effort into them.

4. when you aren't blatantly trying to pass the name of a type as a variable, the compiler catches a lot and is helpful to a surprising degree. Hey anon you're not mutating that variable, want to make it constant? Hey anon you're switching over an enum but you missed a case, aren't you glad you're not writing Go right now? Hey anon you're testing to see if that variable is negative but by its type it should never be negative, are you high?

5. C FFI is very easy. There's even C header parsing, built into gcc, that generates Ada code for you.

6. Ada's generics.

I'm still looking forward to

1. pooled allocators. skimming "Programming in Ada 2012", I get the feeling that the pieces are all there for your own allocator and you just need to put them together.

2. something called 'controlled' types that manage their memory according to the scope of a variable? reference counting's also an option?

3. finding more ways to write less code. I only discovered "for X of BLAH" to loop over all the members of a thing (be it a multidimensional array or a hash table) yesterday.

4. understanding more of the costs of what I'm doing in Ada. You get 'copy semantics' on assignment but the language can cheat with parameters or something.


 No.1004758>>1004762

>>1004739

oh yeah, and Ada has Erlang-style message-passing between concurrent processes. Wild.


 No.1004762>>1004766 >>1004773 >>1004786 >>1005050

>>1004758

>>1004739

too bad its named after a thot that never programmed


 No.1004766

>>1004762

she's not so bad. She was an aristocrat that was into math and had some friends. She was far too ahead of her time to have any significant influence on computing, and with in light she's not a bad choice of name for a language that was too verbose and too big with too much of a stdlib at release, when now it's a lot less remarkable in all respects (because other languages have grown).

as a feminist hero she's ridiculous, but feminism is ridiculous. As a real woman she might've been right up your alley.


 No.1004773>>1004786

>>1004762

>never programmed

Mate, she even shared her source code; you can view it in a museum. Just because bluehairs of today have marred her image by association, it doesn't mean you have to denigrate her. She came from very good stock, had copious wealth, an education and was surrounded by the intellectuals of her day, it's not a surprise that she smart.


 No.1004786>>1004794 >>1005145

>>1004762

>>1004773 is correct. Ada Lovelace has been (mis)appropriated by modern feminists for their own ends, but that doesn't change the fact that she was the real deal when it came to understanding and programming Babbage's machines.

https://blog.stephenwolfram.com/2015/12/untangling-the-tale-of-ada-lovelace/


 No.1004794

>>1004786

>To some she is a great hero in the history of computing; to others an overestimated minor figure. I’ve been curious for a long time what the real story is.

...

>When one reads Ada’s letters, what comes through is a smart, sophisticated person, with a clear, logical mind. What she says is often dressed in Victorian pleasantaries---but underneath, the ideas are clear and often quite forceful.

good read.


 No.1004976>>1005010 >>1005041 >>1005043


 No.1005010

>>1004976

>oh they like Trump? ha, well of

<SNL HUMOR INTENSIFIES

oh.


 No.1005041

>>1004976

Often you get some low level intern or quota hire responsible for their social-media doing this without anyone important knowing. In a similar instance, I noticed a project retweeting some antifa articles, and when I emailed the head guy about it, he seemed genuinely apologetic and cleaned it up.


 No.1005043

File (hide): 9fcb2ba702858e0⋯.png (1.7 MB, 1548x872, 387:218, wrong.png) (h) (u)

>>1004976

>Armband on the right arm

Can SNL get anything right?


 No.1005050>>1005145

>>1004762

Not 100% correct, she did program. It's just she programmed for an imaginary machine she herself came up with. To this day nobody actually built a working copy of the Analytical Engine to test her "programs".


 No.1005145

>>1005050

Why don't you take a gander at the article here >>1004786, and read it all, because you clearly don't know what you're talking about.


 No.1005740

<wow the custom allocators thing Zig has looks promising...

<I wonder how that idea might develop in the future?

https://www.adacore.com/gems/gem-77

ohhh


 No.1011885>>1011981

Having trouble getting into Ada. There are so many niggling little details about the syntax. Very confusing. Does anyone have a cheat sheet on 2012 syntax I could use?


 No.1011981>>1012707

>>1011885

I started learning Ada from "Introduction to Ada Programming" and then "Programming in Ada 2012" by Barnes. I made a few mistakes with parameter declarations (putting a , instead of a ;) and with type declarations (do I need "new"? etc.) but overall I haven't had much trouble with syntax. And especially not with the 2012 syntax, isn't it just "with", replacing 2005 pragmas?


 No.1012707

>>1011981

Do you have a pdf by any chance?


 No.1017940

Some reasons to learn Ada are the type system, the tasks, and the block structure. Ada has Algol-style block structure, not only for subprograms like Pascal, but for everything in the language, including packages, generics, tasks, and types. Each recursive call to Nested creates a new type T1 with its own instance of the Test procedure which captures a separate value of N. A lot of languages have some kind of block structure, but most of them don't take it as far as Ada does. The entire design of Ada and its safety mechanism is based on block structure and nesting levels.

with Ada.Text_IO;
use Ada.Text_IO;
procedure Classes is
package P is
type T is tagged null record;
procedure Test (Name : String; X : T);
end P;
package body P is
procedure Test (Name : String; X : T) is begin
Put_Line(Name & " is a T.");
end Test;
end P;
use P;
procedure Nested(N : Positive; X, Y : T'Class) is
type T1 is new T with null record;
overriding procedure Test (Name : String; X : T1) is
begin
Put_Line(Name & " is a T1 with N =" & Positive'Image(N) & ".");
end Test;
Z : T1;
begin
Test("X", X);
Test("Y", Y);
Test("Z", Z);
Put_Line("");
if N < 4 then Nested(N + 1, Y, Z); end if;
end Nested;
X : T;
begin
Nested(1, X, X);
end Classes;


 No.1017951>>1017952 >>1017957 >>1017999

Does anyone know a GC-less language where I can easily terminate threads that are waiting on blocking I/O (i.e. getline)? I was bitten by this in my C program and the only way to do it (pthread_kill then watch for EINTR and do your thing) is just vomit inducing.


 No.1017952

>>1017951

This stuff is so dirty that I'm seriously considering doing a TCL extension to libflac and libao instead of going further.

To be more precise, the problem is that I don't want blocking I/O (so you get an easy thread sleep) but I want a cancellation point.


 No.1017957

>>1017951

You could use select, implementing your own readline.


 No.1017999>>1018016

>>1017951

Ada has a much easier way to do this. A few modifications to the example would do what you want and it doesn't even need explicit threads.

http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-9-7-4.html

with Ada.Text_IO;
use Ada.Text_IO;
procedure Input_Test is
begin
select
delay 5.0;
Put_Line("No input detected!");
then abort
declare
S : String := Get_Line;
begin
Put_Line("Received string from user: " & S);
end;
end select;
end Input_Test;


 No.1018016>>1018022 >>1018023

>>1017999

Ada didn't invent nonblocking I/O and polling. That just means a single fcntl in my code. It's just that I want my cake and eat it (blocking I/O with the low CPU usage due to sleeping but still interruptible).


 No.1018022

>>1018016

pipe + select


 No.1018023

>>1018016

There is no non-blocking I/O or polling there. Get_Line is blocking I/O and on GNAT on Linux a signal aborts the code if it does not complete in time.

http://www.iuma.ulpgc.es/users/jmiranda/gnat-rts/node42.htm#SECTION001223000000000000000

>The one-thread model can be implemented using a signal and longjmp(). The trigger (entry call or delay) is pending on the thread while the abortable part is executed. If the abortable part completes first, the pending trigger is removed. If the trigger completes, an abortion signal is sent to the thread. The signal handler for the abortion signal then transfers control out of the abortable part into the triggered statements [GMB93, section 4.3]. Due to the disadvantages of the two-threaded model, GNAT implements the one-thread model. The non-local jump is performed by raising the internal exception in a signal handler. The propagation of this exception aborts one or more levels of abortable parts [GB94a, section 4.3].




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
28 replies | 1 images | Page ?
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / animu / doomer / fa / hentai / sl / sw / tahlia / wmafsex ][ watchlist ]