• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 13:02
CEST 19:02
KST 02:02
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists22
Community News
Weekly Cups (April 27-May 4): Clem takes triple0RSL Revival: Season 5 - Qualifiers and Main Event11Code S Season 1 (2026) - RO12 Results12026 GSL Season 1 Qualifiers25Maestros of the Game 2 announced9
StarCraft 2
General
Weekly Cups (April 27-May 4): Clem takes triple Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Code S Season 1 (2026) - RO12 Results Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun Team Liquid Map Contest #22 - The Finalists
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament RSL Revival: Season 5 - Qualifiers and Main Event StarCraft Evolution League (SC Evo Biweekly) 2026 GSL Season 2 Qualifiers $1,400 SEL Season 3 Ladder Invitational
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 524 Death and Taxes The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base
Brood War
General
AI Question ASL21 General Discussion Using AI to optimize marketing campaigns [ASL21] Ro8 Preview Pt2: Progenitors Why there arent any 256x256 pro maps?
Tourneys
[ASL21] Ro8 Day 4 [ASL21] Ro8 Day 3 [Megathread] Daily Proleagues [ASL21] Ro8 Day 2
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV OutLive 25 (RTS Game) Daigo vs Menard Best of 10 Nintendo Switch Thread
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread Russo-Ukrainian War Thread 3D technology/software discussion Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread Formula 1 Discussion McBoner: A hockey love story
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Movie Stars In Video Games: …
TrAiDoS
ramps on octagon
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1922 users

The Big Programming Thread - Page 468

Forum Index > General Forum
Post a Reply
Prev 1 466 467 468 469 470 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
Last Edited: 2014-04-14 18:16:42
April 14 2014 18:13 GMT
#9341
On April 14 2014 06:39 bangsholt wrote:
Show nested quote +
On April 14 2014 04:42 Manit0u wrote:
The thing is, the date was being set. I solved it by making the check in a different class though (before strings are joined with -).


Why are you not converting the string date into a DateTime or something similar as soon as you can? You can always get the string representation at a later point - or even use Humanizer, if it's to show for a user.

http://www.hanselman.com/blog/NuGetPackageOfTheWeekHumanizerMakesNETDataTypesMoreHuman.aspx


I'm not converting it to DateTime because it's for a program that has to convert between two file formats and I have to get the strings and then reformat them certain way. All the values there are strings for simplicity (even values that would normally be ints). And the program has to do it both ways and people who're using it have no standards (on one end at least) and write their date using '.' or '-' or '/' as a separator or without any separator at all, which is most annoying but if it's a string I can easily fix that.

Also, a stupid question perhaps, but related to the subject. Does C# have a method that would convert '000018920300' into '189203.00'?

The rather dirty way for me to do it was take it as a string, strip leading zeros, split into two substrings and join them with '.' to get the final string.
Time is precious. Waste it wisely.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
April 14 2014 18:19 GMT
#9342
--- Nuked ---
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
April 14 2014 18:22 GMT
#9343
On April 15 2014 03:19 Nesserev wrote:
Show nested quote +
On April 15 2014 03:13 Manit0u wrote:
Also, a stupid question perhaps, but related to the subject. Does C# have a method that would convert '000018920300' into '189203.00'?

The rather dirty way for me to do it was take it as a string, strip leading zeros, split into two substrings and join them with '.' to get the final string.

Use regular expressions?


The dirty way seems fine to me. It's equivelently understandable to the way using the C# double library: http://msdn.microsoft.com/en-us/library/system.double.aspx
Any sufficiently advanced technology is indistinguishable from magic
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2014-04-14 18:45:34
April 14 2014 18:37 GMT
#9344
On April 14 2014 06:43 Manit0u wrote:
Show nested quote +
On April 14 2014 05:23 spinesheath wrote:
On April 14 2014 04:58 whiteLotus wrote:
just a dumb question, is it theoretically possible to actually learn programming through google, various online courses and tutorials, like lets say java,php,jq, maybe some python or C, and actually get a job as a web programmer or smth at some shitty ass company, or you would still ideally need some university courses like advanced math and shit? i dont mean anything like software developer at Blizzard or anything like that lol.

You certainly can become good enough, the question is whether you can get an invitation to an interview. The majority of my knowledge is from the internet and books, university was a painful waste of time.
Proof techniques, combinatorics and matrices are pretty much the only things I learnt at univeristy and consider relevant. For comp sci stuff, it was far more efficient to just read it up myself.

But I don't know how good universities are where you live, and having a piece of paper saying "I provably spent some time on learning moderately relevant stuff" is rather effective for getting a job.


It all depends. I have a friend who quit uni because he couldn't be bothered with this kind of stuff and now is a top notch programmer working for big companies (Symantec, Oracle and such). What's most important in this business is the experience, nothing beats that. You can learn all you want from books/courses/studies but at the end of the day it all comes down to 'Are you experienced enough to do it without really thinking about it?'. That's the feeling I get when I'm asking my friends who are established programmers for some help. They're able to solve the problems that take me several hours in 5 minutes and do it way more efficiently and elegantly than I could ever hope to do now. Because they all have 10+ years in doing this stuff under their belts they know the realities, all the design patterns and best ways to do things inside out.

That's the thing, you don't really get a lot of practical experience at uni; at least not if it's anything like my uni. If you want to learn it by yourself, you better do it while actually developing a real application, then throw it into the trash bin and code it again from scratch. Just better. And if you go for a degree, you should still do the same.

That's pretty much what I did while completing my bachelor's. Quickly got a Job in the C# area. Aside from being a formal requirement to the job offer, the degree didn't matter in the least. I never even had to actually show it to anyone.

On April 15 2014 03:13 Manit0u wrote:Also, a stupid question perhaps, but related to the subject. Does C# have a method that would convert '000018920300' into '189203.00'?

The rather dirty way for me to do it was take it as a string, strip leading zeros, split into two substrings and join them with '.' to get the final string.

"Dirty", but separate it into a clean method with a nice name and documentation. The next time you need to adjust it or find you need something similar, see how you could generalize it.
There's no point in writing a regex - which is hard to grasp unless you use them a lot - for something that amounts to a short and easy to understand method. And even if you someday discover a built in method in C# that does exactly that, there's still an argument to be made for having a method wrapped around it: Your intent will be clearer and you will have less direct API calls throughout your code.
If you have a good reason to disagree with the above, please tell me. Thank you.
Ame
Profile Joined October 2009
United States246 Posts
April 14 2014 18:59 GMT
#9345
On April 14 2014 22:04 misirlou wrote:
I made a sieve with some optimizations, source at https://github.com/Misirlou/CparParallelSieve/blob/master/single.c
There are 3 different functions, named 1,2 and 3 . The first function is terribly slow for anything greater than n=2^27, that is computing all primes lower than 2^27. I can get the other ones to run till 2^33 under a minute. The 3rd function takes an extra argument that defines a block size. This is used to split the sieve into little pieces so the array gets stored in cache instead of RAM, which is a much faster memory, as the results I collected can prove, on google spreadsheet
I also stored the primes not as an int array but in a char array. Every bit of a char represents a number, so one char can hold 8 "numbers". If it's unmarked when the computation is finished, it means that number is a prime. I also don't have a position for even numbers, I skip them entirely because the only even number that is prime is 2. All of this was done in an effort to use the least amount of memory. The code gets a little more tricky and it takes more operations to access an element but these operations are meaningless compared to what I save in memory access.

On your code shouldn't marked and sieve be the same array?



Them cache/memory blocks. Such char array. Much advanced. Wow. :|

Hah, my code is pretty terrible in efficiency (like not combining marked and sieve array). Probably the only thing I had going for it was skipping even numbers when initializing the sieve array.

It was something I wrote up a year ago or so as a supernoob that I only recently revisited. Actually one of the quick fixes I did was to stop storing stuff in a HashMap (to answer stuff like 'given prime number p, how many prime numbers are smaller') and moving it to primitive array for binary search. Was like 'gg I just knocked off 90% of the run time'.
]343[
Profile Blog Joined May 2008
United States10328 Posts
April 14 2014 22:17 GMT
#9346
On April 14 2014 22:04 misirlou wrote:
I made a sieve with some optimizations, source at https://github.com/Misirlou/CparParallelSieve/blob/master/single.c
There are 3 different functions, named 1,2 and 3 . The first function is terribly slow for anything greater than n=2^27, that is computing all primes lower than 2^27. I can get the other ones to run till 2^33 under a minute. The 3rd function takes an extra argument that defines a block size. This is used to split the sieve into little pieces so the array gets stored in cache instead of RAM, which is a much faster memory, as the results I collected can prove, on google spreadsheet
I also stored the primes not as an int array but in a char array. Every bit of a char represents a number, so one char can hold 8 "numbers". If it's unmarked when the computation is finished, it means that number is a prime. I also don't have a position for even numbers, I skip them entirely because the only even number that is prime is 2. All of this was done in an effort to use the least amount of memory. The code gets a little more tricky and it takes more operations to access an element but these operations are meaningless compared to what I save in memory access.

On your code shouldn't marked and sieve be the same array?





In C++ you can use things like bitsets to do this more easily
Writer
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2014-04-15 00:51:21
April 15 2014 00:50 GMT
#9347
--- Nuked ---
tofucake
Profile Blog Joined October 2009
Hyrule19210 Posts
April 15 2014 00:54 GMT
#9348
Doing math in functional languages is simpler.
Liquipediaasante sana squash banana
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
April 15 2014 02:47 GMT
#9349
On April 15 2014 09:54 tofucake wrote:
Doing math in functional languages is simpler.


Might be a reason why most operating systems run on C and not higher-level stuff.
Time is precious. Waste it wisely.
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
April 15 2014 04:33 GMT
#9350
On April 15 2014 11:47 Manit0u wrote:
Show nested quote +
On April 15 2014 09:54 tofucake wrote:
Doing math in functional languages is simpler.


Might be a reason why most operating systems run on C and not higher-level stuff.

I thought higher level stuff had performance issues and that was the reason. Doing math in C is horrible compared to in R or matlab.
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
April 15 2014 17:47 GMT
#9351
On April 15 2014 13:33 obesechicken13 wrote:
Show nested quote +
On April 15 2014 11:47 Manit0u wrote:
On April 15 2014 09:54 tofucake wrote:
Doing math in functional languages is simpler.


Might be a reason why most operating systems run on C and not higher-level stuff.

I thought higher level stuff had performance issues and that was the reason. Doing math in C is horrible compared to in R or matlab.


Well, that's why Java still keeps primitive data types despite Integer/Boolean/etc being redundant.
windzor
Profile Joined October 2010
Denmark1013 Posts
April 15 2014 18:16 GMT
#9352
On April 16 2014 02:47 darkness wrote:
Show nested quote +
On April 15 2014 13:33 obesechicken13 wrote:
On April 15 2014 11:47 Manit0u wrote:
On April 15 2014 09:54 tofucake wrote:
Doing math in functional languages is simpler.


Might be a reason why most operating systems run on C and not higher-level stuff.

I thought higher level stuff had performance issues and that was the reason. Doing math in C is horrible compared to in R or matlab.


Well, that's why Java still keeps primitive data types despite Integer/Boolean/etc being redundant.


Java keeps primitive types because its too much of a hassle to remove it from the language, even though the big Java guys wants to remove them.
Yeah
FakePseudo
Profile Joined January 2012
Belgium716 Posts
April 15 2014 18:31 GMT
#9353
On April 15 2014 13:33 obesechicken13 wrote:
Show nested quote +
On April 15 2014 11:47 Manit0u wrote:
On April 15 2014 09:54 tofucake wrote:
Doing math in functional languages is simpler.


Might be a reason why most operating systems run on C and not higher-level stuff.

I thought higher level stuff had performance issues and that was the reason. Doing math in C is horrible compared to in R or matlab.


Never understood why people would go for matlab/octave. If you're looking for speed and serious math libraries (eigenvectors, differential equations, ...) then Fortran isn't that really uglier and at least it has some consistency to it. If you're looking for ease of use and "fun" libraries (plotting and all things data presentation) then use some really dev-friendly, modern language like python with numpy or w/e
I am the 0.0007% /forum/viewpost.php?post_id=17208334|| Big Black Women Vocals Is Like Porn to my Ears ||San Antonio Spurs|Boston Celtics||#1EZToss Hater;
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
April 16 2014 06:19 GMT
#9354
On April 16 2014 03:16 windzor wrote:
Show nested quote +
On April 16 2014 02:47 darkness wrote:
On April 15 2014 13:33 obesechicken13 wrote:
On April 15 2014 11:47 Manit0u wrote:
On April 15 2014 09:54 tofucake wrote:
Doing math in functional languages is simpler.


Might be a reason why most operating systems run on C and not higher-level stuff.

I thought higher level stuff had performance issues and that was the reason. Doing math in C is horrible compared to in R or matlab.


Well, that's why Java still keeps primitive data types despite Integer/Boolean/etc being redundant.


Java keeps primitive types because its too much of a hassle to remove it from the language, even though the big Java guys wants to remove them.


I think this is a better to say it. http://stackoverflow.com/a/5199425/1091781
Ben...
Profile Joined January 2011
Canada3485 Posts
Last Edited: 2014-04-16 09:12:38
April 16 2014 09:09 GMT
#9355
On April 15 2014 13:33 obesechicken13 wrote:
Show nested quote +
On April 15 2014 11:47 Manit0u wrote:
On April 15 2014 09:54 tofucake wrote:
Doing math in functional languages is simpler.


Might be a reason why most operating systems run on C and not higher-level stuff.

I thought higher level stuff had performance issues and that was the reason.

A few years ago that certainly was the case. Haskell, for instance, used to be dreadfully slow. However, now it is approaching being nearly as fast as C, and a good Haskell programmer, just by virtue of the language, can write something significantly faster than a person doing something in C. Back in the day, computers used to be rather expensive so making code run as fast as possible was ideal. However, now we have fairly cheap computers that are quite powerful so the larger cost to a company will be the programmer, not the equipment used by that person, so if they can make that person more productive, it gives the company a better return for their money. The downside is that functional languages are really tricky to learn so you typically have to get really smart people, who might cost more money. But they will be able to code things much faster.

Of course when it comes to OSes and things like that, speed is still king, so the fastest languages will still be dominant. Being nearly as fast as C isn't the same as being as fast as C.

Which leads to this:

On April 15 2014 09:50 Nesserev wrote:
Can anyone tell me when it's better/more preferable to use a functional programming language like Haskell over an OO/Imperative programming language?

Some things are really easy/fast to code in functional programming languages compared to OO/Imperative programming languages, but I can't put a finger on what it is, or when this is the case. I had to program Battleships in Haskell, which was a total b!tch to be honest...

Code bloat and productivity of the programmer is what was often mentioned to us in my class that focused on functional languages. As you have probably experienced, code done in functional languages is significantly shorter than code from many imperative languages (for me, probably 2/3 to 3/4 of each haskell assignment was tests with maybe 50-100 lines of actual program code). This makes it significantly easier to maintain a database of code over time since all of the different pieces of code are upwards of 50-90% shorter than their C/Java counterparts. Also, due to the nature of functional languages, it is much less likely for there to be weird bugs introduced, simply because the code probably wouldn't compile due to how functional languages are structured. Of course I'm more talking things like merge mess ups or copy/paste errors. Stuff like the goto fail error we saw on the open source SSL implementation Apple was using would not likely have happened in Haskell because GHC would have complained. Probably the same for the 8 year old GnuTLS issues (From what I have read, those were pretty rough. C library functions that should not have been in such critical code, pieces of code for encrypting that didn't do what they were supposed to upon testing). This is all combined with the code being much simpler to read (after you know the language well of course) makes it so you can be much more productive with functional languages. Of course the downside is you have to be insanely smart to use functional languages effectively. But once you do, you can do some pretty crazy things with them. We built another programming language in Haskell in about 40 lines in total.

Though, with all of the huge security issues we've been seeing with stuff like Heartbleed and the above goto fail and GnuTLS, I wouldn't be shocked if certified programming becomes much more prevalent fairly soon. I've done a bit of it and it is pretty cool. The idea behind certified programming is basically that you can prove something does exactly what you say it does. This is done so mathematically via proofs. One of the more common certified programming languages, Coq (yup, that's the name), is very Haskell-like. It is a functional language in which types are handled in a very similar fashion. A lot of the code I have seen is basically Haskell code with a slightly more verbose syntax.
"Cliiiiiiiiiiiiiiiiide" -Tastosis
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
April 16 2014 18:53 GMT
#9356
On April 16 2014 18:09 Ben... wrote:
Show nested quote +
On April 15 2014 13:33 obesechicken13 wrote:
On April 15 2014 11:47 Manit0u wrote:
On April 15 2014 09:54 tofucake wrote:
Doing math in functional languages is simpler.


Might be a reason why most operating systems run on C and not higher-level stuff.

I thought higher level stuff had performance issues and that was the reason.

A few years ago that certainly was the case. Haskell, for instance, used to be dreadfully slow. However, now it is approaching being nearly as fast as C, and a good Haskell programmer, just by virtue of the language, can write something significantly faster than a person doing something in C. Back in the day, computers used to be rather expensive so making code run as fast as possible was ideal. However, now we have fairly cheap computers that are quite powerful so the larger cost to a company will be the programmer, not the equipment used by that person, so if they can make that person more productive, it gives the company a better return for their money. The downside is that functional languages are really tricky to learn so you typically have to get really smart people, who might cost more money. But they will be able to code things much faster.

Of course when it comes to OSes and things like that, speed is still king, so the fastest languages will still be dominant. Being nearly as fast as C isn't the same as being as fast as C.

Which leads to this:

Show nested quote +
On April 15 2014 09:50 Nesserev wrote:
Can anyone tell me when it's better/more preferable to use a functional programming language like Haskell over an OO/Imperative programming language?

Some things are really easy/fast to code in functional programming languages compared to OO/Imperative programming languages, but I can't put a finger on what it is, or when this is the case. I had to program Battleships in Haskell, which was a total b!tch to be honest...

Though, with all of the huge security issues we've been seeing with stuff like Heartbleed and the above goto fail and GnuTLS, I wouldn't be shocked if certified programming becomes much more prevalent fairly soon. I've done a bit of it and it is pretty cool. The idea behind certified programming is basically that you can prove something does exactly what you say it does. This is done so mathematically via proofs. One of the more common certified programming languages, Coq (yup, that's the name), is very Haskell-like. It is a functional language in which types are handled in a very similar fashion. A lot of the code I have seen is basically Haskell code with a slightly more verbose syntax.


Well, Formal Methods comes to mind when you say 'certified programming'. In particular, Promela
Liebig
Profile Joined August 2010
France738 Posts
April 16 2014 19:39 GMT
#9357
Coq has also been used to make a formal proof of the Feit-Thompson Theorem (written proof is equivalent of 2 books) and found errors in the written proof.
It is also used to make a certified C compiler (CompCert).
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
April 16 2014 21:01 GMT
#9358
I have an OOP question. For reference, I'm using C#.net

I'm trying to discipline myself by sticking to the SOLID principles as much as I can. For example, I know that when one particular object has a dependency on another, it's better to extract that dependency out and provide an interface to an implementation, so the implementation can change without having to change the object.

But what happens when I have a need to combine multiple objects to perform a higher level task. Say that I have Object A which does Task A, and Object B which does Task B, but I need to do Task C, which depends on the implementations of Task A and Task B. Should Task C be done by a completely new object, like Object C? If so, should Object C have it's own interfaces that Object A and Object B implement? Or is there some other way? Hope that makes sense. It's hard to describe my exact problem without a lot of details.
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
Last Edited: 2014-04-16 21:52:35
April 16 2014 21:44 GMT
#9359
On April 16 2014 18:09 Ben... wrote:
Show nested quote +
On April 15 2014 13:33 obesechicken13 wrote:
On April 15 2014 11:47 Manit0u wrote:
On April 15 2014 09:54 tofucake wrote:
Doing math in functional languages is simpler.


Might be a reason why most operating systems run on C and not higher-level stuff.

I thought higher level stuff had performance issues and that was the reason.

A few years ago that certainly was the case. Haskell, for instance, used to be dreadfully slow. However, now it is approaching being nearly as fast as C, and a good Haskell programmer, just by virtue of the language, can write something significantly faster than a person doing something in C. Back in the day, computers used to be rather expensive so making code run as fast as possible was ideal. However, now we have fairly cheap computers that are quite powerful so the larger cost to a company will be the programmer, not the equipment used by that person, so if they can make that person more productive, it gives the company a better return for their money. The downside is that functional languages are really tricky to learn so you typically have to get really smart people, who might cost more money. But they will be able to code things much faster.

Of course when it comes to OSes and things like that, speed is still king, so the fastest languages will still be dominant. Being nearly as fast as C isn't the same as being as fast as C.

Which leads to this:

Show nested quote +
On April 15 2014 09:50 Nesserev wrote:
Can anyone tell me when it's better/more preferable to use a functional programming language like Haskell over an OO/Imperative programming language?

Some things are really easy/fast to code in functional programming languages compared to OO/Imperative programming languages, but I can't put a finger on what it is, or when this is the case. I had to program Battleships in Haskell, which was a total b!tch to be honest...

Code bloat and productivity of the programmer is what was often mentioned to us in my class that focused on functional languages. As you have probably experienced, code done in functional languages is significantly shorter than code from many imperative languages (for me, probably 2/3 to 3/4 of each haskell assignment was tests with maybe 50-100 lines of actual program code). This makes it significantly easier to maintain a database of code over time since all of the different pieces of code are upwards of 50-90% shorter than their C/Java counterparts. Also, due to the nature of functional languages, it is much less likely for there to be weird bugs introduced, simply because the code probably wouldn't compile due to how functional languages are structured. Of course I'm more talking things like merge mess ups or copy/paste errors. Stuff like the goto fail error we saw on the open source SSL implementation Apple was using would not likely have happened in Haskell because GHC would have complained. Probably the same for the 8 year old GnuTLS issues (From what I have read, those were pretty rough. C library functions that should not have been in such critical code, pieces of code for encrypting that didn't do what they were supposed to upon testing). This is all combined with the code being much simpler to read (after you know the language well of course) makes it so you can be much more productive with functional languages. Of course the downside is you have to be insanely smart to use functional languages effectively. But once you do, you can do some pretty crazy things with them. We built another programming language in Haskell in about 40 lines in total.

Though, with all of the huge security issues we've been seeing with stuff like Heartbleed and the above goto fail and GnuTLS, I wouldn't be shocked if certified programming becomes much more prevalent fairly soon. I've done a bit of it and it is pretty cool. The idea behind certified programming is basically that you can prove something does exactly what you say it does. This is done so mathematically via proofs. One of the more common certified programming languages, Coq (yup, that's the name), is very Haskell-like. It is a functional language in which types are handled in a very similar fashion. A lot of the code I have seen is basically Haskell code with a slightly more verbose syntax.


Good points regarding Haskell and perhaps other functional languages starting to take a larger role in bigger projects.

C is used for OS development not just because of speed, but also because it's easy to cross compile for a different target architecture, doesn't require much as far as run-time initialization, and executes in a predictable, easy to debug fashion. It also has a tons of previous support in terms of drivers and libraries for linux, solaris, etc.

I look forward to the next-generation of C-like-but-strongly-typed languages of Rust and Go for new operating systems such as Firefox OS. Note that, because the compiler technology for these languages is ~20 years behind C, it will be some time before it reaches performance parity, even if its a better language for writing faster code.

As far as certified programming languages go, there are different levels depending on the security or safety of the system. C is actually one of the better examples of a language that's capable of certifying. For example, if you're going to write code to go to space, it's probably had some Formal Methods applied to it. For automotive code, there is a code standard called MISRA. Locomotive, aerospace, medical, and security critical all have their own ways of certifying code.

You can use a C syntax checker such as Lint to apply the rules from a certification to your code base to check for things like "goto fail" being in there twice. In fact, it's kind of baffling that Apple didn't have warnings turned on, which would have certainly shown that code-smell that half of a function had no entry point for which it could be executed from.

Note that certification has much more to do with how you test code rather than the code itself, with the notable exception of MISRA.

I guess my point is that it's not the languages fault for heartbleed and goto fail;, etc... One of C's biggest strengths is also its weakness: it allows the programmer extreme liberties such that they can get themselves in trouble easily.
Any sufficiently advanced technology is indistinguishable from magic
Arevall
Profile Joined February 2010
Sweden1133 Posts
Last Edited: 2014-04-17 09:26:54
April 17 2014 09:24 GMT
#9360
I need some help with my hobby project. I'm trying to make a pentomino puzzle AI based on genetic programming in python.

[image loading]

I'll get to my question after a somewhat brief introduction.

Workflow is:
0. Initiate a empty game grid, for example array of 5x5 with elements equal to -1.
1. The AI will get a random piece.
2. The AI will then need to test every possible way to place the piece, and for each way calculate a score.
(The score will be calculated from (for example) number of holes and number of edges touching the piece.
3. Place piece, return to 1 until no empty squares.

Rules:
No collisions, so possible to place pieces over each other!

I've stored the pieces in 5x5 arrays using numpy. It was easy because then I only needed to enter a piece once. The pentomino 'P' looks something like this:
[[0,0,0,0,0],
[0,0,1,0,0],
[0,0,1,1,0],
[0,0,1,1,0],
[0,0,1,1,0]]

Problem: Solving the possible ways to place a piece:
I'm a bit stumped over getting this done as quickly as possible. My current idea is to expand the 5x5 game grid to 7x7 by padding it with zeros. Then iterate over all elements and if they are equal to -1 I'll smack my piece over it and calculate a score.
But if the game grid gets larger, like 10x10, that means going over 100 elements 8 times for piece 'P'.
Anyone have an idea of an alternative way of solving this?
Prev 1 466 467 468 469 470 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 6h 58m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 247
MindelVK 12
UpATreeSC 8
StarCraft: Brood War
Britney 50398
Calm 4485
Bisu 2180
Mini 749
EffOrt 642
Light 635
Soma 559
Horang2 449
ggaemo 249
ZerO 218
[ Show more ]
Dewaltoss 188
actioN 142
hero 103
Hyun 75
Sharp 66
Leta 54
PianO 54
Aegong 36
sorry 28
Backho 23
Hm[arnc] 19
Rock 18
Movie 16
IntoTheRainbow 14
Sacsri 13
Terrorterran 10
ajuk12(nOOB) 10
zelot 8
Dota 2
Gorgc5457
Counter-Strike
fl0m2363
pashabiceps1580
zeus729
byalli350
edward84
Other Games
Grubby1640
B2W.Neo1530
Liquid`RaSZi1025
FrodaN858
Beastyqt727
qojqva638
KnowMe162
DeMusliM145
Hui .136
ArmadaUGS122
QueenE120
monkeys_forever106
C9.Mang081
Mew2King71
Trikslyr56
elazer22
ZerO(Twitch)17
Organizations
Dota 2
PGL Dota 2 - Main Stream43
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 17 non-featured ]
StarCraft 2
• Dystopia_ 1
• AfreecaTV YouTube
• sooper7s
• intothetv
• Migwel
• Kozan
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• HerbMon 16
• Azhi_Dahaki16
• Michael_bg 1
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• imaqtpie170
Other Games
• WagamamaTV432
• Shiphtur242
Upcoming Events
PiGosaur Cup
6h 58m
GSL
16h 28m
Classic vs Cure
Maru vs Rogue
GSL
1d 16h
SHIN vs Zoun
ByuN vs herO
OSC
1d 17h
OSC
1d 19h
Replay Cast
2 days
Escore
2 days
The PondCast
2 days
WardiTV Invitational
2 days
Zoun vs Ryung
Lambo vs ShoWTimE
OSC
3 days
[ Show More ]
Replay Cast
3 days
CranKy Ducklings
3 days
RSL Revival
3 days
SHIN vs Bunny
ByuN vs Shameless
WardiTV Invitational
3 days
Krystianer vs TriGGeR
Cure vs Rogue
uThermal 2v2 Circuit
3 days
BSL
4 days
Replay Cast
4 days
Sparkling Tuna Cup
4 days
RSL Revival
4 days
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
4 days
BSL
5 days
GSL
5 days
Afreeca Starleague
5 days
Monday Night Weeklies
5 days
Afreeca Starleague
6 days
CranKy Ducklings
6 days
Liquipedia Results

Completed

Proleague 2026-05-02
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

YSL S3
Escore Tournament S2: W6
KK 2v2 League Season 1
BSL 22 Non-Korean Championship
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.