Previous in Forum: How I Show Only Cells of Excel   Next in Forum: Learning to Code Made Easy
Close
Close
Close
8 comments
Rating: Comments: Nested
Guru

Join Date: Jun 2010
Location: New York
Posts: 972
Good Answers: 23

An Exercise in Efficiency for Code

03/27/2013 1:02 PM

JS1K is a little challenge site set up to make a working application using under 1 KB of Javascript. It started as a joke, but has since grown into something kind of incredible.

Check out some of the creations people have been able to come up with here. OR just check out a couple of my favorite entries thus far:

working notepad in cursive

a tunnel demo

making a structure using dots

For an added bonus, you should check out the various source codes supplied by the drop down menu to see just how precise the code is. If more websites utilized maximum efficiency in their code, we (the web-browsing consumer) would be able to navigate pages at speeds never seen before.

__________________
The first law of thermodynamics is you do NOT talk about thermodynamics.
Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru

Join Date: Jun 2010
Location: New York
Posts: 972
Good Answers: 23
#1

Re: An Exercise in Efficiency for Code

03/27/2013 2:07 PM

Here's a physics engine put in only 1024 bits (impressive!). Each dot follows Hook's law of "being a spring" so it's an interesting little toy, especially for how condensed it is!

__________________
The first law of thermodynamics is you do NOT talk about thermodynamics.
Register to Reply
Guru

Join Date: Jun 2009
Location: South of Minot North Dakota
Posts: 8376
Good Answers: 775
#2

Re: An Exercise in Efficiency for Code

03/27/2013 5:04 PM

I have always wondered why programmers don't design their code to be far more efficient.

To me having the most efficient code would mean having the fastest program response times and working speeds which is what everyone wants from their stuff.

Register to Reply
Guru
Hobbies - Musician - New Member

Join Date: Feb 2012
Posts: 523
Good Answers: 17
#3
In reply to #2

Re: An Exercise in Efficiency for Code

03/28/2013 10:44 AM

My speculation is that hardware is so cheap. When I first learned to program (Early 1970's), you had to account for every bit and byte. When 64k was the upper limit for memory, your code had to be as spare as possible. With faster microprocessors and buses and oodles of cheap memory (counted in gigs and teras, for heaven's sake!) the pressure to optimize is minimal.

I do things in Excel now that I used to have to write my own program for and then start it running when I left for the day, hoping it would be finished by the time I came in the next day.

Register to Reply
Guru

Join Date: Jun 2009
Location: South of Minot North Dakota
Posts: 8376
Good Answers: 775
#4
In reply to #3

Re: An Exercise in Efficiency for Code

03/28/2013 2:36 PM

I follow the cheap hardware concept well enough but still by far portable devices tend to be up against battery power limitations which I think could be greatly alleviated with the simplification of software to reduce the amount of hardware needed to run a program.

Wouldn't trimming down a software program to run on 30% of its present needed code and hardware also give a near proportional savings in battery power usage as well?

Register to Reply
Guru
Hobbies - Musician - New Member

Join Date: Feb 2012
Posts: 523
Good Answers: 17
#5
In reply to #4

Re: An Exercise in Efficiency for Code

03/28/2013 3:22 PM

I admit I know nothing of apps for phones and such. However, the biggest energy user on my android phone is the display. As long as the app has the display on, I doubt optimized code would do much to improve battery life.

Perhaps one of our friends can provide more info and lead us to a reasonable conclusion.

Register to Reply
Anonymous Poster #1
#6
In reply to #4

Re: An Exercise in Efficiency for Code

03/28/2013 4:28 PM

Actually, the amount of code is less a factor in power consumption as is the speed at which it runs. Cutting clock speeds drastically reduces power consumption.

And simplifying software and reducing hardware rarely come at the same time. There is usually an inverse relationship and you must write more software to make up for the missing hardware.

Register to Reply
Guru

Join Date: Dec 2009
Posts: 581
Good Answers: 15
#7
In reply to #2

Re: An Exercise in Efficiency for Code

03/28/2013 6:32 PM

I have always wondered why programmers don't design their code to be far more efficient.

Because, like all other engineers, we are lazy. Um, I mean, we prize efficiency in the creation and maintenance of software, which is costly and difficult to manage. Usually, the most efficiently-executing design is not the simplest to create or the easiest to understand and maintain.

(It's nice to be back after two+ years on the dark side [management].)

__________________
Ignorance is no sin. Willful ignorance is unforgiveable.
Register to Reply
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#8

Re: An Exercise in Efficiency for Code

03/28/2013 6:55 PM

Cool programs. I take it the train never stops. I got the feeling I was going in circles. I remember the first HP computers that had 1kB of total memory. The techs checked them out by programming them with the row of toggle switches on the front panel!

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply
Register to Reply 8 comments
Copy to Clipboard

Users who posted comments:

Lynn.Wallace (1); Mizuti (1); reward54 (2); StandardsGuy (1); tcmtech (2)

Previous in Forum: How I Show Only Cells of Excel   Next in Forum: Learning to Code Made Easy

Advertisement