Can everybody code? - Page 1
Forum section: electronics / general

author: hamster_nz
author_rank: Super Contributor
timestamp: June 15, 2016, 11:41:02 pm
content: I've been watching the whole "teach everybody to code" movement, and even helping out at a CodeClub. But now having second thoughts about the whole 'coding is the new math' mindset . Can everybody code? I don't think so.Why do I say that? I am useless at Art, my drawing make XKCD look like masterpieces of art. Doing art class hasn't helped me at all.I think 'innate coding ability' must be a bell curve, with those who are "wired to code" at one end, and those who have no talent whatsoever at the other.I doubt that the "everybody must code!" movement will actually produce a large number of highly skilled technologists - but it might help a few find coding as their calling, but isn't going to make a golden age of computer uber-geeks. A bit like music, where most of us can hum a tune, but doing music classes doesn't turn many of them into musicians.What I think we should be doing is finding those who have innate ability, and upskill them up as fast as possible. six months playing with Scratch for an hour a week isn't going to cut it. Some sort of focused accelerator program...

author: Yansi
author_rank: Super Contributor
timestamp: June 16, 2016, 12:00:43 am
content: It will undoubtedly create some more arduino slaptogethers.

author: Galenbo
author_rank: Super Contributor
timestamp: June 16, 2016, 12:26:40 am
content: Quote from: hamster_nz on June 15, 2016, 11:41:02 pmIf you shut down TV and take away the food till they code "hello world", every normal built person can code.But it depends on the efforts that has to be put in them, and what can be expected to come out.On the other side,every bachelor/masters degreeshould contain a decent real-programming course, with an individual evaluation.Totally unacceptable that a person with the potential ability to rise in an organisation can't program. Those are the biggest obstructions in organisation computerisation and a web-awareness course sponsored by Apple/Google isn't gonna do it.

author: 3db
author_rank: Frequent Contributor
timestamp: June 16, 2016, 12:32:15 am
content: Quote from: Yansi on June 16, 2016, 12:00:43 amWell that would be a very good thing.It must promote some understanding of code.Better than just being glued to a phone or tablet on arsebook or twatter.

author: xrunner
author_rank: Super Contributor
timestamp: June 16, 2016, 12:38:33 am
content: Quote from: hamster_nz on June 15, 2016, 11:41:02 pmI don't see why not, at least at some level. "Can everybody code?" that's kindof a loaded question, again at what level of complexity?QuoteAgain - what type of art? Anyone can do some sort of art, it's all a matter of what level and so on ...

author: John_ITIC
author_rank: Frequent Contributor
timestamp: June 16, 2016, 12:41:23 am
content: I think that your personality determines whether you would be a good programmer. You should be introverted, not interested in people so you don't mind spending 12 hours straight staring at the screen, reading books etc. Becoming good at this takes an incredible amount of time. The same character traits are shared by the best electrical engineers. Both Linus Torvalds and Steve Wozniak have these traits.When I went to college and studied EE and CS, my class mates ranges from the extremely introverted to the extremely extroverted. Once graduated, the extroverted didn't stay hands on in engineering for very long but rather chose different career path such as pre-sales or field applications engineering, where there's lots of talking and socializing but NOT much coding done.

author: StillTrying
author_rank: Super Contributor
timestamp: June 16, 2016, 12:41:58 am
content: It's OK, they've changed their minds now. The UK is training up 850,000 kids ready for their trip to the ISS.

author: rrinker
author_rank: Super Contributor
timestamp: June 16, 2016, 01:16:51 am
content: Can anyone code? I think not, just like not anyone can write a piano concerto (or even play a piano, for that matter), or create fine art.No, everyone on the planet is not exactly equal. Some are better at logical thinking. Some are better at artistic creativity. The real geniuses are both. Some people are better at science, some people are better at math, some people are better at language skills. It doesn't make any one group 'better' than another. It's not a bad thing if you aren't good at task a, but are at task b. Someone else who's good at task a may suck at task b. It's not elitism, racism, or any other ism to think that not everyone is good at everything.Teaching everyone the very basics is entirely possible, but for some people that's as far as they will ever go. Others will take to it like a duck to water and want more.

author: retrolefty
author_rank: Super Contributor
timestamp: June 16, 2016, 01:29:44 am
content: I think natural selection will continue to work.

author: Zad
author_rank: Super Contributor
timestamp: June 16, 2016, 01:52:07 am
content: Whatever happened to programming?Is it in the drawer with white towelling socks and shoulderpads?

author: linux-works
author_rank: Super Contributor
timestamp: June 16, 2016, 02:02:56 am
content: 'everyone should learn to code' is code, itself.it means 'we, as corporations, want an ever-increasing selection of cheap, warm bodies we can hire'.problem is, the bottom already dropped out of 'coding' and even higher levels of programming. its increasingly harder to get good paying jobs (by western standards) even by the big giants in silicon valley.learning to code for fun and doing things for yourself is great. if you are learning it for future work, well, that ship has already sailed. I would not advise it for future employment. if anything, it bottomed-out even more than 10 years ago.when the cries for 'we need more coders' come from liars such as h1b abusers, you know its code-words and not sincerity.

author: Skimask
author_rank: Super Contributor
timestamp: June 16, 2016, 02:04:46 am
content: ^^^^^^^^^^^^That.Or this...depending...

author: hamster_nz
author_rank: Super Contributor
timestamp: June 16, 2016, 02:22:42 am
content: Quote from: linux-works on June 16, 2016, 02:02:56 amWhen anything becomes an 'average' skill, it also attracts an average salary... what programmers really should want is less programmers.Is their any inherent reason why a programmer should get paid more than any other run-of-the-mill trade (e.g. mechanic)? Maybe not.In the late 1900s programmers were specialist people who put other people out of work increased productivity and profitability - remember the typing pool, secretaries, floors filled with clerical staff opening envelopes, bank tellers updating manual accounts? Now programmers are increasingly spending time producing tiny improvements, and a new generation are making new products to fritter time away with while presenting eyeballs with advertisements.When everything seems to require a three-year full time course post schooling (e.g. Travel and Tourism, Nursing, Preschool teachers, Building Trades...), can generic programmers really demand/expect a premium?

author: linux-works
author_rank: Super Contributor
timestamp: June 16, 2016, 02:29:16 am
content: we certainly need more of society to be able to THINK. but that is not really emphasized, at least in the US. school is about conformity, forcing you to 'fit in' and some cultures take this to extremes and model their society on that.governments do not want thinkers in their population, not really. they want you to be kept ignorant of the bigger world so that their truth is all you believe. almost universally, this is true.so its odd to hear cries of 'we need all kids to learn programming'. in effect, you will be creating more thinkers and those thinkers may unseat you, collectively, later on. governments do not like that.quite a mixed thing they are asking for, in fact.but really, its just about creating a concentrated labor force to pick from. we know what's going on, here, don't we.

author: Galenbo
author_rank: Super Contributor
timestamp: June 16, 2016, 02:40:01 am
content: Quote from: hamster_nz on June 16, 2016, 02:22:42 amI never needed less programmers.Especially not the times I was in a "multidisciplinary" team (project owner, marketeer, mechanical boss, production planner, QA assistant, maintenance guy, Motion Drive programmer and me as HMI/safety/PLC.)We never get past the explanation that programming is putting some text into a machine. Those meetings were very constructive. Not.The decisions the project owner/leader mader were all so very inspiring. Not.

author: Brumby
author_rank: Unknown
timestamp: June 16, 2016, 02:51:15 am
content: Quote from: hamster_nz on June 15, 2016, 11:41:02 pm.... and just how do you intend to identify them?The broad brush approach you referred to is how.Quote from: Galenbo on June 16, 2016, 12:26:40 amI don't disagree - but the definition of "decent real-programming" is key. I do not believe a degree course in many disciplines requires programming skills - but it would be useful if the candidate was aware of the capabilities available. Even in something like Civil Engineering, aside from perhaps putting together a macro, coding skills are essentially irrelevant. However, the ability to USE software is imperative.QuoteI could not disagree with you more.The ability of an organisation to adopt and adapt has very little, if not nothing, to do with the programming skill of management - but EVERYTHING to do with their ability to appreciate the capabilities and benefits of technology ... not just computerisation.In fact, I will take the opposite position and say that if you have programming expertise within management, you may actually find organisational advancement is impeded - because that expertise will bedated, Since, by definition, management will not be driven by their job to keep their skill sets current, the risk is that their judgement and direction on computerisation will be driven by ever aging concepts. Talk about built-in obsolescence.Society needs diversity. It needs a wide range of people capable of a specific range of skills. Yes we need programmers, but we also need doctors and plumbers. We need firefighters and pilots and we need organisations that support them. Programming skills aren't necessary - we just need people who can appreciate the part that technology can play.JMHO.

author: Brumby
author_rank: Unknown
timestamp: June 16, 2016, 03:01:57 am
content: Quote from: Galenbo on June 16, 2016, 02:40:01 amTwo things here....First, with such a multi-disciplined set of responsibilities within a very few team members, the line between management and "coal face" workers is blurred - potentially invisible. Broad technical abilities become necessary.Secondly, the project owner/leader obviously did not have the appropriate level of technological appreciation to drive the project effectively. The fact "We never get past the explanation that programming is putting some text into a machine" does not, in itself, worry me - unless it is a fundamental and critical component where coding content is key. Then you have a problem.

author: linux-works
author_rank: Super Contributor
timestamp: June 16, 2016, 03:34:35 am
content: http://www.oldielyrics.com/lyrics/donald_fagen/i_g_y.htmlA just machine to make big decisionsProgrammed by fellows with compassion and visionWe'll be clean when their work is doneWe'll be eternally free yes and eternally youngWhat a beautiful world this will beWhat a glorious time to be free1950's USA vision of today vs, actual today. (and still no flying cars, dammit)

author: vk6zgo
author_rank: Super Contributor
timestamp: June 16, 2016, 03:56:26 am
content: The question sounds like something out of the 1970s/early '80s.Back then,people who were interested in computers spent the time learning how to programme them,first in machine language,then in ever more sophisticated languages.Now,most of the things they made computers do are either just "part of Windows"/Linux,etc,or are available as applications.How often is a person,other than someone actually working in IT,or,perhaps an EE,or a few others,likely to need "to code"?In my opinion,the IT component of Electronics courses has assumed too great an importance,until you find people who have passed an "Advanced Certificate" or a "Diploma" of Electronics on the basis of their IT skills,but who have little or no knowledge of basic Electrical Theory.Whether this is also the case in EE courses,I have no direct knowledge,but some of the questions that present on this & other forums,leads me to think so.

author: System Error Message
author_rank: Frequent Contributor
timestamp: June 16, 2016, 04:13:02 am
content: I consider both coding,mechanics and electronics as a modern day survival skill, cant get by without them. Something breaks and you cant repair you're stuck with either buying a new one or paying someone lots to fix it. Programming is pretty much needed for you to get things to do things. Besides when all companies plan their product to break down regularly you just dont want other people controlling your life and what you can or cant do.In the past hunting was a survival skill. Today even finance, math, science are survival skills, just too many scammers.In my opinion everyone can code. If i can just grab an enterprise router and figure it out, pretty sure others can.

author: rollatorwieltje
author_rank: Unknown
timestamp: June 16, 2016, 08:03:27 am
content: What do you consider coding? Back when I was at school we had 'computer science' classes, covering stuff like MS Office and a tiny bit of Visual Basic.I don't think it's useful for people in general to know how to write a standalone piece of software, but knowing that existing tools can be automated with a few lines of code is definitely useful. Pretty much everybody has to do stuff in Excel once in a while. You really don't have to be a great programmer at all, my guess is the vast majority of companies operate on several bodged together Excel sheets. Maybe it's a liability, but meh, somehow they seem to survive just fine.When you go into R&D/Engineering though... For the love of all that is holy, at least learn something like Matlab or similar. Maybe even Arduino, or try to get experience with a PLC. It makes your life so much easier when you can automate your own test setups. Those programs are typically very simple, maybe a dozen lines of PLC code, yet the amount of mechanical engineers I've seen staring at a screen and have absolutely no clue how to turn a PLC output on and off... Also afterwards, after your tests have run and you end up with a bunch of CSV files with data, now what? You have to filter out the useful data, are you going to parse a 100k line CSV file by hand? I've seen it happen...

author: SL4P
author_rank: Super Contributor
timestamp: June 16, 2016, 08:17:19 am
content: Lazinessis not compatible with coding/development.Hence platforms like Arduino(as an example only - I use them), have simplified the hardware aspect for rapid ignition of anidea... but has no measurable effect on the ability of a user tothinkabout the problem, or to create a viable solution.Anyonecan jump in and 'code' asimplesequential process, but to do much more - requires a bit of analysis and understanding of the problem and it's elements... time, power, logic, expectations, environment, functional relationships etcNewbies - the best thing you can do is find an experienced local 'buddy' to work with you - over the shoulder. Trying to develop skills purely from video tutorials will only get you about 30% of the way.

author: Jeroen3
author_rank: Super Contributor
timestamp: June 16, 2016, 10:06:16 am
content: You need a high level of self-discipline.If you're not disciplined you can code. But you'll end up with a house of cards that will collapse upon you.You will have to collapse it a few times before you learn to code properly.An example:- Ask code class students after C-syntax class how they would build asimplestate machine with 20 states.They will use a switch-case which creates bug-hell.Instead, you can use a lookup table with function pointers so you can keep the states short, separate and readable.- Ask code class to build a circular buffer.Only a few will succeed. Probably without any use of pointers.Then ask them you want to use TWO or maybe more circular buffers in your code.They'll be coping and renaming all the functions.

author: Rerouter
author_rank: Super Contributor
timestamp: June 16, 2016, 10:23:30 am
content: Jeroen3, could you give an example of that lookup table state machine?My thoughts would be using a switch case for entry, (based on the last state), then run the function required, set the next state depending on the result, and loop back to the switch,

author: bitslice
author_rank: Frequent Contributor
timestamp: June 16, 2016, 10:31:51 am
content: Anyone can learn enough French to order coffee and declare that their postillion has been struck by lightning.Doesn't mean they can write poetry.Does Windows 10 really require 80 million lines of code, or is part of that simply workarounds that have been passed down over the years and nobody wants to break it.

author: Kjelt
author_rank: Super Contributor
timestamp: June 16, 2016, 10:52:13 am
content: Anyone can learn anything and become good at it (within physical restrictions that is) if they are motivated and put in 10000 hours.Recent studies showed that IQ is mostly not genetically based but what surroundings (phenotype) a child grows up in.The problem is motivation if you do not have that for something you will never ever get it.Then there are people with certain talents that are good in something very quickly and sure they have a head start, still anyone if they put in the time and practice can learn to do something (within physical restrictions that is).

author: hamster_nz
author_rank: Super Contributor
timestamp: June 16, 2016, 10:59:03 am
content: Quote from: Jeroen3 on June 16, 2016, 10:06:16 amI would use an enum for the states, and then use a case statement, maybe to call functions for complex actions, rather than indexing a table of functions.That way you can easily add a state which logically fits between two existing states, without having to carefully inspect all the called functions...

author: tom66
author_rank: Super Contributor
timestamp: June 16, 2016, 11:01:44 am
content: I disagree with the idea that everyone can learn to program. Past a certain age, it appears that the ability to think in a specifically logical way that is required to construct a complex program is lost. I'm sure anyone can make an LED blink but do they really understand what they wrote intuitively? Or are they just following a tutorial or cut-n-paste?

author: Kjelt
author_rank: Super Contributor
timestamp: June 16, 2016, 11:40:06 am
content: Quote from: tom66 on June 16, 2016, 11:01:44 amSo what age are you talking about and do you know how many professors at universities that write new papers each and every year are older than 55 ?What coding requirements are you talking about? Normal software coding is pretty intuitive since it is a serial flow which is very much like human thinking.Now VHDL and the sorts that is tricky since everything happens at the same time, i can agree that this is another ballgame.

author: Jeroen3
author_rank: Super Contributor
timestamp: June 16, 2016, 11:42:40 am
content: Quote from: Rerouter on June 16, 2016, 10:23:30 amSure. It's a quick extract from a project. But it should show the theory.You can make it as fancy as you'd like. Enums, getters/setters of the xState variables, be creative but disciplined.Don't deviate from the concept of:nextstate state(prevstate);Have some empathy for the next maintainer!I've used this many times as solid base for projects. It's much better than a thousand lines of switch-case. Now you have a few files with state groups.Getting into HDL as a programmer is the hardest thing you can imagine. Like riding thebackwards bike.

author: SL4P
author_rank: Super Contributor
timestamp: June 16, 2016, 11:44:47 am
content: Quote from: Kjelt on June 16, 2016, 11:40:06 amI can see a lot of scope to disagree with almost every word in that response!Normal Software?Pretty intuitive?Serial flow?Like human thinking?- I'll let someone else start.

author: rrinker
author_rank: Super Contributor
timestamp: June 16, 2016, 01:02:08 pm
content: There's an ability to visualize the overall scope that is needed. You might get there eventually by following the serial path, but many times you will have to go back and redo something because that path led to a dead end.It's sort of like being able to look at a schematic and visualize the physical circuit, or a 2D CAD drawing and visualize the final product. Not everyone can do that, and not everyone who can do it can do it well.I'm not sure if they still do it, but when I went to university, a required first year class for ALL engineering students, regardless of specific discipline, was a course that involved programming and numerical methods. Some people can do it, others struggle. I ended up becoming a university paid tutor for the course in later years. Everyone, regardless of college, was also required to take Economics 1. As an engineering major, I had it on what was an 'off' semester for business majors, however a good portion of the class included business majors taking it for the second and even THIRD time because they previously failed. Makes you wonder.

author: macboy
author_rank: Super Contributor
timestamp: June 16, 2016, 04:13:46 pm
content: "Can Everybody Code?"Definitely not. In my experience writing embedded software for nearly two decades,half the people who are gainfully employed as coderscan't code worth a damn. Fortunately, after surviving many years of layoffs, I now work with a very talented bunch of real coders who also survived those years.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: June 17, 2016, 01:18:18 am
content: Lots of definitions of coding here. All the way from getting a light to blink on an Arduino through writing fast and efficient code for an embedded processor and on to writing operating systems for general purpose computers with tons of random peripherals and operating in a diverse network environment. There are tons of side branches.Damn few, if any, can do all the kinds of coding in the world. I know people who write thousands of lines of Matlab code a year who can't write a line of assembly, and visa versa. So in that sense, nobody can code. But I do think that everybody could code at some level. Talent and motivation are keys. Talent varies, but virtually everyone has enough to do simple coding. Motivation is trickier. What is the benefit to the average Joe to do ANY coding? Writing a macro to clean your mailbox, or to bomb everyone on Facebook with a silly meme are probably the kind of things that would interest the widest cross section of people, but they aren't important enough to put much effort into. So you are left with the people who have a personality trait that drives them to learn for the hell of it and the people who have a specific purpose that forces them to learn.I fall into the second category. I learned Fortran, Algol and some assembly in university as parts of required course work. Every other language I have learned since has been a necessary part of getting something else done I was interested in. In many cases I learned the absolute minimum required and was definitely not proficient. In other cases the language turned out to be a useful tool for other things and I became fairly proficient over time, or the thing I was doing required ongoing use of the language.So I would say teach everyone enough programming that they know that that kind of tool exists, and then let them carry it further as their interests or jobs require. That basic level that everyone should be exposed to probably can be covered in a few weeks at the most.

author: AntiProtonBoy
author_rank: Frequent Contributor
timestamp: June 17, 2016, 03:01:53 pm
content: Quote from: Jeroen3 on June 16, 2016, 10:06:16 amIf you do this under my watch, you will not pass code review. A switch statement is perfectly suited for the task, and more importantly, it's safer code.

author: m98
author_rank: Frequent Contributor
timestamp: June 17, 2016, 03:52:42 pm
content: Quote from: AntiProtonBoy on June 17, 2016, 03:01:53 pmCouldn't agree more. Just much cleaner then messing around with a lookup table and pointers and much more obvious without further explanations.As far as the question of the thread is concerned, no, not everyone can. I know a few who went to study informatics and couldn't implement simple if-statements or follow simple program logic or algorithms after two years. They just couldn't get anything, even after hours of explanation.It's just a very different way of thinking. Humans interact intelligence based, when you ask someone to open the window, he just does that. But when you ask a robot, you'll have to tell him how to listen to sound waves, interpret human language, where the window is, how to get there, check if there isn't something in the way, how to grab a door handle, what direction to twist the handle, what direction the window opens, how to pull it open, how to let go of the grip, how to control the actors to perform all those moves, how to process the sensor information, how to pass around the information, etc...When you really can't get into that scheme of thinking, then it's simply impossible to learn to program. You must be able to analyze the problem in tiny sequential steps while still keeping the big picture in mind.

author: bitslice
author_rank: Frequent Contributor
timestamp: June 18, 2016, 02:18:06 pm
content: Quote from: CatalinaWOW on June 17, 2016, 01:18:18 amFor me that's the pivot for education, I've repeatedly found it more useful to know where information (a solution) can be located than to actually know it in the first place.

author: Rerouter
author_rank: Super Contributor
timestamp: June 18, 2016, 03:13:25 pm
content: Now as i am well outside of high school (6 years), I have to wonder if the average child knows how a library index works, that was what actually taught me how to properly attack keyword searches, (I'm getting no results for X, but maybe there is something related to X i can use), This isn't so far removed from the mindset for software, you cannot work out a solution using the common methods, so what other approaches are there? or what task might be similar enough to clone,And i very much agree with bitslice, knowing where to find the information, and how to understand it are far more valuable than being able to recite it from memory in 6 months time,

author: Galenbo
author_rank: Super Contributor
timestamp: June 18, 2016, 04:25:04 pm
content: Quote from: AntiProtonBoy on June 17, 2016, 03:01:53 pmthe switch case thing in ansi-C is the most unreadable and biggest pitfall I ever seen.I even prefer a page full of separate if statements.

author: German_EE
author_rank: Super Contributor
timestamp: June 18, 2016, 04:45:23 pm
content: Can everybody code? No, and I am a prime example. Back when I did my Electrical Engineering degree I could fault find an IBM AT to component level and then get it working again, yet if you asked me to write something in Fortran, or Pascal, or C++ I would struggle badly. I'm an Engineer, I build and repair physical things, and although I understand the basics of software I'm not able to code.Now time for a modern example. Four years ago I figured out a way to present the direction of an antenna on the screen of a PC with a map in the background. I built four copies of the hardware and they all worked first time but then I handed them over to someone else who wrote the software then we had a finished product.We live in an age of specialists. One person builds the hardware, another writes the software, a third person creates the advertising copy, a fourth person sets up the web page and a fifth person actually sells the product. Not all of us can be principle violinist but together the orchestra produces the music.

author: Galenbo
author_rank: Super Contributor
timestamp: June 19, 2016, 08:38:58 am
content: Quote from: German_EE on June 18, 2016, 04:45:23 pmThe sixt person is the cousin of the company owner, becomes project leader and makes person 1,2 and 4 run away.Person 7 is engaged as HR specialist, to engage every other year some new software fixers, because customers want "updates and stuff".

author: AntiProtonBoy
author_rank: Frequent Contributor
timestamp: June 19, 2016, 08:46:27 am
content: Quote from: Galenbo on June 18, 2016, 04:25:04 pmCare to elaborate? A switch statement makes the connection between the state and the callable object (that handles the state) clear as night and day.Consider an enumeration of states:Code:enum CharacterState{CharacterDefend = 0,CharacterAttack,CharacterEat = 10,CharacterSleep,CharacterWalk};These can be easily tabulated like so, with a toy example:Code:void MutateCharacterState(Character* character){switch (character->state){case CharacterDefend : PerformDefend(character); break;case CharacterAttack : PerformAttack(character); break;case CharacterEat : PerformEat(character); break;case CharacterSleep : PerformSleep(character); break;case CharacterWalk : PerformWalk(character); break;default: /* error handling code here */ break;}}With tables you generally have to do the following:* Perform static initialisation on the lookup tables. That alone is error prone, because static initialisation order is undefined across many translation units. But you can wrap that into a global getter function.* You already assigning the functions to a table as a list, in the same manner as you list the case statements, so you might was well use a switch.* You must maintain a strict numeric sequence of your enumerated types that is used to index the table.* You must perform boundary checks to make sure you don't index outside the table.Enumerations used in conjunction with switch statements is safer, cleaner, has a default handler for unknown states, and it's maintainable. It doesn't need strict sequence of values for the states. It doesn't do anything fancy other than linking states with the functions that performs the action at compile time. Btw, if you are shoehorning a bunch of state logic inside the a case block, you are doing it wrong. Contain states within functions.People like to perform heroic feats with tables and pointers, but those things are always a source of fuck ups, guaranteed.

author: Jeroen3
author_rank: Super Contributor
timestamp: June 19, 2016, 11:46:19 am
content: Quote from: AntiProtonBoy on June 19, 2016, 08:46:27 am* Do you have any examples? The behavior of the compiler and linker should not be undefined.* The end result might be equal, depending on the optimizations of the compiler. If not, it will perform states-1 branch compares for the last state in the switch. Instead of a call that is always of equal lenght.* I fail to see why using an enum with undefined values of an undefined size is better. It's looks better, that's true.* You also havedefaultdon't you?I should note that I'm an embedded programmer. Time and memory are limited, and I want deterministic behavior of my code. On state 0 and on state 99. If I have a 99 case switch, the compiler can choose to do two things:1. Build an 99 branch long if else of variable execution lenght.2. Build a jump table of fixed execution lenght.With the function pointer jump table I force the compiler to utilize a jump table.On desktop C++ I would have used the switch approach.

author: Kjelt
author_rank: Super Contributor
timestamp: June 19, 2016, 12:29:37 pm
content: If you have a 99 states statemachine I think the designer should go back to the drawing boardWe had TNO do an analysis for a piece of software consisting of "only"20 states and they have this special custom simulation software that simulates all posibble transitions and other exceptions, it took 2 months, 20k€ but they found a couple of errors in the design. Mind you this was a critical piece of software not able to be updated and should be 100% from the get go.From that day on I personally always stick to the KISS principle if statemachines are involved.And perhaps overkill but from my FPGA days I always encode my states one hot encoded so that any erroneous bit toggle would go to the default error handler instead of another valid state, but that is probably overkill programming for most

author: Galenbo
author_rank: Super Contributor
timestamp: June 19, 2016, 08:29:38 pm
content: Quote from: AntiProtonBoy on June 19, 2016, 08:46:27 amThe example you gave, a switch with each case only being one line, and the whole thing limited in <half a page, is the exception I did not mention.Looks fine, but I still don't like those mandatory break instructions.Nobody uses it without break, they better had designed a "stay;" instruction.For the rest, Your example is not the way I program my 8-bit processors. So maybe my fault, I don't know.

author: retrolefty
author_rank: Super Contributor
timestamp: June 19, 2016, 09:11:36 pm
content: Look, I suspect you could give a dozen seasoned even professional embedded programmers the same none trivial but none complex task and you would get a dozen different styles (formatting) and several different solution methods (algorithm) that all meet the task requirements.I'm only a hobbyist programmer in C/C++ but I've found my style is loads and loads of comments to help me remember six months on what the heck I created.

author: fubar.gr
author_rank: Unknown
timestamp: June 19, 2016, 10:47:16 pm
content: Quote from: hamster_nz on June 15, 2016, 11:41:02 pmI think you will find this paper of interest:https://web.archive.org/web/20090401003425/http://www.cs.mdx.ac.uk/research/PhDArea/saeed/paper1.pdfSince you are involved in teaching programming, you've probably already realized that some people take to programming like a duck to water, while others, can't even write the simplest of programs to save their life.There's always a sizeable group that cannot work out the ABCs of coding, like what the result ofa = a +1will be, or to visualize the sequence of events in a simple while loop.Unfortunately, there's nothing you can do for this group of people. No matter how hard you try and how hard they study in their own time, they are not going to get it.I've heared of a university prof who teaches an introductory course in C and does a neat little trick on his students. He gives an in-class assignment, which is same for everybody, but each student has to put a printf line with their full name at the end of the program.You can't imagine how many people will plagiarize the code from the guy sitting next to them and not bother to change the name with their own. They go into some mental block mode and when they reach the final line, they simply copy it verbatim and type the other guy's name!

author: hamster_nz
author_rank: Super Contributor
timestamp: June 19, 2016, 11:04:52 pm
content: Quote from: Galenbo on June 19, 2016, 08:29:38 pmI submit to you something related to my past, when compilers were dumb, and unrolling loops was something you did by hand:Code:#include <stdio.h>void print_number(int i) {printf("%i\n",i);}void print_numbers(int len){/* How's this for abusing C to unroll a loop */int last_item = len-1;int index = last_item >> 3;if(len == 0)return;switch(last_item & 0x7){while(index--) {case 0x7: print_number(index*8+7);case 0x6: print_number(index*8+6);case 0x5: print_number(index*8+5);case 0x4: print_number(index*8+4);case 0x3: print_number(index*8+3);case 0x2: print_number(index*8+2);case 0x1: print_number(index*8+1);case 0x0: print_number(index*8+0);}}}int main(int argc, char *argv[]){print_numbers(10);printf("\n");print_numbers(5);printf("\n");print_numbers(8);printf("\n");print_numbers(7);return 0;}Have you ever seen a finer example of abuse of the C switch() statement?

author: hamster_nz
author_rank: Super Contributor
timestamp: June 19, 2016, 11:07:13 pm
content: Quote from: fubar.gr on June 19, 2016, 10:47:16 pmThat is awesome!

author: AntiProtonBoy
author_rank: Frequent Contributor
timestamp: June 20, 2016, 01:04:33 am
content: Quote from: Jeroen3 on June 19, 2016, 11:46:19 amThe particular problem I'm referring to is called the "static initialisation order fiasco". Having said that, it could be a specific C++ issue, not C, i can't remember. To work around that problem, you basically do the following:Code:struct Foo { /*...*/ };//Badstatic Foo badFoo = MakeFoo();//GoodFoo* GetGoodFoo(){static Foo goodFoo = MakeFoo();return &goodFoo;}The problem with the "bad" example is that when otherstatically declaredcode in an external translation unit accesses, the badFoo variable may not be initialised yet. Whereas accessing the function GetGoodFoo() will construct the static variable on demand and is guaranteed exists.edit: edited for clarity

author: Jeroen3
author_rank: Super Contributor
timestamp: June 20, 2016, 06:27:19 am
content: That is aboutstaticnotconst. I see no direct relevance to my state machine.The static keyword is tricky due to it's double meaning:1. Statics in objects (or local scopes such as functions) are tricky since they existonce. If you create a more than one objects with a static, the instance of the static variable is shared.It is common that you do not initialize a static variable, but you assign it during creation of the first object. Statics are guaranteed to be zero initialized.2. Static globals mean that the object is not accessible outside the containing scope (the file). You can'texternit.If you'd want to see ugly code, go find yourself somevoidpointers. Those are fun.You can really do some pointer kung-fu with those. It will scare the newbies!

author: AntiProtonBoy
author_rank: Frequent Contributor
timestamp: June 20, 2016, 08:35:29 am
content: Quote from: Jeroen3 on June 20, 2016, 06:27:19 amSorry man, I must have missed something. Did you mention something about your state machine and how it relates to const?I was only expanding on the bullet points I made earlier, and you actually asked for an example. My earlier point was, creation of lookup tables generally involves storing them as a static object of some description. Create once, use many times. It's a common technique. The problem is, statics referenced by other compilation units, probably indirectly via some forward declared function, is undefined behaviour. I seen people make this mistake a few times, including myself.Here is a more comprehensive example:foo.hCode:#ifndef FOO_H#define FOO_Hstruct Foo { /*...*/ };#endifbad.hCode:#ifndef BAD_H#define BAD_H#include "foo.h"Foo* GetBadFoo();#endifbad.cCode:#include "bad.h"Foo MakeFoo() {return /* ... */}static Foo badFoo = MakeFoo();Foo* GetBadFoo() {return &badFoo;}good.hCode:#ifndef GOOD_H#define GOOD_H#include "foo.h"Foo* GetGoodFoo();#endifgood.cCode:#include "good.h"Foo MakeFoo() {return /* ... */}Foo* GetGoodFoo(){static Foo goodFoo = MakeFoo();return &goodFoo;}main.cCode:#include "bad.h"#include "good.h"//Undefined behaviour, as GetBadFoo may point to data not initialised yetstatic Foo badFoo = *GetBadFoo();//Okay, as GetGoodFoo points to data that will be initialised once on demandstatic Foo goodFoo = *GetGoodFoo();int main(/* ... */){DoSomething(badFoo); //OopsDoSomething(goodFoo); //Okay}

author: Kirr
author_rank: Regular Contributor
timestamp: June 20, 2016, 10:18:45 am
content: Quote from: hamster_nz on June 15, 2016, 11:41:02 pmPersonally I'm not a big fan of Scratch. I'd let the kids learn proper text-based coding from the start. But that would be even harder for those who are not "wired to code". Perhaps Scratch is more engaging and makes it easier to survive coding class for the unlucky non-wired ones (which could be the majority).Unfortunately segregating kids on ability is bordering on "intolerance" and "political incorrectness", so schools are not going to do nearly enough of it to make much difference. For as long as the lowest common ability is the target, Scratch will be a popular choice I guess.As you say, for the most people no amount of learning can turn them into coders. But note that we do teach math at schools to everyone, without expectation of producing an army of math experts either. Both advanced math and coding has close to zero utility in average person's daily life. Yet both may help to develop logic, abstract thinking and whatever other good traits. Which is better and how to best divide school time between math and coding - I'm not sure.

author: Jeroen3
author_rank: Super Contributor
timestamp: June 20, 2016, 10:46:06 am
content: The lookup table is indeed static for data hiding, but it's also const. It is placed in ROM, there can be no unintialized state. Even if I perform initialisation of the lut in ram, there still can't be an unintialised state for the code, because it is copied from linker resources before entry of main.If i were to use it before jump to main, in the assmemly startup file, I will get undefined results.It looks like you're using static as keyword for linking between files. Isn't extern meant for that?

author: sca
author_rank: Regular Contributor
timestamp: June 20, 2016, 11:19:58 am
content: Quote from: hamster_nz on June 15, 2016, 11:41:02 pmThe 'more engaging' bit is something of a double edged sword.It's very easy for kids to get distracted into making 'costumes' etc and end up doing no coding whatsoever. The teacher meanwhile has ticked the 'coding' box on the curriculum.I do like Scratch, we've done some moderately interesting things at home with it, but without appropriate supervision, in a classroom context, it's verging on worse-than-useless.sca

author: madires
author_rank: Super Contributor
timestamp: June 20, 2016, 01:01:57 pm
content: "Can everybody code?" is a silly question. It's like "Can everbody bake a cake?". It think the question should be: "Should everybody be able to code?". And my answer would be: "I don't think so.". Who likes writing software should do so, but we shouldn't force everyone to learn programming. There's more than enough bad code out therePS: I do both

author: bitshift
author_rank: Regular Contributor
timestamp: June 20, 2016, 04:40:09 pm
content: Quote from: hamster_nz on June 16, 2016, 02:22:42 amOut of interest, is there any inherent reason why an engineer should get paid more than any other run-of-the-mill trade?

author: Jeroen3
author_rank: Super Contributor
timestamp: June 20, 2016, 06:53:03 pm
content: It's basic supply and demand. If there are less people with the skill a company needs, the people become more expensive.We (the dutch) are running towards a shortage of all trades: plumbers, engineers, programmers, IT people, welders... Everyone?The shortage I can't possible understand is the lack of people in basic healthcare, while a basic healthcare company falls over every month or so. But that is not related to this topicA company here paid a full month bonus to the guy who could find a full time embedded software developer.Any new guy from bachelor or masters software development would fit. There are less then 50 graduates a year around here. Compared to around 600 new lawyers each year.It's even worse for IT and Web folks, they have plenty of graduates, but they are trained for the stuff from today. Which companies don't use, they use the stuff from 5-10 years ago!

author: bitshift
author_rank: Regular Contributor
timestamp: June 20, 2016, 07:16:01 pm
content: I can understand that a shortage of skills would cause an increase in remuneration. I did a Computer Science degree here in South Africa and in first year there were around 260 students. At the end of the degree only 23 of us graduated. There is a massive shortage of "skilled" software developers here and as a result software developers are starting to out-earn engineers (mining engineers being the exception in South Africa).I was more interested in the idea of comparing software developers to blue collar workers. Software development, in my opinion, is very much like engineering in that you are required to "engineer" and build solutions from the ground up. This is in contrast to mechanics which repair already engineered items for example.

author: Kjelt
author_rank: Super Contributor
timestamp: June 20, 2016, 07:58:44 pm
content: Quote from: bitshift on June 20, 2016, 07:16:01 pmIt does not. That is what baffles me the last years, the salary for IT specialists, programmers etc. stay about the same.It is not bad but still much less than lawyers or bankers or managers and there are plenty of those to go around.To me this is proof that there are silent agreements between the large tech companies not to raise the salaries in order to keep the market quiet.Otherwise good tech people would easily get 100k today instead of the 50-60k they get today.Another proof of this is that a brilliant colleague of mine that has multiple PhD's was going to leave our company for another company and would get 1,5x his current salary which btw was around 100k.The negotiations took months and one day he was requested by his boss's boss. There was this committee of high managers that asked him why he would leave and how much he was valued and actually they were not going to let him leave. He was flabbergasted he never spoke about it to anyone not even his friends.Later on he found out through a friend that had relatives in the management of the other company that the higher management of that company contacted our higher management to see if they would not object too much of taken him over. WTF??So that was for me the hard proof. It happened also in the states where I believe Apple, MS , Google and some others had silent agreements not to aggresively hire personell from the other company, that is soooo bad for the engineers that could really benefit from cross hiring.

author: rstofer
author_rank: Super Contributor
timestamp: June 20, 2016, 08:18:48 pm
content: Quote from: bitshift on June 20, 2016, 04:40:09 pmMath! Up to a point, people with more math in their curriculum tend to make more money. Obviously, that theory blows up at executive levels where other criteria dominate.

author: Dago
author_rank: Frequent Contributor
timestamp: June 21, 2016, 05:52:12 am
content: Quote from: Jeroen3 on June 20, 2016, 06:53:03 pmFinland basically has the same problem. But actually I think the problem is that they are not willing to pay enough for nurses and other healthcare professionals so no wonder there is a shortage. I can totally understand how nursing in an old peoples home or something is extremely heavy (physically and mentally) work and not everyone wants to do that especially when you're not being compensated enough for it.

author: bitshift
author_rank: Regular Contributor
timestamp: June 21, 2016, 07:14:41 am
content: Quote from: rstofer on June 20, 2016, 08:18:48 pmWhy aren't math graduates the highest paid then? To be fair, CS majors do a lot of math. Statistics, calculus, linear algebra, mathematical modelling, discrete structures, abstract algebra, numerical analysis were all math modules we took. We even did the formal mathematics behind programming languages (can't remember the name now, did it as part of a programming languages course).I don't think computer scientists are better than engineers and vice versa as we both work in related but different areas of practical technology implementation. I do take offence to the notion that we are like blue collar workers though

author: bitslice
author_rank: Frequent Contributor
timestamp: June 21, 2016, 11:56:52 am
content: I suspect leaning to program in BASIC as a kid was a bad thing, even now I think in BASIC and then convert to C.On the other hand the mad duffer teaching us PASCAL at Poly may have been inadvertently helpful, as it was quite a structured way of programming. Even though he was personally convinced that the outside world was awash with jobs in PASCAL programming, when it was blindingly obvious that the world (at the time) was using C and JAVA.

author: rrinker
author_rank: Super Contributor
timestamp: June 21, 2016, 01:16:52 pm
content: Maybe, maybe not. My first computer language was BASIC, when the TRS-80 Model 1 came out. I couldn't afford one, at the tender age of 11 or so at the time, but I could afford the $5 manual and the mall with a Radio Shack was close by so we were frequently there - I stayed in the RS store the whole time while my Mom and Sister went shopping. My first computer that I had at home though was a small single board kit that programmed directly in machine language with a hex keypad. I parlayed that into teaching my friend (who DID own a TRS-80) Z80 assembly (my computer was an RCA 1802) when he bought the EDTASM program and had no idea how to use it. In HS I learned FORTRAN and took a (so called) advanced BASIC class (they let me skip the prerequisite beginner class) where due to the utter slowness of Apple 2 BASIC, I had to code some of my routine in 6502 assembly. By the time the started teaching Pascal in school I was well past the beginner stage and looking at it briefly (I never really did much programming in it, just helped out some other students on occasion - truly, once you know one language it's not terribly difficult to figure out at least the basics of another) and all I even thought about it was that it was made explicitly for teachers - it always seemed much less flexible than other languages, which in my eye made it perfect for the classroom - every correct solution to a given problem would be pretty much identical, making it easy to grade. I also then had a college course in FORTRAN as well as one that used 8080 Assembly - not a difficult jump down from Z80 which by then I was quite familiar with since by that time I did have my own TRS-80, a Model 4P. The whole grading thing was borne out by this class - grading was accomplished by printing your code listing and then executing your program in front of a lab TA who, upon witnessing the program execute properly, then signed off on your code listing which you turned in. No one read through all that code to see if you got it right. Shortly after graduation I started playing around with C, writing code for a multiport I/O card I designed but never built for model railway control. Originally Turbo C, but then I got into early Linux releases and played with GCC as well. At the same time, I was also working in higher level stuff at work, FoxBASE/Mac in the maintenance department and Advanced Revelation for the business office. Over the years I've picked up other stuff, doing lots of stuff with Visual Studio, mainly VB but some VC++ as well as plenty of VBA in Excel and Word and lately a lot of Powershell scripting since my primary job is installing and supporting Windows servers and associates systems like Exchange and SQL Server. Oh and some SQL dev stuff too, writing SSIS packages and other things there.With all this programming background, you may wonder why I have an EE and not CE or CompSci degree - well, along with all this playing around with computers in my younger days, I ALSO did plenty of circuit building and experimenting. And I had done enough programming prior to college that I knew I wasn't really all that interested in the why's and how's of various computing algorithms, I was more into the hardware with the programming part of it a necessity to make it all do something. So while I do program for fun and profit, and it's a nice break at work when someone has a bit of a development project (we don't generally as a company do any sort of serious development projects, but occasionally a customer will ask for some small things, which as the only one in the organization with any experience at it, such things always fall to me), I still am mostly a hardware geek. I did somewhat enjoy my time a few years back when I was engaged on a 2 year application development project, but that focus also set me behind on some of the newer server technology plus operating as a solo developer was a bit trying at times, with no one else to bounce ideas off other than some online forum where, due to the nature of the project, I couldn't reveal much about what I was doing, I had to post most detailed questions as hypotheticals or completely made up examples in no way related to my actual project. In the end it worked out pretty well but a second set of eyes on the project would have made it go a lot smoother and quicker.

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 12:58:38 am
content: I've programmed in several languages over the years. My favorite is assembly, it's elegant! My least favorite is 'C'. 'C' should go void it self if you ask me but I do use it.I think if you're going to be a viable engineer you really need to learn rudimentary coding. Apparently there are a lot of people who can't do it so they spend money on dweennos of one type or another. 'C' is a pain ,Oh I already said that, I think it's worth repeating. I'm sorry it's the common uC language.Rob

author: dannyf
author_rank: Super Contributor
timestamp: June 22, 2016, 01:29:25 am
content: QuoteThat just about nailed it. Everyone one can code, just as everyone can shoot a basketball. Not everyone can code, just as not everyone can shoot a basketball like Michael Jordan.The answer depends on what is meant by "coding".

author: dannyf
author_rank: Super Contributor
timestamp: June 22, 2016, 01:33:25 am
content: QuoteYes. Those companies are fined for anti-trust offenses, a criminal matter. That's why the tech companies are some of the largest contributors to political campaigns.However, I don't think that's a major contributor.Two things come to my mind:1) engineering isn't the biggest contributor of value to even tech companies' success.2) H2 visas act as an effective regulator of tech salaries.To a less extent: I would also add that at the highest level, tech engineers' primary income comes not from salaries but from stocks.And contrary to what most people think, there is no shortage of STEM graduates in most western countries.

author: hamster_nz
author_rank: Super Contributor
timestamp: June 22, 2016, 01:42:50 am
content: Quote from: Robaroni on June 22, 2016, 12:58:38 amTell me you aren't trolling.... really?"Assembly is elegant?" - how can you support this in any way? Convince me!

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 12:07:23 pm
content: Quote from: hamster_nz on June 22, 2016, 01:42:50 amTrolling? What?? because I find assembly elegant? I'm not the only one, lots of engineers do. It's precise, gives you the best control of timing and it's compact. I've done things with an AVR Tiny that 'C' people need a Mega for.Have you and do you ever program in assembly? Sure 'C' has its place but so does assembly, it's like Latin, once you know it well your other languages benefit.Rob

author: Kjelt
author_rank: Super Contributor
timestamp: June 22, 2016, 12:16:26 pm
content: Assembly is processor bound and way too specific for general software development.C is freedom between different processor families and manufacturers.The only reason I now and then inline some assembly code into C , is because C has no multiply with carry

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 12:20:17 pm
content: Quote from: blueskull on June 22, 2016, 01:21:02 amI can't argue with this, I do mostly compact, high performance code on uC's. So, it's what you use it for and certainly 'C' has its place.Rob

author: Kjelt
author_rank: Super Contributor
timestamp: June 22, 2016, 12:23:45 pm
content: Quote from: Robaroni on June 22, 2016, 12:20:17 pmTwenty years ago you would have a great point, but nowadays modern compilers are so good you really have to do a lot of work to optimize your code using assembly.In the peripherals and lower layers you could gain some, but it would be a PITA to write your utils and services all in assembly instead of C and have to redo most of it when the company decides to switch to another brand of micro.

author: madires
author_rank: Super Contributor
timestamp: June 22, 2016, 12:27:25 pm
content: Anyway, Pascal and Java are the most common languages for teaching programming.

author: Kjelt
author_rank: Super Contributor
timestamp: June 22, 2016, 12:36:12 pm
content: Quote from: madires on June 22, 2016, 12:27:25 pmHow do you figure that?In any case these are the most used programming languages, Pascal is not on the list , perhaps they should fire/replace or update those old fashioned teachers from the 80's.https://en.wikipedia.org/wiki/TIOBE_indexhttp://www.tiobe.com/tiobe_index

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 12:38:50 pm
content: Quote from: Kjelt on June 22, 2016, 12:23:45 pmI do a lot of work with AVRTINY uC's and assembly is ideal for them. When you need precise timing ASM is hard to beat.Sure, although I've done it in ASM, floating point math can get cumbersome. I usually got to 'C' when I have to crunch numbers.And again, ASM gives you a solid background to build off of when you go to C.Ro b

author: Kjelt
author_rank: Super Contributor
timestamp: June 22, 2016, 12:40:18 pm
content: Trends over the years, C is still rocksteady, JAVA is in decline

author: madires
author_rank: Super Contributor
timestamp: June 22, 2016, 12:45:29 pm
content: There's a huge difference between the most popular languages and the ones good for teaching programming. You don't teach the "right" languange, you teach one suitable for beginners to learn the basics. And later on JS, python and what have you.

author: dannyf
author_rank: Super Contributor
timestamp: June 22, 2016, 12:45:44 pm
content: "I can't argue with this, I do mostly compact, high performance code on uC's. "I wonder what kind of high performance code you write on attiny? Blinking LEDs really fast?Btw, if you rely on asmbley for precision timing, you are in the wrong business.

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 12:56:00 pm
content: Blinking LEDs?Everything from SPI, I2C, etc.Precise tachometer functions on 2313A's.CNC and DRO's on Tiny48's and 88's.Rob

author: dannyf
author_rank: Super Contributor
timestamp: June 22, 2016, 01:04:45 pm
content: That's what you meant by "high performance" code?You believe that it can only be done in assembly?We C people do that with our eyes closed,

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 01:07:49 pm
content: Quote from: dannyf on June 22, 2016, 01:04:45 pmCan you program in ASM?

author: dannyf
author_rank: Super Contributor
timestamp: June 22, 2016, 01:16:22 pm
content: Not in the code you write high performance code on attiny.We C people consider them fairly low end.

author: dannyf
author_rank: Super Contributor
timestamp: June 22, 2016, 01:21:33 pm
content: However, if you can code in assembly 256 bignumber ligrithmic routines, or 64 bit IEEE compliant floating point fft routines in assembly, and being able. To port it from your avr to arm to 8086 and that mcu to be invented 5 years from now, I would consider that "high performance" coding.Being able to use spi or i2c is a pre-requisute for an entry level programmer or an intern.

author: Kjelt
author_rank: Super Contributor
timestamp: June 22, 2016, 01:22:50 pm
content: Quote from: madires on June 22, 2016, 12:45:29 pmI know but not extinct languages where a compiler is hard to find and students can not use in their own environment.My personal belief is that if you want a student to code , you learn him the basics in about a hundred hours and then let him learn the rest at home on their own projects.That means you need them to have a practical and living language that has use outside the classroom, preferably also used in businesses.

author: Galenbo
author_rank: Super Contributor
timestamp: June 22, 2016, 01:23:28 pm
content: Quote from: Kjelt on June 22, 2016, 12:16:26 pmasm CLRWDT;asm reset:-)

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 01:30:08 pm
content: Quote from: dannyf on June 22, 2016, 01:16:22 pmGee, I see the light, you're absolutely right Danny, I'm wasting my time. Now go bug (pun intended) someone else. What's your point? Don't use it, I don't care. I didn't get that answer, did you say you can program in assembly?And I am "C people", I program in the language that works best for the application.How's that rigidity working out for you?What's your point??Rob

author: dannyf
author_rank: Super Contributor
timestamp: June 22, 2016, 01:31:19 pm
content: "My personal belief is that if you want a student to code , you learn him the basics in about a hundred hours and then let him learn the rest at home on their own projects".I think C is very difficult to teach, especially at thee entry level, due to all the intricacies and it's power.Javaa and Python are easier on that regard.Assembly can be easy to teach if you are limiting yourself to simple mcus and simple tasks. In real life, assembly is probably the most difficult language to develop, maintain and deploy. It is idealy suited to two types of tasks:1 very simple ones, like blinking An LED.2. Very complex ones where you are. Pushing the performance envelope (by that, I don't mean spi or. I2c). Most of us solve that problem by going to a more powerful chip. But if you cannot, assembly sometimes is your only way out.

author: Kjelt
author_rank: Super Contributor
timestamp: June 22, 2016, 01:49:33 pm
content: Quote from: Robaroni on June 22, 2016, 12:38:50 pmI understand that, still I would do all coding first in C, look at the results and then pinpoint the functions or parts of the functions that cause timing problems and check the assembly the compiler generated and optimize that where needed instead of writing in assembly from scratch.

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 02:03:47 pm
content: Quote from: dannyf on June 22, 2016, 01:31:19 pmThis routine uses only one int. pin, if the pin is not set it returns using just 2 machine cycles, if the pin is set it uses 4 machine cycles - beat it in C.Encoder:sbis PinB,0reti ;A not high = returnsbis PinB,1rjmp Clock_Incr ;incrjmp Clock_Decrementreti

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 02:09:07 pm
content: Quote from: Kjelt on June 22, 2016, 01:49:33 pmYes but ASM is so easy for me that I just run through it. Sure when things get complex I go to C. when I need to really optimize an I2C routine I can contour it in ASM much better than C and get a lot out of 2K space.Rob

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 02:15:22 pm
content: Quote from: dannyf on June 22, 2016, 01:31:19 pmAnd I disagree, I can write an I2C or SPI routine that uses less space in ASM than C, contour it to my specific needs and do it on a 37 cent per 100 TINY11 with no built in TWI function.Rob

author: hamster_nz
author_rank: Super Contributor
timestamp: June 22, 2016, 07:20:22 pm
content: Quote from: Robaroni on June 22, 2016, 12:07:23 pmJust a little.A few platforms & projects worked on over the years that I can remember:* 6502, mostly in hex and as numbers in BASIC DATA statements that get poked into memory then called.* Z80, Spectrums Yay!* DG Eclipse - with a real OS* 8088 - a DOS driver that used OSI networking to talk with an ICL mainframe to grab data into a Powerflex program. TASM, MASM...* 80386 stuff in 80368 that jumped to protected mode (yay! setting up page tables and call gates),* 80486 (when hand ASM optimization got very bland)* Pentium (when it got interesting again for a while for optimizing due to superscaler CPUs)Then graphics cards and OSes took all the fun out of it...* PIC - restarted assembly on 16F84s* AVR/Arduino, mainly as inline in GCC for as you say, precise timing* ARMHowever integrated FPUs and GPUs have taken all the fun out of it. Superscalar CPUs, Protected mode, Virtualization, Operating systems, Hyperthreading, Interupts, Cache misses and so on have meant that "oh, it gives you precise timing" is no longer true on anything but the smallest embedded platforms. Assembly to leverage multcore CPUs is hard, you really need the abstractions that a full OS provides.Having an FPU is the big one though - a compiler can write FPU code pretty much just as well as anybody can, so I now spend my time improving things at the algorithm level, not bits and bytes. So now I use C for pretty much everything, and when I do need precise bashing of bits for anything but hacks, any HDL is really the only way to go over assembly. Can assembly bash multi-gigabit data over multiple channels with sub-nanosecond accuracy? Nah, Didn't think so, it only gets you to the 10s of MB/s, if you are lucky.Using assembly no opens up what is achievable on a platform by a small bit, less that changing platforms to one with better peripherals, or faster clock does.Still not convinced.

author: dannyf
author_rank: Super Contributor
timestamp: June 22, 2016, 09:42:26 pm
content: "I can write an I2C or SPI routine that uses less space in ASM than C, contour it to my specific needs and do it on a 37 cent per 100 TINY11 with no built in TWI function."I don't doubt for a second that it is true.Does that, however, make your code "high performance"?If so, I would venture to say that you have a unique definition of " high performance".

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 10:35:13 pm
content: First, I'm not trying to "convince" anyone of anything, use the system you want, that's why electronics is called an "art". There's more than one way to accomplish a goal.Secondly, being able to control timing and compact code on relatively inexpensive uC's makes it high performance and that's what I use it for mostly because that's the kind of work I want to do now that I'm retired, well semi-retired. If I had to do floating point math I probably would use C. The nice thing is I always have the option because I know both.I gave my OPINION with respect to programming. Don't like it? Gee now I'm upset. I'm going to change my complete way of doing things because a couple of guys on the blog disagree with my approach to programming.Right, I'm selling bridges all next week, how many do you two want?Rob

author: dannyf
author_rank: Super Contributor
timestamp: June 22, 2016, 10:51:09 pm
content: I think yoy are taking it too personalky. I forr one isnt challenging your right to call doing spi or i2c on an attiny "high performaannce". If anything, i would defend your right to call it whatever you feel like. Just as I don't think you are justified in getting mad at others expressing their views about it being ultra low-end. I was being polite in telling you that i would have to significantly reassess an empkoyee if he told me his getting precision timing through the use of assembly - something like that is pre requisite in getting an entry level job. Not something you brag about, especially with such fan fare of " high performance" coding in a professional setting."Secondly, being able to control timing and compact code on relatively inexpensive uC's makes it high performance"I think had you laid this out upfront, this whole conversation could have been avoided. As you can tell, "high performance" can mean totally different things to different people. Understanding what others means by a common term goes a long way in facilitating a productive conversation.

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 22, 2016, 11:14:38 pm
content: Quote from: dannyf on June 22, 2016, 10:51:09 pmYou missed it again, the high performance is the ability to perform those tasks more efficiently than C on AVRTiny uC's and get more out of those chips than is possible with C.As far as entry level jobs go, I don't need one now and never have, I retired from what people who actually live in the rat race call the workforce in my mid 40's with several medical instrument patents and no need to ever work again in my life. So basically I do exactly what I want in my life and electronics work and have for the last 25 years. Is that high performance enough for you being someone who seems to know a lot about entry level jobs?Rob

author: hamster_nz
author_rank: Super Contributor
timestamp: June 22, 2016, 11:32:18 pm
content: This thread just made me recall a repressed memory for the past - the whole 'Gate A20' thing. If you never heard of it, look it up and have a laugh at our expense.Argh! I'm going to go sit in a corner and cry for a while.

author: lemmegraphdat
author_rank: Frequent Contributor
timestamp: June 23, 2016, 02:18:38 am
content: Can you? Just pick one and do it.

author: Kjelt
author_rank: Super Contributor
timestamp: June 23, 2016, 07:15:58 am
content: Quote from: dannyf on June 22, 2016, 01:21:33 pmCome to think of it, on my 60 projects I did on an 8 bitter commercial and non-commercial I never ever used floats.Reason is this costs a large library, bloats the codesize and actually I never needed it.If I needed higher precision I used longs and multiplied the values (preferably binary with shifts) and devide them when I use them.That is how I for years calculated and transformed AD values back to the SI units.Sometimes I used lookup tables if small or simple curves like lines can be translated in a formula and if they became too strange the curves I used excel to translate the measured curve back to a quadratic equation and programmed that in the software. But floats, nah floats->bloats

author: dannyf
author_rank: Super Contributor
timestamp: June 23, 2016, 10:10:09 am
content: "I retired from what people who actually live in the rat race call the workforce in my mid 40's with several medical instrument patents and no need to ever work again in my life. So basically I do exactly what I want in my life and electronics work and have for the last 25 years."The fact that you find it compelled to boast about your supposed "success" and imaginary "wealth" publucally in a discussion of "high performance" coding tells us all we need to know about your success. I bet you if we challenged you to show verifiable evidence of your wealth and those parents of yours, you would find innumerable number if excuses as to why you cannot provide them. But we all know braging on the net us cheap, precisely because of that.I wish you best of luck in your "high performance" code on driving spi and i2c on attiny.

author: dannyf
author_rank: Super Contributor
timestamp: June 23, 2016, 10:12:38 am
content: "I never ever used floats."You aren't alone. I usually just use millivolt for volt, ua for milliamp, all in integers, to provide some decimal points.

author: Robaroni
author_rank: Frequent Contributor
timestamp: June 23, 2016, 12:10:52 pm
content: Quote from: dannyf on June 23, 2016, 10:10:09 amYou keep tripping over the same stone. Because I gave an example of bus generation doesn't mean that other tasks can't be done in ASM and I explained the benefit of ASM.Coding is done in blocks, most complex tasks can be broken down to code blocks that can be chained together regardless of the language used. You brought up blinking an LED, I merely cited more complex task, it wasn't a full list of what can be done in ASM. Anyone who knows ASM, knows that!You constantly attempted to diminish me with little slanders implying all that ASM was good for was simple "entry level" tasks. Why because I like to use ASM? We don't even know if you can write a full in depth program in it.I never sat in a cubicle with a boss dropping menial work on my desk, I got out and figured a better way to live and I worked hard, really hard across several engineering platforms. So am I proud of the fact that I retired young and beat the "entry level job" rat race. You bet! Am I happy about the fact that I get to pick the work I want to get involved in today and don't answer to anyone? You bet!You're so smart? What's your day job?PM me and I'll give you parent(sic) numbers.And I've always respected the talent and brains on this site so it really bugs me when someone comes along with an ax to grind (for whatever reason) and bites at my ankles.R

author: apis
author_rank: Super Contributor
timestamp: June 23, 2016, 01:38:58 pm
content: I think the point of trying to teach everyone to code is not to make everyone programmers but to at least give everyone some fundamental understanding of what is possible to do with a computer program. Most countries in the world spend a lot of resources and time trying to teach all children mathematics, yet most adults don't understand how to calculate percentages... If the school forces people to learn chemistry, for example, then surely programming is just as important, if not more.Quote from: Kjelt on June 23, 2016, 07:15:58 amFloats doesn't really give higher precision (the precision is fixed!), it gives higher "dynamic range" thanks to the exponential part. You can do it all with integers, shifting and so on, it's just more work than letting the library (or rather whoever coded that library) do it for you. Some might be forced to use standard floating point though, to ensure you handle all the corner cases in a consistent way in all parts of a system.