• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 17:47
CET 23:47
KST 07:47
  • 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
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
RSL Offline FInals Sea Duckling Open (Global, Bronze-Diamond) $5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
BW General Discussion Which season is the best in ASL? Data analysis on 70 million replays BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET [BSL21] RO16 Group C - Saturday 21:00 CET Small VOD Thread 2.0
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread ZeroSpace Megathread Nintendo Switch Thread The Perfect Game Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
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
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1712 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
Poland17495 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
Hyrule19167 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
Poland17495 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 1h 14m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
elazer 110
PiGStarcraft82
CosmosSc2 19
StarCraft: Brood War
Shuttle 503
Larva 145
Dota 2
syndereN1178
League of Legends
C9.Mang0117
Counter-Strike
Foxcn415
Other Games
Grubby6866
FrodaN918
fl0m705
Liquid`Hasu500
RotterdaM184
ArmadaUGS97
Maynarde86
ZombieGrub30
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• HeavenSC 59
• musti20045 49
• IndyKCrew
• Migwel
• sooper7s
• AfreecaTV YouTube
• intothetv
• Kozan
• LaughNgamezSOOP
StarCraft: Brood War
• RayReign 61
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• Ler113
League of Legends
• Doublelift2719
• TFBlade1075
Other Games
• imaqtpie1328
• Shiphtur267
Upcoming Events
Replay Cast
1h 14m
The PondCast
11h 14m
OSC
17h 14m
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
1d 1h
Korean StarCraft League
2 days
CranKy Ducklings
2 days
WardiTV 2025
2 days
SC Evo League
2 days
BSL 21
2 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
2 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
[ Show More ]
Sparkling Tuna Cup
3 days
WardiTV 2025
3 days
OSC
3 days
BSL 21
3 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
4 days
Wardi Open
4 days
StarCraft2.fi
4 days
Monday Night Weeklies
4 days
Replay Cast
5 days
WardiTV 2025
5 days
StarCraft2.fi
5 days
PiGosaur Monday
6 days
StarCraft2.fi
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
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 © 2025 TLnet. All Rights Reserved.