• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 19:11
CET 01:11
KST 09:11
  • 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
[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Weekly Cups (October 19-25): Clem triples first in 5.0.175Evil Geniuses - shutting down21ISSL (IntoTheTV x SOOP SC2 League): Premier6Weekly Cups (October 12-18): 5.0.17 era begins1[$1250] International ShieldBattery League99
StarCraft 2
General
No more SC2 streamers on team liquid? Evil Geniuses - shutting down Behind the Blue - Team Liquid History Book SC2 Power Rank: epic29 Weekly Cups (October 19-25): Clem triples first in 5.0.17
Tourneys
Stellar Fest TWO the Moon (Dec 16-20) Sparkling Tuna Cup - Weekly Open Tournament RSL goes to London! 2026 Offline Finals Nov 21-22 ISSL (IntoTheTV x SOOP SC2 League): Premier RSL 2026 Offline Finals LCQ Sign-Ups
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[D] the control group Simple Questions/Answers [G] How to playtest arcade maps [A] Nemrods 1/4 players
External Content
Mutation # 550 Graveyard Shift The PondCast: SC2 News & Results Mutation # 549 Endless Sparkles Mutation # 548 Shining Bright
Brood War
General
[Megathread] Daily Funny Videos BW General Discussion Mathematicians needed to calc "Low Econ Epicness" Rollback Netcode in Brood War SCHNAIL now supports Remastered
Tourneys
[Megathread] Daily Proleagues [IPSL] IPSL Winter 26-27 Ro24 is HERE! [$1250] International ShieldBattery League [ASL22] Grand Finals
Strategy
50,000-Word Terran Builds Memo 2026-10-22 Cliff Jump Revisited (1 in a 1000 strategy) Simple Questions, Simple Answers
Other Games
General Games
Deus Ex 3!? Stormgate/Frost Giant Megathread Nintendo Switch Thread Mobile Legends: Bang Bang Armies of Exigo - YesYes?
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread European Politico-economics QA Mega-thread
Fan Clubs
Reynor Fan Club The Flash Fan Club Serral Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Why I built Repalyzer (1.1.…
BlueStar
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 9776 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
Poland17868 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
Hyrule19266 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
Poland17868 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
Replay Cast
08:00
QMC 2: Invitational Tournament
CranKy Ducklings56
ChoboTeamLeague
06:30
Best Games SC
PiGStarcraft493
Discussion
BSL
05:00
RO24 Group D
Ret vs DragOn
Doodle vs Dienmax
ZZZero.O189
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft501
Codebar 39
StarCraft: Brood War
GuemChi 1593
Rain 1369
Artosis 625
Bisu 327
ZZZero.O 202
ProTech120
White-Ra 97
Dota 2
syndereN241
NeuroSwarm131
League of Legends
Doublelift5267
Super Smash Bros
C9.Mang01655
amsayoshi39
Heroes of the Storm
Grubby3757
Other Games
summit1g13134
FrodaN3252
JimRising 412
KnowMe191
Maynarde101
JuggernautJason25
CosmosSc2 17
Organizations
Other Games
gamesdonequick1692
Counter-Strike
PGL531
[ Show 17 non-featured ]
StarCraft 2
• Hupsaiya 84
• Hinosc 70
• CranKy Ducklings SOOP70
• HeavenSC 31
• musti20045 26
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Laughngamez YouTube
• Migwel
StarCraft: Brood War
• ChaeLyn 18
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• imaqtpie797
• Shiphtur383
Upcoming Events
WardiTV Weekly
11h 49m
Ultimate Battle
11h 49m
Rush vs BeSt
Replay Cast
22h 49m
Rogue vs Classic
Patches Events
1d 12h
PiGosaur Cup
2 days
Kung Fu Cup
2 days
Replay Cast
2 days
The PondCast
3 days
KCM Race Survival
3 days
IntoTheTV X SOOP
5 days
herO vs Rogue
Reynor vs Solar
ByuN vs SHIN
Clem vs MaxPax
[ Show More ]
WardiTV Invitational
5 days
IPSL
5 days
WorsT vs nOmaD
Dewalt vs andersOn
IntoTheTV X SOOP
6 days
WardiTV Invitational
6 days
IPSL
6 days
Azhi_Dahaki vs ggnore13
Double vs WIZARD
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-11-01
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
IPSL Winter 2026-27
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026

Upcoming

1xBet Invitational
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
BLAST Bounty Winter 2027
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 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.