Live data from Hacker News

Giving Ada a Chance

ajxs.me

191–200 of 261 posts

Re: Giving Ada a Chance

#191
post #188

Earlier quoted context omitted.

No, my complaint is, as said, hat for-loops in Python do not create a block scope as they do in about any other language. The closure is simply a way to illustrate that but there are many other problems such as this one: x = something # some lines of code for x in iterator: # something # try to use x again here # x has been re-assigned by the loop In about any other language, the loop would create it's own scope, and…

So your first example was clearly a bad example. This was a better example. But even so, this is a lousy example since x is already defined at the top. So the for loop could theoretically use the defined x already. I think what you're looking for is something akin to the following in C: int x = 5; for (int x=0; x But I would argue that this is terrible C code since the inner x shadows the outer scope leading to confu…

No, the first example illustrates the fundamental problem that all iterations of the loop share the same scope rather than a new one each.

In your example, the variable `x` is also shared with all iterations of the loop. Rather, it is more so as so in C, like syntax what is the common approach:

  while(1) {
    int x = next(iterator)
    if(STOPITER) { break }
    /* code that uses x */
  }
Every iteration of the loop receives a brand new `x` rather than re-assigning the old `x`, this problem is illustrated by creating a closure that closes over the `x`, for which the expected behavior is not that the `x` is then assigned to another value on the next iteration of the loop.

The only way to achieve this in Python is to create an ad-hoc function which is passed `x` as a formal parameter, for every new function call in Python does create a new scope rather than simply re-assigning to the last one.

Re: Giving Ada a Chance

#192
post #177

Earlier quoted context omitted.

> People found it frustrating how much work it'd take to get their programs to even compile Makes sense if they're students working on small projects. Ada is explicitly designed to make large programs readable, and willingly trades off on writeability when the two come into conflict. It isn't going to shine if you're writing small 'single shot' applications, that isn't what Ada is for. (Ada also commits to using many…

I really think a semantic facelift would do wonders for ADA, and shouldn't make much of a difference for readability. I know a lot of people are turned off by this.

> I really think a semantic facelift would

I think you mean a syntactic facelift, without changing semantics. You mean making the syntax look more like TypeScript, Kotlin, or something, right?

Re: Giving Ada a Chance

#193
post #186

Earlier quoted context omitted.

It's not merely that. That for-loops work by assignment rather than creating a new scope, or that if-conditions do not create a new scope for their arms is most unusual. Not only does it not teach programmers to properly reason about scope, but it results into subtle bugs that are easy to miss. Consider the following: list = [] for x in iterator: list.append(lambda y: some_code_that_closes_over(x)) This almost certai…

Not a technical counter argument, but surely this is a trifle in the grander scheme of things? The hard things about programming, such as modularization at a high level and verification of user input, are orders of magnitude more important than quirks like these? (And if we broaden our view to include more of software engineering in general, like solving the right problems and validating hypotheses with fast feedback…

But block scope is all about modularization and ensuring that parts of the program that need not interact do not interact.

Python code seems to either be written from a mentality of not at all caring about variable lifetime and making it far longer than it should be, or programmers that do care, and uses classes and functions as makeshift tools to attempt to limit the lifetime of variables to make up for the lack of block scope of the language.

Re: Giving Ada a Chance

#194
post #40

Earlier quoted context omitted.

Lack of a free compiler with permit to use commercially (gnu linker exception), was a problem during a significant phase of the language.

GNAT debuted in 1995, 25 years ago. Some 12 years after the 1983 standard.

Yes, but Gnat did not have a gpl linker exception, so for the free version your compiled file would also be gpld. https://groups.google.com/g/comp.lang.ada/c/cPsKwgiuO-w Only when gnat fsf was released end of 2001 this was not a problem anymore, except for the confusion and perceived uncertainty (also using it on windows means mingw, not everybody likes that) For the fsf release: https://people.debian.org/~lbrenta/debian-ada-policy.html#Hi...

You can say this is still 20 years ago, but you have to count from the other side. If you have two solutions to a problem the earlier one wins more (except if the later ones is order of magnitude better on a metric that counts). Yes, rust is also late to the party, but support of Mozilla is a big advantage.

Re: Giving Ada a Chance

#195
post #39

> I can’t help but think that complicated programming paradigms would seem more intuitive to beginners if taught through Ada instead of C and its derivative languages, as is common in computer science and engineering faculties worldwide. At my university, the first courses you took in CS used Ada. I think it was a really good choice but I was in the minority I guess because after my year they switched to either using…

I help beginner python students. Python might be a nice easy scripting language for bashing out NUMPY scripts, but I'm beginning to suspect it is terrible for teaching. The "what type is this variable, and will this function automatically convert it for me" game is not very fun at all for beginners.

Beginners to programming don't agonize over variable types, they don't have the mental model of statically typed language in their head.

Re: Giving Ada a Chance

#196
post #190
post #156

Earlier quoted context omitted.

Regarding `repr(packed)`: Thank you for posting this. I really like Rust's official documentation on the subject. I stand corrected regarding Rust's support of structure packing. The following statement is a little troubling however: "As of Rust 2018, this still can cause undefined behavior." This greatly affects Rust's suitability for bare-metal programming, where you very often require control over a structure's la…

> "As of Rust 2018, this still can cause undefined behavior." This is referring to the fact that you have to be careful when accessing the fields of a packed struct that everything is aligned correctly. Normally anything where "you have to be careful" in order to uphold memory safety requires use of the `unsafe` keyword, but due to an oversight Rust doesn't currently require it in this instance. So, in typical Rust f…

That is a mistake. Architectures are being updated to support unaligned access. MIPS, PowerPC, and ARM have all been updated. The machines that can't handle unaligned access are going the way of machines with sign-magnitude integers, trap representations, 9-bit bytes, base-16 floating-point, and so many other terrible things that must have seemed like good ideas at the time.

Re: Giving Ada a Chance

#197

Earlier quoted context omitted.

A lot of Universities and company's were bribed by Sun to start using Java.

Do you have any evidence for this? As an early university adopter, I sure would have liked to know how to get in on that sweet Java bribe money.

In universities there were steep educational discounts of Sun hardware. At the time administering labs full of PCs was a nightmare, and a lot of departments were culturally predisposed towards Unix anyway, so a natural result in many places was Sun workstations or Sun Ray terminals where Java was well supported and was portable enough to also run on the student personal PC.

This is a well known pattern in services now too, lots of platforms are buying user market share by offering free/cheap service for college students and reaping the revenue when the students move on / generate invites.

I wouldn't call this bribes but you can make an argument that it's buying mindshare that you wouldn't get on your own merits.

Re: Giving Ada a Chance

#198
post #182

Earlier quoted context omitted.

Javascript is too weird to be a teaching language. Lexical scoping, invisible and sometimes unintuitive conversion rules, challenging runtime environments, and asynchronous code are important concepts but I wouldn't put them into an intro to programming class. IMO the ideal programming track would be as follows: Intro to programming track: * Assembly --> to understand the basics of how computers work and learn simple…

I really don't think you should use C as a teaching language. There are way too many pitfalls, and using libraries is quite cumbersome.

I wouldn't program production code in C if I could avoid it. But sometimes you can't avoid it, and I wouldn't program production code in Pascal, either.

Re: Giving Ada a Chance

#199
No discussion of Ada is complete without referencing the cost of commercial development licenses. They're expensive. Very expensive.

Any enthusiasm for this language is inevitably quashed upon encountering the $$,$$$ per-seat price of the compilers for the absolute bare-bones x86 version. It's more if you want to target non x86. I pester AdaCore for info every few years and while they've dropped a little bit, they're still out of reach for companies not in the Fortune 500. I'd love to use SPARK, but I don't see that happening any time soon.

Re: Giving Ada a Chance

#200
post #192
post #177

Earlier quoted context omitted.

I really think a semantic facelift would do wonders for ADA, and shouldn't make much of a difference for readability. I know a lot of people are turned off by this.

> I really think a semantic facelift would I think you mean a syntactic facelift, without changing semantics. You mean making the syntax look more like TypeScript, Kotlin, or something, right?

Yes! Thanks for the correction!
Post reply on HN