|
So in other words, implementation aspects become before abstraction? No sorry, never
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Since I left C/C++, I have never accessed an array via its address. Actually, I never did before I started using C either (but using Pascal, CHILL and propritary Pascal-like languages ... not to talk of APL!). C/C++ is the only language where I ever was close to consider the memory address of an array.
|
|
|
|
|
In C (and C++) the name of an array is - by definition - a pointer to the first element. Sometimes you don't realise what you are using, even with older languages!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
In C/C++, you cannnot do much decent programming if you are not aware of the array name as a pointer.
E.g. in Pascal, if you declare an array summerMonths: array[may..agust] of travelPlans; then you wouldn't care if 'summerMonths' is the address of element 'may' and actual indexes reduced by four before multiplied by the element size to get the element offset, or 'summerMonths' is the element of the (non-existing) 'january' element so that actual indexes may be directly multiplied by the element size to get the element offset. I believe that the Pascal standard says nothing about the implementation, and the compiler could do it either way. At least in the "original" Pascal that wasn't made for linking with modules in other languages. Maybe some external interface specification defines which address (of a non-existing elment 0 or of the first existing element) is transferred, to make the C programmers comfortable
None of that affects the Pascal code, though. You address summerMonth[july] as one of four travelPlans objects, without knowing what its address is and how it was calculated. Why would you care? In C/C++ you more or less have to care.
When using C for writing machine code, e.g bottom layer drivers, where the task by definition relates to physical addresses, controlling the exact binary code emitted by the compiler, you of course have to know. Pascal wasn't meant for those kind of tasks. My guess is that well above 99% of all C/C++ code written is not at that low level either, and actual physical addresses are not relevant. Yet, because of that fraction of a percent, all C/C++ programmers must be aware of the array as a pointer, indexing as a kind of pointer arithmetic etc.
If I work at that bottom level, interfacing directly to harware, I appreciate C. For higher levels, user applications in particular, I prefer languages that does not give me the freedom of C, and that relieves me from knowing which addresses are generated by the compiler.
|
|
|
|
|
Let's play "spot the developer who's never had to use pointers"...
|
|
|
|
|
Java developers know this. They have to, because it works differently enough that you have to care. Also it means that something like an image is often presented as a 1D array (for example bitmap.getPixels dumps the pixels in an int[] that you supply) and you have to do the index conversion yourself.
|
|
|
|
|
But can't you implement your own two (or more) -dimensional array class? Using a one-dimensional array as the backing store?
Profit.
modified 18-Feb-20 14:43pm.
|
|
|
|
|
Yup, and I dare say there are array and record class libraries that you can download and import, with built-in iterators for the java.util.Arrays functions, to save a bit of work if you have to do a bunch of them of different sizes and types.
If not, it'd be a nice hobby project for someone.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Yeah of course . But why didn't the Java folks opt for the standard model?
|
|
|
|
|
Maybe because they knew of other languages than C/C++
On the serious side: Newly educated Masters of today know "nothing" about langugages that are not of "the C class". If you show them something like APL, they look upon it like something from a fantasy world, cannot fathom how you can solve a problem in such a language.
Or a little closer to the C class: If you show them that in Pascal, you need not enclose conditions in parentheses, you can test "if x > 5" like we would write it in ordinary prose text; they as surprised how you can know that it is a condition when it is not parenthesized. "The standard model" uses parentheses.
"The standard model" prescibes that array indexes run from zero, and are integers. You show them a Pascal array summerMonths: array[may..august], and they worry about element zero of the array, where is that in all of this.
"The standard model" says that characters and enums "really" are integers, noting else. So a language that doesn't let you divide 'B' by 2 to get an exclamation mark, or multiply february with 3 to get april, breaks with the standard model.
Show them CHILL where you need not pre-announce that there is an exception handler. But "the standard model" requires a "try" and enclosing the block in braces! How can you know the scope of the exception handler? The 'block' to which it is attached? But isn't that what the braces do, delimit the block, so how can you avoid the braces?
And so on. 'The standard model', also known as 'C', is what young programmers know today. They believe that when they know both K&R C, C++20, Pyton and Javascript, then they know all the languages of the world. Or at least all the valuable ones. The rest is only for cases where you need one more credit point for this quarter and must choose between 101 Introduction to Japanese or 101 Introduction to SNOBOL. You don't need either, you will never be using either. The Real Thing is the C class languages.
|
|
|
|
|
I've been always uncomfortable without the braces.
Python says:
try:
print(x)
except:
print("An exception occurred")
Just imagine a multi-level/nested try-catch blocks.
|
|
|
|
|
After working for a while with CHILL, I never understood this "try" fixation - it is just a wart caused by exception handling being a cludge added to C long after its "design".
In CHILL, any block (and contrary to C: A simple statement is a block) can have an exception handler; just add it before the terminating semicolon, whether the block is a simple assignment, a loop, a function body, or even an entire module. To satisfy "C language class" oriented guys, you could say that an ON clause at the end of the block "implies a try at the start of the block" - but there is never any need for an explicit "try" (so it doesn't exist in the language).
Furthermore, to reduce the red tape of exception handling, "ON" is like a C "switch": The exception codes are like labels, followed by a block for handling that exception (but as a simple statement is also a block, there is no red tape for simple, one-statement handing), with an ELSE option.
So to me, C style exception handling is kludgy and inflexible.
|
|
|
|
|
There is no "standard model".
|
|
|
|
|
|
When you come home from work, or when your significant other comes home, how good are you, are they, at leaving all the work trials and tribulations at the doorstep and simply "being present" with your SO? I realize that "being present" means occasionally hearing about work, but how consuming is it? Do you agree on, say, 15 minutes of venting time? Or does work issues consume the entire evening, or not at all?
|
|
|
|
|
I might check my work email or otherwise login to my work computer from home outside of working hours once a month. Most of that has to do with deployments; I'm doing educational software and we can't deploy until kids are done on the system for the day. That's generally between 4:30 and 5 my time (stupid timezones to my west ); but occasionally is later and logging in around 7 or 10 for 5 minutes to kick off a deploy and make sure it goes as planned is less annoying than staying late on days I got in around 8 instead of 8:20.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
It's an unequal balance but I'm usually okay with it. My beloved is an elementary school teacher so I need to listen to her frustrations with people and policies (Sometimes makes me want to take a bat and "explain" things to those who are causing her stress) and her own imposter syndrome worries.
She doesn't understand nor cares about what I do so technical challenges are met with an "I don't care" but if there are interpersonal problems she does listen.
I've come to accept it after over 30 years of marriage.
|
|
|
|
|
Nowadays I'm pretty good with that - we do talk about things at work occasionally, but the pressure of the work does not came home with me (or her)...
It took some years to learn that however, but I was lucky and finished 'school' before wedding...
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
I believe it depends on frequency; if you or your SO do it occasionally after having a really bad day it's one thing but if done constantly it's another.
Monday starts Diarrhea awareness week, runs until Friday!
JaxCoder.com
|
|
|
|
|
Agree
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Mike Hankey wrote: but if done constantly it's another.
Yes, exactly!
|
|
|
|
|
I often use the time it takes to commute home (subway/walking, so no car driving stress) to clear my mind of work.
When I get home, I play on the computer a little bit, do chores (food, cleaning ... )
It happens a couple times a year that I think about work at home and need to log in remotely do check something.
I don't have work emails on my phone but I have Teams installed, I look at the messages, but rarely respond. (when on vacation, I uninstall the app.)
When I was in a relationship, GF and I talked/ranted/vented about our work while preparing dinner; that was the extent of it.
I'd rather be phishing!
|
|
|
|
|
I'm having a functional employer, so I mostly have to listen.
|
|
|
|
|
Like flipping a switch.
I'm either working, or I'm not, so If I'm not meant to be working, it just stops.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Mark_Wallace wrote: I'm either working, or I'm not, so If I'm not meant to be working, it just stops.
Nice! I tend to be that way -- pretty much no matter how work goes, it doesn't require venting when I get home. Though if something cool happens I do like to share the positive things. I guess I just want home to be a positive experience, the negative crap can be left outside in the cold.
|
|
|
|
|