top | item 11823691

SyntaxDB – Quickly look up syntax for programming languages

183 points| sidcool | 9 years ago |syntaxdb.com | reply

71 comments

order
[+] stepvhen|9 years ago|reply
I would suggest using "learn x in y minutes" [1] if you need to lookup syntax for something. It doesn't feature the "for loop in java" search function, but it has more languages than this tool, as well as tools like vim, git, tmux, with many files having multiple natural language translations. It is also community driven, so if there is something missing it is only a pull-request away.

[1] https://learnxinyminutes.com/

[+] pc2g4d|9 years ago|reply
Cool site, but are there no English translations? Could be good for my (non-computer) language learning, though!
[+] mywittyname|9 years ago|reply
Right now, this isn't really any better than looking at an individual language's site for syntax, this just offers a common user interface. For example, the site has no idea what a list comprehension is, yet that's a fundamental component of python.

I think a transpiler would be absolutely awesome -- even if it only works on curated code samples on the site. Something that shows how a piece of code can be expressed in many different languages. This would be extremely useful for things like Regular Expressions (also, no results found for regular expressions on the site), which are in just about every language, but are treated very differently.

Personally, I think that's your killer idea. It will be damn hard to do, but if you can make it work, I think you'll end up with a lot of visitors. Knowing the language idioms is key to understanding a language.

[+] thenipper|9 years ago|reply
Would a transpiler kind of be like rosetta code?
[+] anthnguyen94|9 years ago|reply
Hey HN, I'm the developer behind SyntaxDB. This feedback is good and I encourage people to keep it coming!

A lot of responses will be about "there's no result for x". You're right, there isn't nearly as much content on the site as I'd like there to be!

The content is actually hand written, and as of right now focuses on the very basic programming fundamentals common across all of the languages. The plan is to triple the amount of content in the database (adding DS, special classes, parsing, etc.), and eventually open up the database to outside contributions.

Additional languages are coming too!

[+] Etheryte|9 years ago|reply
How do you plan to compare and compete with other projects such as Stack Overflow documentation (currently in closed beta iirc) which, as far as I can see, offers the same functionality, but a larger user base?
[+] joelg236|9 years ago|reply
It would be very awesome to have this backend data user-contributed, makes the burden of adding and improving a lot less on you. I'm looking through the sections and see lots of little tiny things that would be a quick PR on github, and I'm sure there are tons of people who'd help out.

Love the idea!

[+] smhenderson|9 years ago|reply
Good to know, I was coming to say something about smart pointers in C++ and a few other things I tried with no results.

Not sure how you're doing the querying but when I dropped the "smart" from "C++ smart pointers" it did return a result. Does every word in the search have to match then? I'd have thought, similar to Google, that it would return results where at least some of the search keywords matched even if they all don't.

Anyway, it looks like a good start. Even for people who already know a lot about programming it should be really useful for those times when you know what you need but just can't quite remember the full syntax of something.

[+] arviewer|9 years ago|reply
Don't try to explain basic concepts in all languages. Better make sure that the languages you have are covered for as much as possible. Then add other languages.
[+] bijection|9 years ago|reply
Great job! Have you considered moving the example section above the notes section?
[+] adontz|9 years ago|reply
Idea is good, but search does not take into account language specifics. I mean same keywords do not mean same things in different languages. For instance, for and foreach are one and the same in Python (actually there is no for, just foreach named for), so if look for Python version of C#'s foreach I find nothing.
[+] anthnguyen94|9 years ago|reply
I actually have something in place which handles some cases of differences in keywords across languages. For example, searching for "dictionary in java" would return a HashMap.

I guess I didn't account the specific "foreach" keyword with C# (I have it as "for each"), good catch!

[+] robbles|9 years ago|reply
A while back, there was a service on the front page that was a combination of search engine for code, static analysis, and git repository browser. The initial implementation was for Golang only.

Does anybody remember what that project was? Does it still exist?

Slightly OT, sorry. This project just reminded me of it.

[+] wasd|9 years ago|reply
Source graph does this but now supports many languages.
[+] SmellTheGlove|9 years ago|reply
This is a very good idea. As others have said, and the creator acknowledged, there isn't a lot of content yet. Community contribution would be very cool.

I'm not sure if I have a good idea here or not, but focusing on older and/or more esoteric languages is a potential niche. For instance, and these are real examples, maybe I've inherited some SAS code with a nasty DATA step and I don't really know how a MERGE works. Or COBOL. I always have ridiculous COBOL things to google.

As someone else pointed out, though, I think you need some cross-search between idioms. I might not know what a SAS DATA MERGE is, but if I look for a SAS join, tell me how to do it in PROC SQL or the DATA step.

Keep going, I think this is very cool.

[+] quaffapint|9 years ago|reply
I think this would be great to open up to the community to maintain. Maybe you approve it initially, and eventually come up with a system for community approval.
[+] alexkavon|9 years ago|reply
Agreed. A moderation approach and applied merit could foster a healthy community as well as innovation with this.
[+] jkoudys|9 years ago|reply
I like this site, but i'm uncomfortable with it for the same reason w3schools is such a steaming pile. It can be more dangerous to project authority but not actually be accurate.

I don't have to look for long to find inaccurate statements, e.g. the page that describes "for of" in ecma states that order is not guaranteed, when the order of an `of` is however the iterator is defined for that collection. e.g. `for (const a of (function*() { yield 1; yield 2; })())` is certainly going to have an order. I think they were just confusing it with for in.

[+] fish2000|9 years ago|reply
Good start but -- some C++ stuff is wrong, e.g. in the bit on friend functions, a member function prototype is written with an empty block instead of a terminal ";". Subtle, but you know. Also, more subjectively, std::string is described as immutable, but with no further discussion about what that means or how that might work.

Just sayin. Frankly I like how it's not Wikipedianishly drowning in citations and/or demands for same -- but how does it get updated? I immediately tried to expand on those two issues I mentioned but there was no sort of UX recourse for my pedantic urges (FWIW)

[+] anthnguyen94|9 years ago|reply
Thanks for pointing that out! As of right now, it all gets updated manually (there's an internal CMS I built and use). As of right now, when people point out corrections they do so via feedback form, and I update accordingly (if I can verify it). Not the greatest but it's what's in place for the time being.

It'll later be open for others to provide new concepts and corrections.

[+] Gys|9 years ago|reply
Ideally to me this is part of the editor. I use Visual Code + Go.

I think there is still a lot of improvement possible for the help that the editor (plus tools) can offer. Much more (and more intelligent !) help and info to be shown while I type or move around in code. At the very least instantly show parameter types plus full docs on every function my cursor is on. Visual Code does a good job with the Go plugin but it could be faster. And there is only so much a plugin can do.

If AI is really the future of coding then it least at some point it should be more helpful before it takes over...

[+] theseoafs|9 years ago|reply
Three rather simple queries I ran that turned up with nothing:

    do notation in haskell
    with python
    function pointer c
[+] anthnguyen94|9 years ago|reply
The site doesn't actually support Haskell or Obj-C atm (will in the future).

I also need to improve the search engine to handle queries with additional words that might give a null result, as well as words like "foreach" (that has to do with the database). This will be fixed very soon.

It is bad that there are missing concepts, and I'm fully aware that this isn't even close to complete. The goal in the future is to have as few null result queries as possible. I actually make note of queries that don't provide results so I'm glad everyone's making these known, it'll only make the database better in the future!

[+] gresrun|9 years ago|reply

   objective-c blocks
   blocks in objective-c
[+] daenney|9 years ago|reply
Is there any way to suggest improvements, or heck, raise PRs, instead of using the feedback button?

For example, the for in Python should include an example using enumerate too which I'd be happy to add and contain some additional docs on xrange vs range in Python 2 vs Python 3.

[+] aneil|9 years ago|reply
I used the pattern suggested, but came up with no useful results after 3 tries:

* "channels in go" (no result)

* "mutex"(no result)

* "generator in python" (returned a page describing the Python programming language)

[+] aardvark179|9 years ago|reply
It's not a bad idea but it seems a bit sparse at the moment even in the languages it does support. Search for lambda does give anything about Java 8's lambda syntax, and search for annotation returns nothing at all.
[+] blairanderson|9 years ago|reply
Pretty darn cool!

Feature suggestions:

- include the code-highlighted syntax block in the typeahead suggestions. - When i hit 'enter' on a typeahead suggestion, send the user to the page instead of just filling the input.